Skip to content

Commit bd70135

Browse files
committed
Merge branch '2-17-stable' into develop
2 parents 32fb433 + ad6a06b commit bd70135

11 files changed

Lines changed: 308 additions & 256 deletions

api/projects/keys.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func (c *KeyController) AddKey(w http.ResponseWriter, r *http.Request) {
9494

9595
// Plain cannot be passed via a request
9696
key.Plain = nil
97+
key.IgnorePlain = true
9798

9899
//if err := key.Validate(true); err != nil {
99100
// helpers.WriteJSON(w, http.StatusBadRequest, map[string]string{
@@ -139,6 +140,7 @@ func (c *KeyController) UpdateKey(w http.ResponseWriter, r *http.Request) {
139140

140141
// Plain cannot be passed via a request
141142
key.Plain = nil
143+
key.IgnorePlain = true
142144

143145
repos, err := helpers.Store(r).GetRepositories(*key.ProjectID, db.RetrieveQueryParams{})
144146
if err != nil {

db/AccessKey.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ type AccessKey struct {
3838

3939
// Secret used internally, do not assign this field.
4040
// You should use methods SerializeSecret to fill this field.
41-
Secret *string `db:"secret" json:"-" backup:"-"`
42-
Plain *string `db:"plain" json:"plain,omitempty"`
41+
Secret *string `db:"secret" json:"-" backup:"-"`
42+
Plain *string `db:"plain" json:"plain,omitempty"`
43+
IgnorePlain bool
4344

4445
String string `db:"-" json:"string"`
4546
LoginPassword LoginPassword `db:"-" json:"login_password"`

db/sql/access_key.go

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func (d *SqlDb) UpdateAccessKey(key db.AccessKey) error {
6868
query := "update access_key set name=?"
6969
args = append(args, key.Name)
7070

71+
if !key.IgnorePlain {
72+
query += ", plain=?"
73+
args = append(args, key.Plain)
74+
}
75+
7176
if key.OverrideSecret {
7277

7378
query += ", type=?, secret=?, source_storage_id=?, source_storage_key=?, source_storage_type=?"
@@ -90,33 +95,65 @@ func (d *SqlDb) UpdateAccessKey(key db.AccessKey) error {
9095
}
9196

9297
func (d *SqlDb) CreateAccessKey(key db.AccessKey) (newKey db.AccessKey, err error) {
93-
insertID, err := d.insert(
94-
"id",
95-
"insert into access_key ("+
96-
"name, "+
97-
"type, "+
98-
"project_id, "+
99-
"secret, "+
100-
"plain, "+
101-
"environment_id, "+
102-
"owner, "+
103-
"storage_id, "+
104-
"source_storage_id, "+
105-
"source_storage_key, "+
106-
"source_storage_type) "+
107-
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
108-
key.Name,
109-
key.Type,
110-
key.ProjectID,
111-
key.Secret,
112-
key.Plain,
113-
key.EnvironmentID,
114-
key.Owner,
115-
key.StorageID,
116-
key.SourceStorageID,
117-
key.SourceStorageKey,
118-
key.SourceStorageType,
119-
)
98+
99+
var insertID int
100+
101+
if key.IgnorePlain {
102+
insertID, err = d.insert(
103+
"id",
104+
"insert into access_key ("+
105+
"name, "+
106+
"type, "+
107+
"project_id, "+
108+
"secret, "+
109+
"environment_id, "+
110+
"owner, "+
111+
"storage_id, "+
112+
"source_storage_id, "+
113+
"source_storage_key, "+
114+
"source_storage_type) "+
115+
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
116+
key.Name,
117+
key.Type,
118+
key.ProjectID,
119+
key.Secret,
120+
key.EnvironmentID,
121+
key.Owner,
122+
key.StorageID,
123+
key.SourceStorageID,
124+
key.SourceStorageKey,
125+
key.SourceStorageType,
126+
)
127+
} else {
128+
insertID, err = d.insert(
129+
"id",
130+
"insert into access_key ("+
131+
"name, "+
132+
"type, "+
133+
"project_id, "+
134+
"secret, "+
135+
"plain, "+
136+
"environment_id, "+
137+
"owner, "+
138+
"storage_id, "+
139+
"source_storage_id, "+
140+
"source_storage_key, "+
141+
"source_storage_type) "+
142+
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
143+
key.Name,
144+
key.Type,
145+
key.ProjectID,
146+
key.Secret,
147+
key.Plain,
148+
key.EnvironmentID,
149+
key.Owner,
150+
key.StorageID,
151+
key.SourceStorageID,
152+
key.SourceStorageKey,
153+
key.SourceStorageType,
154+
)
155+
156+
}
120157

121158
if err != nil {
122159
return

web/src/components/IntegrationExtractValueForm.vue

Lines changed: 111 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,80 @@
11
<template>
2-
<v-form
3-
ref="form"
4-
lazy-validation
5-
v-model="formValid"
6-
>
7-
<v-alert
8-
:value="formError"
9-
color="error"
10-
class="pb-2"
11-
>{{ formError }}</v-alert>
2+
<v-form ref="form" lazy-validation v-model="formValid" v-if="item">
3+
<v-alert :value="formError" color="error" class="pb-2">{{ formError }}</v-alert>
124

13-
<v-text-field
14-
v-model="item.name"
15-
label="Name"
16-
:rules="[v => !!v || 'Name is required']"
17-
required
18-
:disabled="formSaving"
5+
<v-text-field
6+
v-model="item.name"
7+
label="Name"
8+
:rules="[(v) => !!v || 'Name is required']"
9+
required
10+
:disabled="formSaving"
1911
></v-text-field>
20-
<v-row>
21-
<v-col cols="12" md="12" class="pb-0">
22-
<div class="ml-4 mr-4 mt-6">
23-
<v-select v-model="item.value_source"
24-
label="Source of the Value"
25-
:items="valueSources"
26-
item-value="id"
27-
item-text="text"
28-
:rules="[v => !!v || 'Value Source is required']"
29-
outlined
30-
dense
31-
required
32-
:disabled="formSaving">
33-
</v-select>
34-
<v-select v-model="item.body_data_type"
35-
label="Data Type of Body"
36-
v-if="item.value_source == 'body'"
37-
:items="bodyDataTypes"
38-
item-value="id"
39-
item-text="text"
40-
:rules="[v => !!v || 'Body Data Type is required']"
41-
outlined
42-
dense
43-
required
44-
:disabled="formSaving">
45-
</v-select>
46-
<v-text-field
47-
v-model="item.key"
48-
label="Key *"
49-
:rules="[v => !!v || 'Key is required']"
50-
outlined
51-
dense
52-
required
53-
:disabled="formSaving"
12+
<v-row>
13+
<v-col cols="12" md="12" class="pb-0">
14+
<div class="ml-4 mr-4 mt-6">
15+
<v-select
16+
v-model="item.value_source"
17+
label="Source of the Value"
18+
:items="valueSources"
19+
item-value="id"
20+
item-text="text"
21+
:rules="[(v) => !!v || 'Value Source is required']"
22+
outlined
23+
dense
24+
required
25+
:disabled="formSaving"
5426
>
55-
</v-text-field>
56-
<v-select v-model="item.variable_type"
57-
label="Variable Usage *"
58-
:items="variableTypes"
59-
item-value="id"
60-
item-text="text"
61-
:rules="[v => !!v || 'Variable Type is required']"
62-
outlined
63-
dense
64-
required
65-
:disabled="formSaving">
66-
</v-select>
67-
<v-text-field
68-
v-model="item.variable"
69-
label="Variable *"
70-
:rules="[v => !!v || 'Variable is required']"
71-
outlined
72-
dense
73-
required
74-
:disabled="formSaving"
27+
</v-select>
28+
<v-select
29+
v-model="item.body_data_type"
30+
label="Data Type of Body"
31+
v-if="item.value_source == 'body'"
32+
:items="bodyDataTypes"
33+
item-value="id"
34+
item-text="text"
35+
:rules="[(v) => !!v || 'Body Data Type is required']"
36+
outlined
37+
dense
38+
required
39+
:disabled="formSaving"
40+
>
41+
</v-select>
42+
<v-text-field
43+
v-model="item.key"
44+
label="Key *"
45+
:rules="[(v) => !!v || 'Key is required']"
46+
outlined
47+
dense
48+
required
49+
:disabled="formSaving"
50+
>
51+
</v-text-field>
52+
<v-select
53+
v-model="item.variable_type"
54+
label="Variable Usage *"
55+
:items="variableTypes"
56+
item-value="id"
57+
item-text="text"
58+
:rules="[(v) => !!v || 'Variable Type is required']"
59+
outlined
60+
dense
61+
required
62+
:disabled="formSaving"
63+
>
64+
</v-select>
65+
<v-text-field
66+
v-model="item.variable"
67+
label="Variable *"
68+
:rules="[(v) => !!v || 'Variable is required']"
69+
outlined
70+
dense
71+
required
72+
:disabled="formSaving"
7573
></v-text-field>
76-
</div>
77-
78-
</v-col>
79-
</v-row>
80-
</v-form>
74+
</div>
75+
</v-col>
76+
</v-row>
77+
</v-form>
8178
</template>
8279
<script>
8380
import ItemFormBase from '@/components/ItemFormBase';
@@ -86,47 +83,52 @@ import { EXTRACT_VALUE_TYPE_ICONS, EXTRACT_VALUE_TYPE_TITLES } from '../lib/cons
8683
8784
export default {
8885
mixins: [ItemFormBase, IntegrationExtractorChildValueFormBase],
89-
86+
props: {
87+
integrationId: Number,
88+
},
9089
data() {
9190
return {
9291
EXTRACT_VALUE_TYPE_ICONS,
9392
EXTRACT_VALUE_TYPE_TITLES,
94-
valueSources: [{
95-
id: 'body',
96-
text: 'Body',
97-
}, {
98-
id: 'header',
99-
text: 'Header',
100-
}],
101-
bodyDataTypes: [{
102-
id: 'json',
103-
text: 'JSON',
104-
}, {
105-
id: 'string',
106-
text: 'String',
107-
}],
108-
variableTypes: [{
109-
id: 'environment',
110-
text: 'Variables',
111-
}, {
112-
id: 'task',
113-
text: 'Task Params',
114-
}],
93+
valueSources: [
94+
{
95+
id: 'body',
96+
text: 'Body',
97+
},
98+
{
99+
id: 'header',
100+
text: 'Header',
101+
},
102+
],
103+
bodyDataTypes: [
104+
{
105+
id: 'json',
106+
text: 'JSON',
107+
},
108+
{
109+
id: 'string',
110+
text: 'String',
111+
},
112+
],
113+
variableTypes: [
114+
{
115+
id: 'environment',
116+
text: 'Variables',
117+
},
118+
{
119+
id: 'task',
120+
text: 'Task Params',
121+
},
122+
],
115123
};
116124
},
117125
computed: {
118-
projectId() {
119-
if (/^-?\d+$/.test(this.$route.params.projectId)) {
120-
return parseInt(this.$route.params.projectId, 10);
121-
}
122-
return this.$route.params.projectId;
123-
},
124-
integrationId() {
125-
if (/^-?\d+$/.test(this.$route.params.integrationId)) {
126-
return parseInt(this.$route.params.integrationId, 10);
127-
}
128-
return this.$route.params.integrationId;
129-
},
126+
// integrationId() {
127+
// if (/^-?\d+$/.test(this.$route.params.integrationId)) {
128+
// return parseInt(this.$route.params.integrationId, 10);
129+
// }
130+
// return this.$route.params.integrationId;
131+
// },
130132
},
131133
methods: {
132134
getItemsUrl() {

0 commit comments

Comments
 (0)