4
4
<el-row :gutter =" 20" >
5
5
<el-col :span =" 12" >
6
6
<el-form-item :label =" $t('business.workload.container_name')" prop =" name" >
7
- <ko-form-item itemType =" input" @input =" changeName" v-model =" form.name" />
7
+ <ko-form-item itemType =" input" @input =" changeName" v-model =" form.name" />
8
8
</el-form-item >
9
9
</el-col >
10
10
</el-row >
20
20
</el-col >
21
21
<el-col :span =" 8" >
22
22
<el-form-item :label =" $t('business.workload.container_image')" prop =" image" :rules =" inputRule" v-if =" repo.name===''" >
23
- <ko-form-item placeholder =" e.g. nginx:latest" itemType =" input" v-model =" form.image" />
23
+ <ko-form-item placeholder =" e.g. nginx:latest" itemType =" input" v-model =" form.image" />
24
24
</el-form-item >
25
25
<el-form-item :label =" $t('business.workload.container_image')" prop =" image" :rules =" selectRule" v-else >
26
26
<el-select v-model =" form.image" @change =" changeImage(form.image)" style =" width : 100% " filterable >
31
31
</el-col >
32
32
<el-col :span =" 4" >
33
33
<el-form-item :label =" $t('business.workload.pull_policy')" prop =" imagePullPolicy" >
34
- <ko-form-item itemType =" select" :noClear =" true" v-model =" form.imagePullPolicy"
35
- :selections =" image_pull_policy_list" />
34
+ <ko-form-item itemType =" select" :noClear =" true" v-model =" form.imagePullPolicy" :selections =" image_pull_policy_list" />
36
35
</el-form-item >
37
36
</el-col >
38
37
</el-row >
46
45
<script >
47
46
import KoFormItem from " @/components/ko-form-item/index"
48
47
import Rule from " @/utils/rules"
49
- import {getRepo , listImages } from " ../../../../kubepi/src/api/imagerepos"
48
+ import { getRepo , listImages } from " ../../../../kubepi/src/api/imagerepos"
50
49
51
50
export default {
52
51
name: " KoContainer" ,
@@ -72,17 +71,17 @@ export default {
72
71
},
73
72
metadata: {
74
73
handler (newObj ) {
75
- if (newObj? .annotations ) {
74
+ if (newObj? .labels ) {
76
75
this .cluster = this .$route .query .cluster
77
76
let itemName = " "
78
- if (this .containerType === " initContainers" ) {
79
- itemName = " kubepi-repo-init-" + this .containerParentObj .name + " / "
77
+ if (this .containerType === " initContainers" ) {
78
+ itemName = " kubepi-repo-init-" + this .containerParentObj .name
80
79
} else {
81
- itemName = " kubepi-repo-" + this .containerParentObj .name + " / "
80
+ itemName = " kubepi-repo-" + this .containerParentObj .name
82
81
}
83
- for (const key in newObj .annotations ) {
84
- if (key . indexOf (itemName) !== - 1 ) {
85
- this .repo .name = key . replace ( itemName, " " )
82
+ for (const key in newObj .labels ) {
83
+ if (key === itemName ) {
84
+ this .repo .name = newObj . labels [ itemName]
86
85
this .changeRepo (this .repo .name )
87
86
break
88
87
}
@@ -93,7 +92,7 @@ export default {
93
92
deep: true ,
94
93
},
95
94
},
96
- data () {
95
+ data () {
97
96
return {
98
97
form: {
99
98
name: " " ,
@@ -104,7 +103,7 @@ export default {
104
103
name: " " ,
105
104
images: [],
106
105
image: " " ,
107
- repo: {}
106
+ repo: {},
108
107
},
109
108
checked: false ,
110
109
rules: {
@@ -118,58 +117,65 @@ export default {
118
117
{ label: " Never" , value: " Never" },
119
118
],
120
119
cluster: " " ,
121
- repos: []
120
+ repos: [],
122
121
}
123
122
},
124
123
methods: {
125
- changeName (val ) {
124
+ changeName (val ) {
126
125
this .$emit (" updateContanerList" , val)
127
126
},
128
- checkIsValid () {
127
+ checkIsValid () {
129
128
let isValid = true
130
129
this .$refs [" form" ].validate ((valid ) => {
131
130
isValid = valid
132
131
})
133
132
return isValid
134
133
},
135
- transformation (parentFrom , metadata ) {
134
+ transformation (parentFrom , metadata ) {
136
135
parentFrom .name = this .form .name || undefined
137
136
parentFrom .image = this .form .image || undefined
138
137
parentFrom .imagePullPolicy = this .form .imagePullPolicy || undefined
139
- if (this .repo .name === " " ) {
140
- return
138
+ if (! metadata .labels ) {
139
+ metadata .labels = {}
140
+ } else {
141
+ for (let key in metadata .labels ) {
142
+ if (key .indexOf (" kubepi-repo-" ) !== - 1 ) {
143
+ delete metadata .labels [key]
144
+ }
145
+ }
141
146
}
142
- if (! metadata .annotations ) {
143
- metadata .annotations = {}
147
+ if (this .repo .name === " " ) {
148
+ delete metadata .labels [" operation" ]
149
+ return
144
150
}
145
151
let secrets = " "
146
152
if (this .containerType === " standardContainers" ) {
147
- secrets = " kubepi-repo-" + parentFrom .name + " / " + this . repo . name
153
+ secrets = " kubepi-repo-" + parentFrom .name
148
154
} else {
149
- secrets = " kubepi-repo-init-" + parentFrom .name + " / " + this . repo . name
155
+ secrets = " kubepi-repo-init-" + parentFrom .name
150
156
}
151
- metadata .annotations [secrets] = this .form . image
152
- metadata .annotations [" operation" ] = this .checked ? " update" : " check"
157
+ metadata .labels [secrets] = this .repo . name
158
+ metadata .labels [" operation" ] = this .checked ? " update" : " check"
153
159
},
154
- changeRepo (repo ) {
160
+ changeRepo (repo ) {
155
161
this .repo .images = []
156
162
if (repo === " " ) {
157
163
this .repo .repo = {}
158
164
this .repo .name = " "
159
165
return
160
166
}
161
- listImages (this .cluster , repo).then (res => {
167
+ listImages (this .cluster , repo).then (( res ) => {
162
168
this .repo .images = res .data
163
169
})
164
- getRepo (repo).then (res => {
170
+ getRepo (repo).then (( res ) => {
165
171
this .repo .repo = res .data
166
172
})
167
173
},
168
- changeImage (image ) {
174
+ changeImage (image ) {
169
175
this .form .image = image
170
- }
176
+ },
171
177
},
172
- mounted () {
178
+ mounted () {
173
179
if (this .containerParentObj ) {
174
180
if (this .containerParentObj .name ) {
175
181
this .form .name = this .containerParentObj .name
@@ -182,8 +188,8 @@ export default {
182
188
}
183
189
}
184
190
},
185
- created () {
191
+ created () {
186
192
this .cluster = this .$route .query .cluster
187
- }
193
+ },
188
194
}
189
195
< / script>
0 commit comments