Skip to content

Commit d8b4888

Browse files
authored
Update scaling range validation to match the portal (#734)
1 parent 218414e commit d8b4888

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/commands/scaling/scaleRange/ScaleRangePromptStep.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils';
77
import { localize } from '../../../utils/localize';
88
import { type ScaleRangeContext } from './ScaleRangeContext';
99

10+
const maxReplicas: number = 1000;
11+
1012
export class ScaleRangePromptStep extends AzureWizardPromptStep<ScaleRangeContext> {
1113
public async prompt(context: ScaleRangeContext): Promise<void> {
1214
const scaleRange: string = (await context.ui.showInputBox({
13-
prompt: localize('editScalingRange', 'Set the range of application replicas that get created in response to a scale rule. Set any range within the minimum of 0 and the maximum of 10 replicas'),
15+
prompt: localize('editScalingRange', 'Set the range of application replicas that get created in response to a scale rule. Set any range within the minimum of 0 and the maximum of {0} replicas', maxReplicas),
1416
value: `${context.scaleMinRange}-${context.scaleMaxRange}`,
1517
validateInput: this.validateInput,
1618
})).trim();
@@ -25,14 +27,14 @@ export class ScaleRangePromptStep extends AzureWizardPromptStep<ScaleRangeContex
2527
}
2628

2729
private validateInput(range: string | undefined): string | undefined {
28-
const formatRegex = /^\d{1,2}-\d{1,2}$/;
30+
const formatRegex = /^\d{1,3}-\d{1,4}$/;
2931
if (!range || !formatRegex.test(range)) {
30-
return localize('enterRange', 'Please enter the range in the following format "0-10"');
32+
return localize('enterRange', 'Please enter the range in the following format "0-{0}"', maxReplicas);
3133
}
3234

3335
const [min, max] = range.split('-').map(range => Number(range));
34-
if (min > 10 || max > 10) {
35-
return localize('maxRangeExceeded', 'The maximum number of replicas is 10.');
36+
if (min > maxReplicas || max > maxReplicas) {
37+
return localize('maxRangeExceeded', 'The maximum number of replicas is {0}.', maxReplicas);
3638
} else if (min > max) {
3739
return localize('minHigherThanMax', 'The minimum range cannot be larger than the maximum range.');
3840
} else if (max === 0) {

0 commit comments

Comments
 (0)