Skip to content

Commit

Permalink
Merge pull request #2739 from mantis-toboggan-md/bugfix-sidecar
Browse files Browse the repository at this point in the history
[2.5.8] fix sidecar indexing, container image validation, workload storage pvc namespacing
  • Loading branch information
mantis-toboggan-md authored Apr 21, 2021
2 parents 34c15c0 + a516fb3 commit d8ef0cb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
4 changes: 3 additions & 1 deletion assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,9 @@ workload:
subdomain:
label: Subdomain
placeholder: e.g. web

validation:
containers: Containers
containerImage: Container {name} - "Container Image" is required.
replicas: Replicas
showTabs: 'Show Advanced Options'
scheduling:
Expand Down
11 changes: 0 additions & 11 deletions edit/workload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,6 @@ export default {
if (this.container && !this.container.name) {
this.$set(this.container, 'name', this.value.metadata.name);
}
if (this.container) {
let existing;
if (this.isInitContainer) {
existing = this.podTemplateSpec.initContainers.find(container => container._active);
} else {
existing = this.podTemplateSpec.containers.find(container => container._active);
}
Object.assign(existing, this.container);
}
const ports = this.value.containers.reduce((total, each) => {
const containerPorts = each.ports || [];
Expand Down
13 changes: 8 additions & 5 deletions edit/workload/storage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export default {
},
async fetch() {
const pvcs = await this.$store.dispatch('cluster/findAll', { type: PVC });
const namespace = this.namespace || this.$store.getters['defaultNamespace'];
this.pvcs = pvcs.filter(pvc => pvc.metadata.namespace === namespace);
this.pvcs = await this.$store.dispatch('cluster/findAll', { type: PVC });
},
data() {
Expand All @@ -72,6 +69,12 @@ export default {
return this.mode === _VIEW;
},
namespacedPVCs() {
const namespace = this.namespace || this.$store.getters['defaultNamespace'];
return this.pvcs.filter(pvc => pvc.metadata.namespace === namespace);
},
volumeTypeOpts() {
const hasComponent = require
.context('@/edit/workload/storage', false, /^.*\.vue$/)
Expand Down Expand Up @@ -99,7 +102,7 @@ export default {
},
pvcNames() {
return this.pvcs.map(pvc => pvc.metadata.name);
return this.namespacedPVCs.map(pvc => pvc.metadata.name);
},
// only show volumes mounted in current container
containerVolumes: {
Expand Down
24 changes: 15 additions & 9 deletions utils/validators/container-images.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { get } from '@/utils/object';

export function containerImages(spec, getters, errors) {
let container;
let podSpec;

if (spec.jobTemplate) {
// cronjob pod template is nested slightly different than other types
const { jobTemplate: { spec: { template: { spec: { containers = [] } } } } } = spec;

container = containers[0] || {};
podSpec = get(spec, 'jobTemplate.spec.template.spec');
} else {
const { template:{ spec:{ containers = [] } } } = spec;

container = containers[0] || {};
podSpec = get(spec, 'template.spec');
}

if (!container.image) {
errors.push(getters['i18n/t']('validation.required', { key: getters['i18n/t']('workload.container.image') }));
if (!podSpec.containers || !podSpec.containers.length) {
errors.push(getters['i18n/t']('validation.required', { key: getters['i18n/t']('workload.container.titles.containers') }));

return;
}

podSpec.containers.forEach((container) => {
if (container && !container.image) {
errors.push(getters['i18n/t']('workload.validation.containerImage', { name: container.name }));
}
});
}

0 comments on commit d8ef0cb

Please sign in to comment.