From 6162e7207001411057d172c52fb9639f0a53a0f7 Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 17:41:31 -0400 Subject: [PATCH 01/10] Update config.go Added NoCache to docker struct --- pkg/skaffold/schema/latest/config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index df7d6522a39..03529ebb938 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -631,6 +631,9 @@ type DockerArtifact struct { // CacheFrom lists the Docker images used as cache sources. // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. CacheFrom []string `yaml:"cacheFrom,omitempty"` + + // pass in --no-cache to docker build to prevent caching + NoCache string `yaml:"noCache,omitempty"` } // BazelArtifact *beta* describes an artifact built with [Bazel](https://bazel.build/). From bece80439d84d536b1e34afd4e4e7205af2bf5be Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 17:45:12 -0400 Subject: [PATCH 02/10] Update image.go Allow passing in of --no-cache flag --- pkg/skaffold/docker/image.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/skaffold/docker/image.go b/pkg/skaffold/docker/image.go index 9be2453e9f9..618e2f0aa8f 100644 --- a/pkg/skaffold/docker/image.go +++ b/pkg/skaffold/docker/image.go @@ -161,6 +161,7 @@ func (l *localDaemon) Build(ctx context.Context, out io.Writer, workspace string Target: a.Target, ForceRemove: l.forceRemove, NetworkMode: a.NetworkMode, + NoCache: a.NoCache, }) if err != nil { return "", errors.Wrap(err, "docker build") @@ -367,6 +368,11 @@ func GetBuildArgs(a *latest.DockerArtifact) ([]string, error) { if a.NetworkMode != "" { args = append(args, "--network", strings.ToLower(a.NetworkMode)) } + + if a.NoCache != "" { + args = append(args, "--no-cache") + } + return args, nil } From ca17237f7d2bb4c8963ead813f9103b7e5c8254a Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 18:06:20 -0400 Subject: [PATCH 03/10] Update image_test.go add no-cache test --- pkg/skaffold/docker/image_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/skaffold/docker/image_test.go b/pkg/skaffold/docker/image_test.go index 35c0d8d773b..5fe9b35cc6c 100644 --- a/pkg/skaffold/docker/image_test.go +++ b/pkg/skaffold/docker/image_test.go @@ -227,6 +227,13 @@ func TestGetBuildArgs(t *testing.T) { }, want: []string{"--network", "bridge"}, }, + { + description: "no-cache", + artifact: &latest.DockerArtifact{ + NoCache: "noCache", + }, + want: []string{"--no-cache"}, + }, { description: "all", artifact: &latest.DockerArtifact{ From b50ca74dbf83a984f9326435c60f981f593fe905 Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 18:10:14 -0400 Subject: [PATCH 04/10] Update config.go Make bool and improve doc string --- pkg/skaffold/schema/latest/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 03529ebb938..756703baab9 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -632,8 +632,8 @@ type DockerArtifact struct { // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. CacheFrom []string `yaml:"cacheFrom,omitempty"` - // pass in --no-cache to docker build to prevent caching - NoCache string `yaml:"noCache,omitempty"` + // NoCache used to pass in --no-cache to docker build to prevent caching + NoCache bool `yaml:"noCache,omitempty"` } // BazelArtifact *beta* describes an artifact built with [Bazel](https://bazel.build/). From 06947a89d90eac57acfa7ad762985d857300f840 Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 18:11:55 -0400 Subject: [PATCH 05/10] Update image.go Change for bool --- pkg/skaffold/docker/image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/skaffold/docker/image.go b/pkg/skaffold/docker/image.go index 618e2f0aa8f..35ae7fabb39 100644 --- a/pkg/skaffold/docker/image.go +++ b/pkg/skaffold/docker/image.go @@ -369,7 +369,7 @@ func GetBuildArgs(a *latest.DockerArtifact) ([]string, error) { args = append(args, "--network", strings.ToLower(a.NetworkMode)) } - if a.NoCache != "" { + if a.NoCache { args = append(args, "--no-cache") } From 185aa551f0bbf46c2717fed86a944502e784ee1a Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 18:58:29 -0400 Subject: [PATCH 06/10] Update image_test.go changed test for no-cache to be bool value --- pkg/skaffold/docker/image_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/skaffold/docker/image_test.go b/pkg/skaffold/docker/image_test.go index 5fe9b35cc6c..5e8e1b2e4fa 100644 --- a/pkg/skaffold/docker/image_test.go +++ b/pkg/skaffold/docker/image_test.go @@ -230,7 +230,7 @@ func TestGetBuildArgs(t *testing.T) { { description: "no-cache", artifact: &latest.DockerArtifact{ - NoCache: "noCache", + NoCache: true, }, want: []string{"--no-cache"}, }, From 86d0b0260a55eefca33032ae4d8aee17d7ec7a4a Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 19:17:54 -0400 Subject: [PATCH 07/10] Update config.go Fixed documentation --- pkg/skaffold/schema/latest/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 756703baab9..17e9d6d5576 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -632,7 +632,7 @@ type DockerArtifact struct { // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. CacheFrom []string `yaml:"cacheFrom,omitempty"` - // NoCache used to pass in --no-cache to docker build to prevent caching + // NoCache used to pass in --no-cache to docker build to prevent caching. NoCache bool `yaml:"noCache,omitempty"` } From 9ca16e4d6463eaa9cfec0292c261bed181a49741 Mon Sep 17 00:00:00 2001 From: robertrbruno Date: Wed, 1 May 2019 20:23:12 -0400 Subject: [PATCH 08/10] ran generate-schemas with correct author again --- docs/content/en/schemas/v1beta10.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/content/en/schemas/v1beta10.json b/docs/content/en/schemas/v1beta10.json index 572139fc19c..f5e006b62cf 100755 --- a/docs/content/en/schemas/v1beta10.json +++ b/docs/content/en/schemas/v1beta10.json @@ -729,6 +729,12 @@ "description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are `Host`: use the host's networking stack. `Bridge`: use the bridged network configuration. `None`: no networking in the container.", "x-intellij-html-description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are Host: use the host's networking stack. Bridge: use the bridged network configuration. None: no networking in the container." }, + "noCache": { + "type": "boolean", + "description": "used to pass in --no-cache to docker build to prevent caching.", + "x-intellij-html-description": "used to pass in --no-cache to docker build to prevent caching.", + "default": "false" + }, "target": { "type": "string", "description": "Dockerfile target name to build.", @@ -740,7 +746,8 @@ "target", "buildArgs", "network", - "cacheFrom" + "cacheFrom", + "noCache" ], "additionalProperties": false, "description": "*beta* describes an artifact built from a Dockerfile, usually using `docker build`.", From 05f5e20cefcb179fde5cc512f10db5f20cb8a74a Mon Sep 17 00:00:00 2001 From: robertrbruno <34684082+robertrbruno@users.noreply.github.com> Date: Wed, 1 May 2019 21:41:13 -0400 Subject: [PATCH 09/10] Update image.go remove extra space --- pkg/skaffold/docker/image.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/skaffold/docker/image.go b/pkg/skaffold/docker/image.go index 35ae7fabb39..81e90e0897f 100644 --- a/pkg/skaffold/docker/image.go +++ b/pkg/skaffold/docker/image.go @@ -373,6 +373,5 @@ func GetBuildArgs(a *latest.DockerArtifact) ([]string, error) { args = append(args, "--no-cache") } - return args, nil } From f3fae404bfe74dba40238287a601b3fb52c034c5 Mon Sep 17 00:00:00 2001 From: robertrbruno Date: Wed, 1 May 2019 22:11:50 -0400 Subject: [PATCH 10/10] fix whitespace issues --- pkg/skaffold/docker/image.go | 4 ++-- pkg/skaffold/schema/latest/config.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/skaffold/docker/image.go b/pkg/skaffold/docker/image.go index 81e90e0897f..13628906964 100644 --- a/pkg/skaffold/docker/image.go +++ b/pkg/skaffold/docker/image.go @@ -368,10 +368,10 @@ func GetBuildArgs(a *latest.DockerArtifact) ([]string, error) { if a.NetworkMode != "" { args = append(args, "--network", strings.ToLower(a.NetworkMode)) } - + if a.NoCache { args = append(args, "--no-cache") } - + return args, nil } diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 17e9d6d5576..ba6d9927a94 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -631,7 +631,7 @@ type DockerArtifact struct { // CacheFrom lists the Docker images used as cache sources. // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. CacheFrom []string `yaml:"cacheFrom,omitempty"` - + // NoCache used to pass in --no-cache to docker build to prevent caching. NoCache bool `yaml:"noCache,omitempty"` }