Skip to content

Commit

Permalink
Merge pull request #770 from codyrancher/constraint-api-groups-2.4
Browse files Browse the repository at this point in the history
[backport] Ensuring apiGroups have an empty value
  • Loading branch information
vincent99 authored Jun 15, 2020
2 parents 9f99cea + d2264dc commit d1200bb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions shared/gatekeeper-constraint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,22 @@ export default {
},
async created() {
this.registerBeforeHook(this.willSave, 'willSave');
if (!this.value.save) {
this.$emit('input', merge(await this.createConstraint(), this.value, this.emptyDefaults));
}
},
methods: {
willSave() {
this.value.spec.match.kinds.forEach((kind) => {
const apiGroups = kind.apiGroups || [];
if (apiGroups.length === 0) {
kind.apiGroups = ['*'];
}
});
},
async createConstraint() {
const constraint = await this.$store.dispatch('cluster/create', { type: this.templateOptions[0].value });
Expand Down

0 comments on commit d1200bb

Please sign in to comment.