diff --git a/pkg/aks/components/CruAks.vue b/pkg/aks/components/CruAks.vue index 36a4be1126f..9db30a7e851 100644 --- a/pkg/aks/components/CruAks.vue +++ b/pkg/aks/components/CruAks.vue @@ -51,7 +51,8 @@ import { ipv4WithCidr, outboundTypeUserDefined, privateDnsZone, - nodePoolNames + nodePoolNames, + nodePoolNamesUnique } from '../util/validators'; export const defaultNodePool = { @@ -242,6 +243,10 @@ export default defineComponent({ path: 'poolName', rules: ['poolNames'] }, + { + path: 'poolNamesUnique', + rules: ['poolNamesUnique'] + }, { path: 'poolAZ', rules: ['availabilityZoneSupport'] @@ -336,6 +341,7 @@ export default defineComponent({ outboundType: outboundTypeUserDefined(this, 'aks.outboundType.label', 'aksConfig.outboundType'), privateDnsZone: privateDnsZone(this, 'aks.privateDnsZone.label', 'aksConfig.privateDnsZone'), poolNames: nodePoolNames(this), + poolNamesUnique: nodePoolNamesUnique(this), vmSizeAvailable: () => { if (this.touchedVmSize) { @@ -1093,7 +1099,7 @@ export default defineComponent({ diff --git a/pkg/aks/l10n/en-us.yaml b/pkg/aks/l10n/en-us.yaml index 2d9bb7345aa..a0168396ae2 100644 --- a/pkg/aks/l10n/en-us.yaml +++ b/pkg/aks/l10n/en-us.yaml @@ -167,4 +167,5 @@ aks: poolMinMax: The minimum number of nodes must be less than or equal to the maximum number of nodes, and the node count must be between or equal to the minimum and maximum. poolMin: The minimum number of nodes must be greater than 0 and at most 100. poolMax: The maximum number of nodes must be greater than 0 and at most 100. - poolTaints: Taints must have both a key and value defined. \ No newline at end of file + poolTaints: Taints must have both a key and value defined. + poolNamesUnique: Node pool names must be unique. \ No newline at end of file diff --git a/pkg/aks/util/validators.ts b/pkg/aks/util/validators.ts index 4dbae476eff..1c5b42df072 100644 --- a/pkg/aks/util/validators.ts +++ b/pkg/aks/util/validators.ts @@ -165,3 +165,15 @@ export const nodePoolNames = (ctx: any) => { } }; }; + +export const nodePoolNamesUnique = (ctx: any) => { + return () :string | undefined => { + const poolNames = (ctx.nodePools || []).map((pool: AKSNodePool) => pool.name); + + const hasDuplicates = poolNames.some((name: string, idx: number) => poolNames.indexOf(name) !== idx); + + if (hasDuplicates) { + return ctx.t('aks.errors.poolNamesUnique'); + } + }; +};