diff --git a/cmd/executor/cmd/args.go b/cmd/executor/cmd/args.go new file mode 100644 index 000000000..fdf6eb0c9 --- /dev/null +++ b/cmd/executor/cmd/args.go @@ -0,0 +1,43 @@ +/* +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cmd + +import ( + "github.com/sirupsen/logrus" + "strings" +) + +// The buildArg type is used to pass in multiple --build-arg flags +type buildArg []string + +// Now, for our new type, implement the two methods of +// the flag.Value interface... +// The first method is String() string +func (b *buildArg) String() string { + return strings.Join(*b, ",") +} + +// The second method is Set(value string) error +func (b *buildArg) Set(value string) error { + logrus.Infof("appending to build args %s", value) + *b = append(*b, value) + return nil +} + +func (b *buildArg) Type() string { + return "build-arg type" +} diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index faeafba0a..673dd3dd9 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -23,7 +23,6 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/executor" "github.com/genuinetools/amicontained/container" - "strings" "github.com/GoogleContainerTools/kaniko/pkg/constants" "github.com/GoogleContainerTools/kaniko/pkg/util" @@ -86,26 +85,6 @@ var RootCmd = &cobra.Command{ }, } -type buildArg []string - -// Now, for our new type, implement the two methods of -// the flag.Value interface... -// The first method is String() string -func (b *buildArg) String() string { - return strings.Join(*b, ",") -} - -// The second method is Set(value string) error -func (b *buildArg) Set(value string) error { - logrus.Infof("appending to build args %s", value) - *b = append(*b, value) - return nil -} - -func (b *buildArg) Type() string { - return "Build ARG Type" -} - func checkContained() bool { _, err := container.DetectRuntime() return err == nil diff --git a/pkg/commands/add.go b/pkg/commands/add.go index b407ef871..4fd998719 100644 --- a/pkg/commands/add.go +++ b/pkg/commands/add.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "path/filepath" "strings" diff --git a/pkg/commands/arg.go b/pkg/commands/arg.go index c8fd2abc5..cf4dcd525 100644 --- a/pkg/commands/arg.go +++ b/pkg/commands/arg.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/sirupsen/logrus" diff --git a/pkg/commands/cmd.go b/pkg/commands/cmd.go index 7e20eff70..9d3338534 100644 --- a/pkg/commands/cmd.go +++ b/pkg/commands/cmd.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "strings" "github.com/docker/docker/builder/dockerfile/instructions" diff --git a/pkg/commands/commands.go b/pkg/commands/commands.go index 99e0e1814..e9084715e 100644 --- a/pkg/commands/commands.go +++ b/pkg/commands/commands.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/pkg/errors" diff --git a/pkg/commands/copy.go b/pkg/commands/copy.go index 499fdae99..2fb89ad5a 100644 --- a/pkg/commands/copy.go +++ b/pkg/commands/copy.go @@ -22,8 +22,8 @@ import ( "path/filepath" "strings" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/sirupsen/logrus" diff --git a/pkg/commands/entrypoint.go b/pkg/commands/entrypoint.go index 36a405021..f4c417ca8 100644 --- a/pkg/commands/entrypoint.go +++ b/pkg/commands/entrypoint.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "strings" "github.com/docker/docker/builder/dockerfile/instructions" diff --git a/pkg/commands/env.go b/pkg/commands/env.go index a2d4f93d2..fabd97f12 100644 --- a/pkg/commands/env.go +++ b/pkg/commands/env.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "strings" "github.com/GoogleContainerTools/kaniko/pkg/util" diff --git a/pkg/commands/env_test.go b/pkg/commands/env_test.go index 79e095cb5..d4eec7502 100644 --- a/pkg/commands/env_test.go +++ b/pkg/commands/env_test.go @@ -18,7 +18,6 @@ package commands import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/testutil" - docker "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "testing" @@ -98,7 +97,7 @@ func Test_EnvExecute(t *testing.T) { testutil.CheckErrorAndDeepEqual(t, false, err, expectedEnvs, cfg.Env) } -func setUpBuildArgs() *docker.BuildArgs { +func setUpBuildArgs() *dockerfile.BuildArgs { buildArgs := dockerfile.NewBuildArgs([]string{ "buildArg1=foo", "buildArg2=foo2", diff --git a/pkg/commands/expose.go b/pkg/commands/expose.go index dc9ba6d7d..0c3bbfe1f 100644 --- a/pkg/commands/expose.go +++ b/pkg/commands/expose.go @@ -18,7 +18,7 @@ package commands import ( "fmt" - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "strings" "github.com/GoogleContainerTools/kaniko/pkg/util" diff --git a/pkg/commands/label.go b/pkg/commands/label.go index e5fbbe892..1ce313fa4 100644 --- a/pkg/commands/label.go +++ b/pkg/commands/label.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "strings" "github.com/GoogleContainerTools/kaniko/pkg/util" diff --git a/pkg/commands/onbuild.go b/pkg/commands/onbuild.go index 53dce72ca..1e5dc48a4 100644 --- a/pkg/commands/onbuild.go +++ b/pkg/commands/onbuild.go @@ -17,8 +17,8 @@ limitations under the License. package commands import ( + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/sirupsen/logrus" diff --git a/pkg/commands/run.go b/pkg/commands/run.go index de55ed15d..bd8708e8d 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -17,8 +17,8 @@ limitations under the License. package commands import ( + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/sirupsen/logrus" diff --git a/pkg/commands/shell.go b/pkg/commands/shell.go index 48e941aae..93c37716e 100644 --- a/pkg/commands/shell.go +++ b/pkg/commands/shell.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/sirupsen/logrus" diff --git a/pkg/commands/stopsignal.go b/pkg/commands/stopsignal.go index fd1988a3f..e8d15a4e3 100644 --- a/pkg/commands/stopsignal.go +++ b/pkg/commands/stopsignal.go @@ -17,8 +17,8 @@ limitations under the License. package commands import ( + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/pkg/signal" "github.com/google/go-containerregistry/v1" diff --git a/pkg/commands/user.go b/pkg/commands/user.go index 76fecbb44..46b36c2be 100644 --- a/pkg/commands/user.go +++ b/pkg/commands/user.go @@ -17,8 +17,8 @@ limitations under the License. package commands import ( + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/docker/docker/builder/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/google/go-containerregistry/v1" "github.com/sirupsen/logrus" diff --git a/pkg/commands/volume.go b/pkg/commands/volume.go index ac1323d01..8ca380403 100644 --- a/pkg/commands/volume.go +++ b/pkg/commands/volume.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "os" "strings" diff --git a/pkg/commands/workdir.go b/pkg/commands/workdir.go index 3014eaac9..2179595b3 100644 --- a/pkg/commands/workdir.go +++ b/pkg/commands/workdir.go @@ -17,7 +17,7 @@ limitations under the License. package commands import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "os" "path/filepath" diff --git a/pkg/dockerfile/buildargs.go b/pkg/dockerfile/buildargs.go index 923d59e67..348b71b70 100644 --- a/pkg/dockerfile/buildargs.go +++ b/pkg/dockerfile/buildargs.go @@ -21,7 +21,11 @@ import ( "strings" ) -func NewBuildArgs(args []string) *d.BuildArgs { +type BuildArgs struct { + d.BuildArgs +} + +func NewBuildArgs(args []string) *BuildArgs { argsFromOptions := make(map[string]*string) for _, a := range args { s := strings.Split(a, "=") @@ -31,5 +35,7 @@ func NewBuildArgs(args []string) *d.BuildArgs { argsFromOptions[s[0]] = &s[1] } } - return d.NewBuildArgs(argsFromOptions) + return &BuildArgs{ + *d.NewBuildArgs(argsFromOptions), + } } diff --git a/pkg/util/command_util.go b/pkg/util/command_util.go index d58d8c7a4..bc6bc2caa 100644 --- a/pkg/util/command_util.go +++ b/pkg/util/command_util.go @@ -17,7 +17,7 @@ limitations under the License. package util import ( - "github.com/docker/docker/builder/dockerfile" + "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/builder/dockerfile/parser" "github.com/docker/docker/builder/dockerfile/shell"