Skip to content

Commit

Permalink
fix(container): extraFlags weren't used when building in-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Jun 15, 2020
1 parent ebb42e2 commit 1bbaad6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions garden-service/src/plugins/container/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ export async function buildContainerModule({ module, log }: BuildModuleParams<Co

const cmdOpts = ["build", "-t", identifier, ...getDockerBuildFlags(module)]

cmdOpts.push(...(module.spec.extraFlags || []))

if (module.spec.dockerfile) {
cmdOpts.push("--file", containerHelpers.getDockerfileBuildPath(module))
}
Expand Down Expand Up @@ -94,5 +92,7 @@ export function getDockerBuildFlags(module: ContainerModule) {
args.push("--target", module.spec.build.targetImage)
}

args.push(...(module.spec.extraFlags || []))

return args
}
38 changes: 38 additions & 0 deletions garden-service/test/unit/src/plugins/container/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
minDockerVersion,
DEFAULT_BUILD_TIMEOUT,
} from "../../../../../src/plugins/container/helpers"
import { getDockerBuildFlags } from "../../../../../src/plugins/container/build"

describe("plugins.container", () => {
const projectRoot = resolve(dataDir, "test-project-container")
Expand Down Expand Up @@ -988,4 +989,41 @@ describe("plugins.container", () => {
)
})
})

describe("getDockerBuildFlags", () => {
it("should include extraFlags", async () => {
const module = await getTestModule({
allowPublish: false,
build: {
dependencies: [],
},
disabled: false,
apiVersion: "garden.io/v0",
name: "module-a",
outputs: {},
path: modulePath,
type: "container",

spec: {
build: {
dependencies: [],
timeout: DEFAULT_BUILD_TIMEOUT,
},
buildArgs: {},
extraFlags: ["--cache-from", "some-image:latest"],
services: [],
tasks: [],
tests: [],
},

serviceConfigs: [],
taskConfigs: [],
testConfigs: [],
})

const args = getDockerBuildFlags(module)

expect(args).to.eql(["--cache-from", "some-image:latest"])
})
})
})

0 comments on commit 1bbaad6

Please sign in to comment.