Skip to content

Commit eb5a5d9

Browse files
authored
fix: respect IGNORE_PREDEFINED_VARS in .gitlab-ci-local-env (#1853)
1 parent 1e3df13 commit eb5a5d9

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/argv.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export class Argv {
6262
"variablesFile": ".gitlab-ci-local-variables.yml",
6363
"inputsFile": ".gitlab-ci-local-inputs.yml",
6464
"evaluateRuleChanges": true,
65-
"ignoreSchemaPaths": [],
66-
"ignorePredefinedVars": "",
65+
"ignoreSchemaPaths": [] as string[],
66+
"ignorePredefinedVars": [] as string[],
6767
};
6868

6969
map: Map<string, any> = new Map<string, any>();
@@ -201,7 +201,10 @@ export class Argv {
201201
}
202202

203203
get ignorePredefinedVars (): string[] {
204-
return this.map.get("ignorePredefinedVars") ?? Argv.default.ignorePredefinedVars;
204+
const val = this.map.get("ignorePredefinedVars");
205+
if (Array.isArray(val)) return val;
206+
if (typeof val === "string" && val.length > 0) return val.split(",");
207+
return Argv.default.ignorePredefinedVars;
205208
}
206209

207210
get pullPolicy (): string {

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ process.on("SIGUSR2", async () => {
344344
type: "string",
345345
coerce: (v) => v.split(","),
346346
requiresArg: false,
347-
default: Argv.default.ignorePredefinedVars,
348347
describe: "Comma-seperated list of predefined pipeline variables for which warnings should be suppressed",
349348
})
350349
.option("concurrency", {

tests/argv-input.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,16 @@ test("input namespace collision: same key as global and component name", async (
4646
expect(result._global["deploy"]).toEqual("prod");
4747
expect(result._components["deploy"]).toEqual({replicas: 5});
4848
});
49+
50+
test("ignorePredefinedVars is loaded from .gitlab-ci-local-env", async () => {
51+
const argv = await Argv.build({
52+
cwd: "tests/test-cases/argv-dotenv-ignore-predefined-vars",
53+
home: "tests/test-cases/argv-dotenv-ignore-predefined-vars",
54+
}, writeStreams);
55+
expect(argv.ignorePredefinedVars).toEqual(["CI_PIPELINE_SOURCE", "CI_PROJECT_NAME"]);
56+
});
57+
58+
test("ignorePredefinedVars defaults to empty array", async () => {
59+
const argv = await Argv.build({home: "tests/test-cases/argv-dotenv-ignore-predefined-vars"}, writeStreams);
60+
expect(argv.ignorePredefinedVars).toEqual([]);
61+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IGNORE_PREDEFINED_VARS=CI_PIPELINE_SOURCE,CI_PROJECT_NAME

0 commit comments

Comments
 (0)