Skip to content

Commit

Permalink
fix(trim): Trim whitespace around labels and env-variables
Browse files Browse the repository at this point in the history
  • Loading branch information
vehagn committed Feb 7, 2023
1 parent 2e0d7ca commit e25b198
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Don't add extra trailing slash if already present in `fromRegisty` or `toRegistry`
- Clarify error message with label defined with both `--label` and `--labels`
- Create parent directory for tar-image if not existing
- Trim whitespace around labels and env-variables

## [1.0.3] - 2022-02-06

Expand Down
8 changes: 4 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ function setKeyValue(target: Record<string, string>, keyValue: string) {

const cliLabels = {} as Record<string, string>;
program.on("option:label", (ops: string) => {
setKeyValue(cliLabels, ops);
setKeyValue(cliLabels, ops.trim());
});

const cliEnv = {} as Record<string, string>;
program.on("option:env", (ops: string) => {
setKeyValue(cliEnv, ops);
setKeyValue(cliEnv, ops.trim());
});

const cliOptions = Object.entries(possibleArgs)
Expand Down Expand Up @@ -97,7 +97,7 @@ Object.keys(configFromFile).forEach((k) => {
});

const labelsOpt: Record<string, string> = {};
cliOptions.labels?.split(",")?.forEach((x: string) => setKeyValue(labelsOpt, x));
cliOptions.labels?.split(",")?.forEach((x: string) => setKeyValue(labelsOpt, x.trim()));
Object.keys(labelsOpt)
.filter((l) => Object.keys(cliLabels).includes(l))
.forEach((l) => {
Expand All @@ -107,7 +107,7 @@ Object.keys(labelsOpt)
const labels = { ...configFromFile.labels, ...labelsOpt, ...cliLabels }; //Let cli arguments override file

const envOpt: Record<string, string> = {};
cliOptions.envs?.split(",")?.forEach((x: string) => setKeyValue(envOpt, x));
cliOptions.envs?.split(",")?.forEach((x: string) => setKeyValue(envOpt, x.trim()));
Object.keys(envOpt)
.filter((l) => Object.keys(cliEnv).includes(l))
.forEach((l) => {
Expand Down

0 comments on commit e25b198

Please sign in to comment.