From db85c03d50afcb0077bed1171bb2b2c954e0b58f Mon Sep 17 00:00:00 2001 From: Nancy Butler <42977925+mantis-toboggan-md@users.noreply.github.com> Date: Fri, 23 Apr 2021 10:47:40 -0700 Subject: [PATCH] container update tracking fix http probe headers fix workload selector on edit --- components/form/KeyValue.vue | 4 ++-- components/form/Security.vue | 5 ++++- edit/workload/index.vue | 28 +++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/components/form/KeyValue.vue b/components/form/KeyValue.vue index fe71ec25557..b1c665ecf0d 100644 --- a/components/form/KeyValue.vue +++ b/components/form/KeyValue.vue @@ -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'); }, }, @@ -276,7 +276,7 @@ export default { } return { - [this.keyName]: row.key, + [this.keyName]: row[this.keyName], [this.valueName]: value, }; })); diff --git a/components/form/Security.vue b/components/form/Security.vue index a76f9a871bf..35a3cac9b9f 100644 --- a/components/form/Security.vue +++ b/components/form/Security.vue @@ -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" />
@@ -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" />
@@ -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()}" />
@@ -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" />
diff --git a/edit/workload/index.vue b/edit/workload/index.vue index 93c36962e2f..b0dfddae703 100644 --- a/edit/workload/index.vue +++ b/edit/workload/index.vue @@ -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() { @@ -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 }; } @@ -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 { @@ -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);