Skip to content

Commit

Permalink
Merge pull request #2817 from mantis-toboggan-md/bugfix-cmd
Browse files Browse the repository at this point in the history
[2.5.8] workload sidecar fixes
  • Loading branch information
vincent99 authored Apr 26, 2021
2 parents 392e901 + db85c03 commit 20c2c65
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/form/KeyValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
keyPlaceholder: {
type: String,
default() {
return this.$store.getters['i18n/t']('keyValue.valuePlaceholder');
return this.$store.getters['i18n/t']('keyValue.keyPlaceholder');
},
},
Expand Down Expand Up @@ -276,7 +276,7 @@ export default {
}
return {
[this.keyName]: row.key,
[this.keyName]: row[this.keyName],
[this.valueName]: value,
};
}));
Expand Down
5 changes: 4 additions & 1 deletion components/form/Security.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default {
:options="[false,true]"
:labels="[t('workload.container.security.privileged.false'), t('workload.container.security.privileged.true')]"
:mode="mode"
@input="update"
/>
</div>
<div v-if="!privileged" class="col span-6">
Expand All @@ -127,6 +128,7 @@ export default {
:options="[false,true]"
:labels="[t('workload.container.security.allowPrivilegeEscalation.false'), t('workload.container.security.allowPrivilegeEscalation.true')]"
:mode="mode"
@input="update"
/>
</div>
</div>
Expand All @@ -143,7 +145,7 @@ export default {
:options="[false, true]"
:labels="[t('workload.container.security.runAsNonRoot.false'), t('workload.container.security.runAsNonRoot.true')]"
:mode="mode"
@input="e=>runAsRoot = !e"
@input="e=>{runAsRoot = !e; update()}"
/>
</div>
<div class="col span-6">
Expand All @@ -154,6 +156,7 @@ export default {
:options="[false, true]"
:labels="[t('workload.container.security.readOnlyRootFilesystem.false'), t('workload.container.security.readOnlyRootFilesystem.true')]"
:mode="mode"
@input="update"
/>
</div>
</div>
Expand Down
28 changes: 25 additions & 3 deletions edit/workload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ export default {
this.$set(this.value, 'type', neu);
delete this.value.apiVersion;
},
container(neu) {
const containers = this.isInitContainer ? this.podTemplateSpec.initContainers : this.podTemplateSpec.containers;
const existing = containers.filter(container => container._active)[0];
Object.assign(existing, neu);
}
},
created() {
Expand Down Expand Up @@ -493,7 +500,7 @@ export default {
},
saveWorkload() {
if (this.type !== WORKLOAD_TYPES.JOB && this.mode === _CREATE) {
if (this.type !== WORKLOAD_TYPES.JOB && this.type !== WORKLOAD_TYPES.CRON_JOB && this.mode === _CREATE) {
this.spec.selector = { matchLabels: this.value.workloadSelector };
}
Expand All @@ -505,7 +512,7 @@ export default {
template = this.spec.template;
}
if (this.type !== WORKLOAD_TYPES.JOB) {
if (this.type !== WORKLOAD_TYPES.JOB && this.type !== WORKLOAD_TYPES.CRON_JOB && this.mode === _CREATE) {
if (!template.metadata) {
template.metadata = { labels: this.value.workloadSelector };
} else {
Expand Down Expand Up @@ -612,13 +619,28 @@ export default {
return;
}
(this.allContainers || []).forEach((container) => {
if (container._active) {
delete container._active;
}
});
container._active = true;
this.container = container;
this.isInitContainer = !!container._init;
},
addContainer() {
const container = { imagePullPolicy: 'Always', name: `container-${ this.allContainers.length }` };
let nameNumber = this.allContainers.length;
const allNames = this.allContainers.reduce((names, each) => {
names.push(each.name);
return names;
}, []);
while (allNames.includes(`container-${ nameNumber }`)) {
nameNumber++;
}
const container = { imagePullPolicy: 'Always', name: `container-${ nameNumber }` };
this.podTemplateSpec.containers.push(container);
this.selectContainer(container);
Expand Down

0 comments on commit 20c2c65

Please sign in to comment.