You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/kubernetes/converters/storageClass.js

34 lines
1.2 KiB

import { KubernetesStorageClass } from 'Kubernetes/models/storage-class/models';
import { KubernetesStorageClassCreatePayload } from 'Kubernetes/models/storage-class/payload';
import * as JsonPatch from 'fast-json-patch';
class KubernetesStorageClassConverter {
/**
* API StorageClass to front StorageClass
*/
static apiToStorageClass(data) {
const res = new KubernetesStorageClass();
res.Name = data.metadata.name;
res.Provisioner = data.provisioner;
res.AllowVolumeExpansion = data.allowVolumeExpansion;
return res;
}
static createPayload(storageClass) {
const res = new KubernetesStorageClassCreatePayload();
res.metadata.name = storageClass.Name;
res.provisioner = storageClass.Provisioner;
res.allowVolumeExpansion = storageClass.AllowVolumeExpansion;
return res;
}
static patchPayload(oldStorageClass, newStorageClass) {
const oldPayload = KubernetesStorageClassConverter.createPayload(oldStorageClass);
const newPayload = KubernetesStorageClassConverter.createPayload(newStorageClass);
const payload = JsonPatch.compare(oldPayload, newPayload);
return payload;
}
}
export default KubernetesStorageClassConverter;