mirror of https://github.com/portainer/portainer
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
import { KubernetesNamespace } from 'Kubernetes/models/namespace/models';
|
|
import { KubernetesNamespaceCreatePayload } from 'Kubernetes/models/namespace/payloads';
|
|
import { KubernetesPortainerResourcePoolNameLabel, KubernetesPortainerResourcePoolOwnerLabel } from 'Kubernetes/models/resource-pool/models';
|
|
|
|
class KubernetesNamespaceConverter {
|
|
static apiToNamespace(data, yaml) {
|
|
const res = new KubernetesNamespace();
|
|
res.Id = data.metadata.uid;
|
|
res.Name = data.metadata.name;
|
|
res.CreationDate = data.metadata.creationTimestamp;
|
|
res.Status = data.status.phase;
|
|
res.Yaml = yaml ? yaml.data : '';
|
|
res.ResourcePoolName = data.metadata.labels ? data.metadata.labels[KubernetesPortainerResourcePoolNameLabel] : '';
|
|
res.ResourcePoolOwner = data.metadata.labels ? data.metadata.labels[KubernetesPortainerResourcePoolOwnerLabel] : '';
|
|
return res;
|
|
}
|
|
|
|
static createPayload(namespace) {
|
|
const res = new KubernetesNamespaceCreatePayload();
|
|
res.metadata.name = namespace.Name;
|
|
res.metadata.labels[KubernetesPortainerResourcePoolNameLabel] = namespace.ResourcePoolName;
|
|
if (namespace.ResourcePoolOwner) {
|
|
res.metadata.labels[KubernetesPortainerResourcePoolOwnerLabel] = namespace.ResourcePoolOwner;
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
|
|
export default KubernetesNamespaceConverter;
|