From 2a740686cbc1c2d792aa21f7af0b259fd3685f8b Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Mon, 5 Aug 2019 22:34:35 +0200 Subject: [PATCH] feat(container): add extraFlags option for docker builder * feat(core): add docker command flags allow the user to add in more flags to docker build such as ssh. * feat(core): change to extraflags based on pr feedback update commandargs to extraflags * fix: build error after merge from master (TBS) --- docs/reference/module-types/container.md | 9 +++++++++ docs/reference/module-types/maven-container.md | 9 +++++++++ garden-service/src/plugins/container/build.ts | 2 ++ garden-service/src/plugins/container/config.ts | 7 +++++++ .../src/plugins/local/local-google-cloud-functions.ts | 1 + garden-service/src/plugins/openfaas/config.ts | 1 + .../test/unit/src/plugins/container/container.ts | 6 ++++++ .../test/unit/src/plugins/container/helpers.ts | 2 ++ 8 files changed, 37 insertions(+) diff --git a/docs/reference/module-types/container.md b/docs/reference/module-types/container.md index 2310508bd1..278398f0e9 100644 --- a/docs/reference/module-types/container.md +++ b/docs/reference/module-types/container.md @@ -222,6 +222,14 @@ Specify build arguments to use when building the container image. | -------- | -------- | ------- | | `object` | No | `{}` | +### `extraFlags` + +Specify extra flags to use when building the container image. Note that arguments may not be portable across implementations. + +| Type | Required | +| --------------- | -------- | +| `array[string]` | No | + ### `image` Specify the image name for the container. Should be a valid Docker image identifier. If specified and the module does not contain a Dockerfile, this image will be used to deploy services for this module. If specified and the module does contain a Dockerfile, this identifier is used when pushing the built image. @@ -962,6 +970,7 @@ build: target: targetImage: buildArgs: {} +extraFlags: image: hotReload: sync: diff --git a/docs/reference/module-types/maven-container.md b/docs/reference/module-types/maven-container.md index 96eaeae437..4e3c3c67b1 100644 --- a/docs/reference/module-types/maven-container.md +++ b/docs/reference/module-types/maven-container.md @@ -227,6 +227,14 @@ Specify build arguments to use when building the container image. | -------- | -------- | ------- | | `object` | No | `{}` | +### `extraFlags` + +Specify extra flags to use when building the container image. Note that arguments may not be portable across implementations. + +| Type | Required | +| --------------- | -------- | +| `array[string]` | No | + ### `image` Specify the image name for the container. Should be a valid Docker image identifier. If specified and the module does not contain a Dockerfile, this image will be used to deploy services for this module. If specified and the module does contain a Dockerfile, this identifier is used when pushing the built image. @@ -997,6 +1005,7 @@ build: target: targetImage: buildArgs: {} +extraFlags: image: hotReload: sync: diff --git a/garden-service/src/plugins/container/build.ts b/garden-service/src/plugins/container/build.ts index 71fa9d137d..a75cffa765 100644 --- a/garden-service/src/plugins/container/build.ts +++ b/garden-service/src/plugins/container/build.ts @@ -55,6 +55,8 @@ export async function buildContainerModule({ module, log }: BuildModuleParams ({}), "{}") .description("Specify build arguments to use when building the container image."), + extraFlags: joi.array() + .items(joi.string()) + .description(deline` + Specify extra flags to use when building the container image. + Note that arguments may not be portable across implementations.`, + ), // TODO: validate the image name format image: joi.string() .description(deline` diff --git a/garden-service/src/plugins/local/local-google-cloud-functions.ts b/garden-service/src/plugins/local/local-google-cloud-functions.ts index ebcf728bea..83836b3889 100644 --- a/garden-service/src/plugins/local/local-google-cloud-functions.ts +++ b/garden-service/src/plugins/local/local-google-cloud-functions.ts @@ -41,6 +41,7 @@ export const gardenPlugin = (): GardenPlugin => ({ dependencies: [], }, buildArgs: {}, + extraFlags: [], services: [], tasks: [], tests: [], diff --git a/garden-service/src/plugins/openfaas/config.ts b/garden-service/src/plugins/openfaas/config.ts index 341ae25813..ca920504f2 100644 --- a/garden-service/src/plugins/openfaas/config.ts +++ b/garden-service/src/plugins/openfaas/config.ts @@ -112,6 +112,7 @@ export function getContainerModule(module: OpenFaasModule): ContainerModule { ...module.spec, buildArgs: {}, dockerfile: "Dockerfile", + extraFlags: [], services: [], tasks: [], tests: [], diff --git a/garden-service/test/unit/src/plugins/container/container.ts b/garden-service/test/unit/src/plugins/container/container.ts index 2dcb1fe72c..b54c6930f7 100644 --- a/garden-service/test/unit/src/plugins/container/container.ts +++ b/garden-service/test/unit/src/plugins/container/container.ts @@ -46,6 +46,7 @@ describe("plugins.container", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [], tasks: [], tests: [], @@ -96,6 +97,7 @@ describe("plugins.container", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [{ name: "service-a", annotations: {}, @@ -173,6 +175,7 @@ describe("plugins.container", () => { { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [{ name: "service-a", @@ -302,6 +305,7 @@ describe("plugins.container", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [{ name: "service-a", annotations: {}, @@ -363,6 +367,7 @@ describe("plugins.container", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [{ name: "service-a", annotations: {}, @@ -418,6 +423,7 @@ describe("plugins.container", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [{ name: "service-a", annotations: {}, diff --git a/garden-service/test/unit/src/plugins/container/helpers.ts b/garden-service/test/unit/src/plugins/container/helpers.ts index 51736fed07..9c0b4a08a0 100644 --- a/garden-service/test/unit/src/plugins/container/helpers.ts +++ b/garden-service/test/unit/src/plugins/container/helpers.ts @@ -42,6 +42,7 @@ describe("containerHelpers", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], services: [], tasks: [], tests: [], @@ -233,6 +234,7 @@ describe("containerHelpers", () => { spec: { build: { dependencies: [] }, buildArgs: {}, + extraFlags: [], image: "some/image", services: [], tasks: [],