|
| 1 | +import cuid from 'cuid' |
| 2 | +import { TencentKubernetesCluster } from '../../types/generated' |
| 3 | +import { RawTencentKubernetesEngine } from './data' |
| 4 | + |
| 5 | +export default ({ |
| 6 | + service, |
| 7 | + account, |
| 8 | + region, |
| 9 | +}: { |
| 10 | + service: RawTencentKubernetesEngine |
| 11 | + account: string |
| 12 | + region: string |
| 13 | +}): TencentKubernetesCluster => { |
| 14 | + const { |
| 15 | + id, |
| 16 | + ClusterName: name, |
| 17 | + ClusterDescription: clusterDescription, |
| 18 | + ClusterVersion: clusterVersion, |
| 19 | + ClusterOs: clusterOs, |
| 20 | + ClusterType: clusterType, |
| 21 | + ClusterNetworkSettings, |
| 22 | + ClusterNodeNum: clusterNodeNum, |
| 23 | + ProjectId: projectId, |
| 24 | + TagSpecification, |
| 25 | + ClusterStatus: clusterStatus, |
| 26 | + Property: property, |
| 27 | + ClusterMaterNodeNum: clusterMaterNodeNum, |
| 28 | + ImageId: imageId, |
| 29 | + OsCustomizeType: osCustomizeType, |
| 30 | + ContainerRuntime: containerRuntime, |
| 31 | + CreatedTime: createdTime, |
| 32 | + DeletionProtection: deletionProtection, |
| 33 | + EnableExternalNode: enableExternalNode, |
| 34 | + ClusterLevel: clusterLevel, |
| 35 | + AutoUpgradeClusterLevel: autoUpgradeClusterLevel, |
| 36 | + } = service |
| 37 | + |
| 38 | + const Tags = [] |
| 39 | + TagSpecification?.map(spec => { |
| 40 | + Tags.push(spec.Tags) |
| 41 | + }) |
| 42 | + |
| 43 | + return { |
| 44 | + id, |
| 45 | + region, |
| 46 | + name, |
| 47 | + clusterDescription, |
| 48 | + clusterVersion, |
| 49 | + clusterOs, |
| 50 | + clusterType, |
| 51 | + clusterNetworkSettings: { |
| 52 | + clusterCIDR: ClusterNetworkSettings?.ClusterCIDR, |
| 53 | + ignoreClusterCIDRConflict: ClusterNetworkSettings?.IgnoreClusterCIDRConflict, |
| 54 | + maxNodePodNum: ClusterNetworkSettings?.MaxNodePodNum, |
| 55 | + maxClusterServiceNum: ClusterNetworkSettings?.MaxClusterServiceNum, |
| 56 | + ipvs: ClusterNetworkSettings?.Ipvs, |
| 57 | + vpcId: ClusterNetworkSettings?.VpcId, |
| 58 | + cni: ClusterNetworkSettings?.Cni, |
| 59 | + kubeProxyMode: ClusterNetworkSettings?.KubeProxyMode, |
| 60 | + serviceCIDR: ClusterNetworkSettings?.ServiceCIDR, |
| 61 | + subnets: ClusterNetworkSettings?.Subnets, |
| 62 | + }, |
| 63 | + clusterNodeNum, |
| 64 | + projectId, |
| 65 | + tags: Tags.map(tag => ({ |
| 66 | + id: cuid(), |
| 67 | + key: tag.Key, |
| 68 | + value: tag.Value, |
| 69 | + })), |
| 70 | + clusterStatus, |
| 71 | + property, |
| 72 | + clusterMaterNodeNum, |
| 73 | + imageId, |
| 74 | + osCustomizeType, |
| 75 | + containerRuntime, |
| 76 | + createdTime, |
| 77 | + deletionProtection, |
| 78 | + enableExternalNode, |
| 79 | + clusterLevel, |
| 80 | + autoUpgradeClusterLevel, |
| 81 | + } |
| 82 | +} |
0 commit comments