mirror of https://github.com/rancher/ui.git
Shared subnets are shown in dropdwon when provisioning GKE clusters
This commit is contained in:
parent
349c37e1ce
commit
5bfd228bda
|
|
@ -686,15 +686,40 @@ export default Component.extend(ClusterDriver, {
|
|||
label: matchedSubnets.length > 0 ? `${ net.name } (subnets available)` : net.name,
|
||||
};
|
||||
});
|
||||
const sharedSubnets = (get(this, 'sharedSubnets') || []).map((ssn) => {
|
||||
return {
|
||||
...ssn,
|
||||
group: 'Shared VPC',
|
||||
shared: true,
|
||||
name: ssn?.network,
|
||||
};
|
||||
})
|
||||
const merged = [...networks, ...sharedSubnets];
|
||||
|
||||
const sharedSubnets = get(this, 'sharedSubnets') || [];
|
||||
|
||||
const dedupeSharedSubnets = () => {
|
||||
// Because the shared network comes in as an array of shared subnetworks,
|
||||
// the network names of the shared networks need to be deduplicated.
|
||||
let alreadyUsedNetworkNames = {};
|
||||
let dedupedSharedSubnets = [];
|
||||
|
||||
for (let i = 0; i < sharedSubnets.length; i++){
|
||||
const ssn = sharedSubnets[i];
|
||||
const networkNamePath = ssn?.network.split('/');
|
||||
const networkLabel = networkNamePath[networkNamePath.length - 1];
|
||||
|
||||
if (alreadyUsedNetworkNames[networkLabel]) {
|
||||
// Avoid adding two entries for the same shared network name
|
||||
continue;
|
||||
}
|
||||
|
||||
alreadyUsedNetworkNames[networkLabel] = ssn;
|
||||
|
||||
dedupedSharedSubnets.push({
|
||||
...ssn,
|
||||
group: 'Shared VPC',
|
||||
shared: true,
|
||||
name: ssn?.network,
|
||||
label: networkLabel
|
||||
});
|
||||
}
|
||||
|
||||
return dedupedSharedSubnets;
|
||||
}
|
||||
const dedupedSharedSubnets = dedupeSharedSubnets(sharedSubnets)
|
||||
const merged = [...networks, ...dedupedSharedSubnets];
|
||||
|
||||
return merged;
|
||||
}),
|
||||
|
|
@ -735,9 +760,11 @@ export default Component.extend(ClusterDriver, {
|
|||
|
||||
mappedSubnets = sharedVpcs.map((sVpc) => {
|
||||
const networkDisplayName = sVpc.network;
|
||||
const subnetworkPath = sVpc.subnetwork.split('/');
|
||||
const subnetworkLabel = subnetworkPath[subnetworkPath.length - 1];
|
||||
|
||||
return {
|
||||
label: `${ sVpc.subnetwork } (${ sVpc.ipCidrRange })`,
|
||||
label: `${ subnetworkLabel } (${ sVpc.ipCidrRange })`,
|
||||
value: sVpc.subnetwork,
|
||||
secondaryIpRanges: sVpc.secondaryIpRanges,
|
||||
networkDisplayName
|
||||
|
|
|
|||
|
|
@ -474,7 +474,6 @@ export default Service.extend({
|
|||
// 'subnetwork': 'projects/vpc-host-309518/regions/us-west1/subnetworks/vpc-host-subnet'
|
||||
// }
|
||||
// ];
|
||||
|
||||
return out;
|
||||
} catch (error) {
|
||||
return reject([error.body.error ?? error.body]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue