1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00
portainer/app/kubernetes/endpoint/converter.js
Maxime Bajeux 94676df329
feat(k8s/cluster): Show the cluster leader (#4027)
* feat(cluster): Show the cluster leader

* feat(cluster): Restrict leader label only to admin users

* feat(kubernetes): minor UI update

* feat(endpoint):  move all KubernetesEndpoint related code to a single endpoint sub-folder and change few things

* fix(k8s/cluster): fix conflict leftover

* feat(k8s/cluster): review component leader UX

* refactor(k8s/node): remove useless call to endpoints

* refactor(k8s/endpoint): relocate variable declaration

Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
2020-07-20 10:49:49 +12:00

20 lines
729 B
JavaScript

import { KubernetesEndpoint, KubernetesEndpointAnnotationLeader } from 'Kubernetes/endpoint/models';
import _ from 'lodash-es';
class KubernetesEndpointConverter {
static apiToEndpoint(data) {
const res = new KubernetesEndpoint();
res.Id = data.metadata.uid;
res.Name = data.metadata.name;
res.Namespace = data.metadata.namespace;
const leaderAnnotation = data.metadata.annotations ? data.metadata.annotations[KubernetesEndpointAnnotationLeader] : '';
if (leaderAnnotation) {
const parsedJson = JSON.parse(leaderAnnotation);
const split = _.split(parsedJson.holderIdentity, '_');
res.HolderIdentity = split[0];
}
return res;
}
}
export default KubernetesEndpointConverter;