mirror of https://github.com/grafana/grafana.git
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:
parent
ddf242de86
commit
c62ba51d68
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue