Kubernetes Dashboards: Delete resourceVersion (on update and create) and name (on create) (#110318)

delete resourceVersion when creating and updating, and delete name whe creating
This commit is contained in:
Haris Rozajac 2025-08-28 20:52:14 -06:00 committed by GitHub
parent ddf242de86
commit c62ba51d68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -71,18 +71,22 @@ export class K8sDashboardAPI implements DashboardAPI<DashboardDTO, Dashboard> {
};
}
// remove resource version because it's not allowed to be set
// and the api server will throw an error
delete obj.metadata.resourceVersion;
// for v1 in g12, we will ignore the schema version validation from all default clients,
// as we implement the necessary backend conversions, we will drop this query param
if (dashboard.uid) {
obj.metadata.name = dashboard.uid;
// remove resource version when updating
delete obj.metadata.resourceVersion;
return this.client.update(obj, { fieldValidation: 'Ignore' }).then((v) => this.asSaveDashboardResponseDTO(v));
}
obj.metadata.annotations = {
...obj.metadata.annotations,
[AnnoKeyGrantPermissions]: 'default',
};
// non-scene dashboard will have obj.metadata.name when trying to save a dashboard copy
delete obj.metadata.name;
return this.client.create(obj, { fieldValidation: 'Ignore' }).then((v) => this.asSaveDashboardResponseDTO(v));
}