fix(constraints.gatekeeper.sh.constraint): fix resourceVersion not updated issue (#8285)

This commit is contained in:
LiuYan 2023-02-28 18:50:41 +08:00 committed by GitHub
parent 248e6d9c94
commit 22d15cfae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -9,15 +9,20 @@ export const ENFORCEMENT_ACTION_VALUES = {
export default class GateKeeperConstraint extends SteveModel {
async save() {
let constraint;
let resourceVersion;
if (this.constraint) {
constraint = await this.findLatestConstraint();
resourceVersion = constraint?.metadata?.resourceVersion;
} else {
constraint = await this.$dispatch('cluster/create', { type: `constraints.gatekeeper.sh.${ this.kind.toLowerCase() }` }, { root: true });
}
constraint.spec = this.spec;
constraint.metadata = this.metadata;
if (resourceVersion) {
constraint.metadata.resourceVersion = resourceVersion;
}
await constraint.save();
}