diff --git a/core/src/plugins/kubernetes/container/build/kaniko.ts b/core/src/plugins/kubernetes/container/build/kaniko.ts index aece4a8881..a01b9332c0 100644 --- a/core/src/plugins/kubernetes/container/build/kaniko.ts +++ b/core/src/plugins/kubernetes/container/build/kaniko.ts @@ -211,10 +211,10 @@ export const getKanikoFlags = (flags?: string[], topLevelFlags?: string[]): stri return DEFAULT_KANIKO_FLAGS } const flagToKey = (flag: string) => { - const found = flag.match(/--([a-zA-Z]*)/) + const found = flag.match(/--([a-zA-Z-]*)/) if (found === null) { throw new ConfigurationError({ - message: `Invalid format for a kaniko flag. Expected it to match /--([a-zA-Z]*)/, actually got: ${flag}`, + message: `Invalid format for a kaniko flag. Expected it to match /--([a-zA-Z-]*)/, actually got: ${flag}`, }) } return found[0] diff --git a/core/test/unit/src/plugins/kubernetes/container/build/kaniko.ts b/core/test/unit/src/plugins/kubernetes/container/build/kaniko.ts index b1c95605ae..ef53d1053f 100644 --- a/core/test/unit/src/plugins/kubernetes/container/build/kaniko.ts +++ b/core/test/unit/src/plugins/kubernetes/container/build/kaniko.ts @@ -228,6 +228,10 @@ describe("kaniko build", () => { expect(getKanikoFlags(["--myToggle"])).to.deep.equal(["--myToggle", "--cache=true"]) }) + it("should allow options with dashes", () => { + expect(getKanikoFlags(["--my-toggle", "--my-name=banana"])).to.deep.equal(["--my-toggle", "my-name=banana", "--cache=true"]) + }) + it("should throw if a flag is malformed", () => { expect(() => getKanikoFlags(["--here=first", "-my-flag"])).to.throw(/Invalid format for a kaniko flag/) })