Skip to content

Commit

Permalink
appsettings: Add value validation for containerized function apps (#1701
Browse files Browse the repository at this point in the history
)

* Add value validation

* requested changes

* Add trim

* remove extra line
  • Loading branch information
motm32 authored Mar 13, 2024
1 parent 0b859bd commit 2d59eda
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions appsettings/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion appsettings/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-azureappsettings",
"author": "Microsoft Corporation",
"version": "0.2.0",
"version": "0.2.1",
"description": "Common features and tools surrounding App Settings for the Azure VS Code extensions",
"tags": [
"azure",
Expand Down
12 changes: 11 additions & 1 deletion appsettings/src/tree/AppSettingsTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import type { StringDictionary } from '@azure/arm-appservice';
import { AzExtParentTreeItem, AzExtTreeItem, createContextValue, IActionContext, ICreateChildImplContext, TreeItemIconPath } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { ThemeIcon } from 'vscode';
import { AppSettingsClientProvider, IAppSettingsClient } from '../IAppSettingsClient';
import { AppSettingTreeItem } from './AppSettingTreeItem';
Expand Down Expand Up @@ -35,6 +36,14 @@ export function validateAppSettingKey(settings: StringDictionary, client: IAppSe
return undefined;
}

export function validateAppSettingValue(value: string): string | undefined {
if (!value.trim()) {
return vscode.l10n.t('App setting values cannot be null, undefined or an empty string.');
}

return undefined;
}

interface AppSettingsTreeItemOptions {
supportsSlots?: boolean;
settingsToHide?: string[];
Expand Down Expand Up @@ -131,7 +140,8 @@ export class AppSettingsTreeItem extends AzExtParentTreeItem {

const newValue: string = await context.ui.showInputBox({
prompt: `Enter value for "${newKey}"`,
stepName: 'appSettingValue'
stepName: 'appSettingValue',
validateInput: (v: string): string | undefined => validateAppSettingValue(v)
});

if (!settings.properties) {
Expand Down

0 comments on commit 2d59eda

Please sign in to comment.