Implement KubeApi.patch (#4325)

* implement KubeApi.patch

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* cleanup tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* keep it backward compatible

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2021-11-12 11:15:33 +02:00
1 parent a86b306a48
commit 23d5d40d62
4 files changed
+125 -9

No files matched your search

+18 -4
View File
@@ -295,16 +295,30 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
}
async patch(item: T, patch: Patch): Promise<T> {
return this.postUpdate(await item.patch(patch));
return this.postUpdate(
await this.api.patch(
{
name: item.getName(), namespace: item.getNs(),
},
patch,
"json",
),
);
}
async update(item: T, data: Partial<T>): Promise<T> {
return this.postUpdate(await item.update(data));
return this.postUpdate(
await this.api.update(
{
name: item.getName(), namespace: item.getNs(),
},
data,
),
);
}
async remove(item: T) {
await item.delete();
this.items.remove(item);
await this.api.delete({ name: item.getName(), namespace: item.getNs() });
this.selectedItemsIds.delete(item.getId());
}