From ae0f3f30f938b7b19a87f968e5a57c6177fb2c87 Mon Sep 17 00:00:00 2001 From: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:44:02 -0500 Subject: [PATCH] new: Represent region-specific pricing when configuring LKE Node Pools (#5065) * Add support for region-specific pricing * fix grammar --- .../driver-linodelke/component.js | 37 ++++++++++++++++++- .../driver-linodelke/template.hbs | 15 ++++++-- translations/en-us.yaml | 5 ++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js b/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js index 7e066903a5..34918fe721 100644 --- a/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js @@ -112,7 +112,17 @@ export default Component.extend(ClusterDriver, { errors: [], step: 2, regions: responses.regions.data.filter((region) => (region.status === 'ok' && region.capabilities.includes('Kubernetes'))), - nodeTypes: responses.nodeTypes.data.filter((type) => (['standard', 'highmem', 'dedicated'].includes(type.class))), + nodeTypes: responses.nodeTypes.data.filter( + (type) => (['standard', 'highmem', 'dedicated'].includes(type.class)) + ).map((type) => { + // We need to set default values for effective prices + return { + ...type, + isException: false, + effectiveHourly: type.price.hourly, + effectiveMonthly: type.price.monthly + } + }), k8sVersions: responses.k8sVersions.data, }); @@ -239,8 +249,9 @@ export default Component.extend(ClusterDriver, { const selectedNodePoolList = get(this, 'selectedNodePoolList'); const nodePools = selectedNodePoolList.map((np) => { return `${ np.id }=${ np.count }` - }) + }); + set(this, 'configHasRegionException', selectedNodePoolList.filter((type) => type.isException).length > 0) set(this, 'cluster.lkeEngineConfig.nodePools', nodePools); }), @@ -249,6 +260,28 @@ export default Component.extend(ClusterDriver, { this.prefillSelectedNodePoolList(); }), + updateEffectiveTypePrices: observer('cluster.lkeEngineConfig.region', function() { + // We need special handling for regional price exceptions + const nodeTypes = this.nodeTypes.map((type) => { + let override = undefined; + + if (type['region_prices'] !== undefined) { + override = type.region_prices.find((override) => override.id === this.cluster.lkeEngineConfig.region); + } + + const isException = override !== undefined; + + return { + ...type, + isException, + effectiveHourly: isException ? override.hourly : type.price.hourly, + effectiveMonthly: isException ? override.monthly : type.price.monthly + } + }); + + set(this, 'nodeTypes', nodeTypes); + }), + // Any computed properties or custom logic can go here // for region choises diff --git a/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs b/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs index 6ed2f38ada..2b9743a96e 100644 --- a/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs @@ -191,13 +191,13 @@