mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
fix(kubernetes/pods): save note (#4675)
* feat(kubernetes/pods): introduce patch api * feat(k8s/pods): pod converter * feat(kubernetes/pods): introduce patch api * feat(k8s/pod): add annotations only if needed * fix(k8s/pod): replace class with factory function
This commit is contained in:
parent
2b257d2785
commit
46ff8a01bc
4 changed files with 132 additions and 1 deletions
|
@ -2,6 +2,7 @@ import angular from 'angular';
|
|||
import PortainerError from 'Portainer/error';
|
||||
|
||||
import { KubernetesCommonParams } from 'Kubernetes/models/common/params';
|
||||
import KubernetesPodConverter from './converter';
|
||||
|
||||
class KubernetesPodService {
|
||||
/* @ngInject */
|
||||
|
@ -13,6 +14,7 @@ class KubernetesPodService {
|
|||
this.getAllAsync = this.getAllAsync.bind(this);
|
||||
this.logsAsync = this.logsAsync.bind(this);
|
||||
this.deleteAsync = this.deleteAsync.bind(this);
|
||||
this.patchAsync = this.patchAsync.bind(this);
|
||||
}
|
||||
|
||||
async getAsync(namespace, name) {
|
||||
|
@ -74,6 +76,29 @@ class KubernetesPodService {
|
|||
return this.$async(this.logsAsync, namespace, podName, containerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* PATCH
|
||||
*/
|
||||
async patchAsync(oldPod, newPod) {
|
||||
try {
|
||||
const params = new KubernetesCommonParams();
|
||||
params.id = newPod.Name;
|
||||
const namespace = newPod.Namespace;
|
||||
const payload = KubernetesPodConverter.patchPayload(oldPod, newPod);
|
||||
if (!payload.length) {
|
||||
return;
|
||||
}
|
||||
const data = await this.KubernetesPods(namespace).patch(params, payload).$promise;
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to patch pod', err);
|
||||
}
|
||||
}
|
||||
|
||||
patch(oldPod, newPod) {
|
||||
return this.$async(this.patchAsync, oldPod, newPod);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue