Skip to content

Commit 690fe13

Browse files
authored
Use existing env variables when updating container app if "skipped" (#627)
1 parent 3203e8a commit 690fe13

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/commands/image/imageSource/EnvironmentVariablesListStep.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ export class EnvironmentVariablesListStep extends AzureWizardPromptStep<Environm
4444

4545
private async selectEnvironmentSettings(context: EnvironmentVariablesContext): Promise<DotenvParseOutput | undefined> {
4646
const placeHolder: string = localize('setEnvVar', 'Select a {0} file to set the environment variables for the container instance', '.env');
47+
// since we only allow one container, we can assume that we want the first container's env settings
48+
const existingData: DotenvParseOutput | undefined = context.containerApp?.template?.containers?.[0].env as DotenvParseOutput | undefined;
49+
const skipLabel: string | undefined = existingData ? localize('useExisting', 'Use existing configuration') : undefined;
50+
4751
const envFileFsPath: string | undefined = await selectWorkspaceFile(context, placeHolder,
48-
{ filters: { 'env file': ['env', 'env.*'] }, allowSkip: true }, allEnvFilesGlobPattern);
52+
{ filters: { 'env file': ['env', 'env.*'] }, allowSkip: true, skipLabel }, allEnvFilesGlobPattern);
4953

5054
if (!envFileFsPath) {
51-
return undefined;
55+
return existingData;
5256
}
5357

5458
const data = await AzExtFsExtra.readFile(envFileFsPath);

src/utils/workspaceUtils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ interface SelectWorkspaceFileOptions extends OpenDialogOptions {
1616
* Include a 'skipForNow` option in the prompting. Selection of `skipForNow` should correspond to a value of `undefined`
1717
*/
1818
allowSkip?: boolean;
19+
/**
20+
* Optional label for the 'skipForNow' option; will default to 'Skip for now' if not provided
21+
*/
22+
skipLabel?: string;
1923
/**
2024
* If searching through the workspace file path returns only one matching result, automatically return its path without additional prompting
2125
*/
@@ -68,9 +72,10 @@ export async function selectWorkspaceFile(
6872

6973
quickPicks.push(browseItem);
7074

75+
const label = options.skipLabel ?? localize('skipForNow', '$(clock) Skip for now');
7176
if (options.allowSkip) {
7277
quickPicks.push({
73-
label: localize('skipForNow', '$(clock) Skip for now'),
78+
label,
7479
description: '',
7580
data: skipForNow
7681
});

0 commit comments

Comments
 (0)