From 4194aaff7de749b37d7f80eb088160e690c0664e Mon Sep 17 00:00:00 2001 From: Yvonne Radsmikham Date: Wed, 15 Apr 2020 15:59:14 -0700 Subject: [PATCH] add variable format warning --- src/commands/service/create.ts | 10 ++++++++++ src/lib/fileutils.ts | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/commands/service/create.ts b/src/commands/service/create.ts index 11411ae9..8071bf25 100644 --- a/src/commands/service/create.ts +++ b/src/commands/service/create.ts @@ -56,6 +56,10 @@ export interface CommandValues extends CommandOptions { serviceVariablesArray: string[]; } +export const validUpperUnderscoreCase = (segment: string): boolean => { + return !!segment.match(/^[A-Z0-9_]+$/); +}; + export const fetchValues = (opts: CommandOptions): CommandValues => { if (!isPortNumberString(opts.k8sBackendPort)) { throw Error("value for --k8s-service-port is not a valid port number"); @@ -82,6 +86,12 @@ export const fetchValues = (opts: CommandOptions): CommandValues => { .map((str) => str.trim()); } + serviceVariablesArray.forEach(function (r) { + if (!validUpperUnderscoreCase(r)) { + logger.warn(`${r} is not in a valid format. Valid strings include only uppercases, numbers, and underscores.`); + } + }); + const values: CommandValues = { gitPush: opts.gitPush, helmChartChart: opts.helmChartChart, diff --git a/src/lib/fileutils.ts b/src/lib/fileutils.ts index 59e7fc24..358a7e9c 100644 --- a/src/lib/fileutils.ts +++ b/src/lib/fileutils.ts @@ -146,8 +146,6 @@ export const serviceBuildAndUpdatePipeline = ( const relativeServiceForDockerfile = relServicePath.startsWith("./") ? relServicePath : "./" + relServicePath; - // const test = (serviceBuildVariables ?? []).map((group) => ({ group })); - // logger.info(`${test}`); const pipelineYaml: AzurePipelinesYaml = { trigger: {