diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index 72dee4d..01aa3d4 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -22,6 +22,7 @@ import ( kaniko "github.com/drone/drone-kaniko" "github.com/drone/drone-kaniko/pkg/artifact" "github.com/drone/drone-kaniko/pkg/docker" + "github.com/drone/drone-kaniko/pkg/utils" ) const ( @@ -98,6 +99,17 @@ func main() { Usage: "build args", EnvVar: "PLUGIN_BUILD_ARGS", }, + cli.GenericFlag{ + Name: "args-new", + Usage: "build args new", + EnvVar: "PLUGIN_BUILD_ARGS_NEW", + Value: new(utils.CustomStringSliceFlag), + }, + cli.BoolFlag{ + Name: "plugin-multiple-build-agrs", + Usage: "plugin multiple build agrs", + EnvVar: "PLUGIN_MULTIPLE_BUILD_ARGS", + }, cli.StringFlag{ Name: "target", Usage: "build target", @@ -432,6 +444,8 @@ func run(c *cli.Context) error { AutoTagSuffix: c.String("auto-tag-suffix"), ExpandTag: c.Bool("expand-tag"), Args: c.StringSlice("args"), + ArgsNew: c.Generic("args-new").(*utils.CustomStringSliceFlag).GetValue(), + IsMultipleBuildArgs: c.Bool("plugin-multiple-build-agrs"), Target: c.String("target"), Repo: c.String("repo"), Mirrors: c.StringSlice("registry-mirrors"), diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index 9b966fb..190c596 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -13,6 +13,7 @@ import ( kaniko "github.com/drone/drone-kaniko" "github.com/drone/drone-kaniko/pkg/artifact" "github.com/drone/drone-kaniko/pkg/docker" + "github.com/drone/drone-kaniko/pkg/utils" ) const ( @@ -102,6 +103,17 @@ func main() { Usage: "build args", EnvVar: "PLUGIN_BUILD_ARGS", }, + cli.GenericFlag{ + Name: "args-new", + Usage: "build args new", + EnvVar: "PLUGIN_BUILD_ARGS_NEW", + Value: new(utils.CustomStringSliceFlag), + }, + cli.BoolFlag{ + Name: "plugin-multiple-build-agrs", + Usage: "plugin multiple build agrs", + EnvVar: "PLUGIN_MULTIPLE_BUILD_ARGS", + }, cli.StringFlag{ Name: "target", Usage: "build target", @@ -239,6 +251,7 @@ func main() { Usage: "Enable or disable compressed caching.", EnvVar: "PLUGIN_COMPRESSED_CACHING", }, + cli.StringFlag{ Name: "context-sub-path", Usage: "Sub-path within the context to build.", @@ -349,6 +362,11 @@ func main() { Usage: "Ignore the /var/run directory during build.", EnvVar: "PLUGIN_IGNORE_VAR_RUN", }, + cli.StringSliceFlag{ + Name: "args", + Usage: "build args", + EnvVar: "PLUGIN_BUILD_ARGS", + }, cli.StringFlag{ Name: "ignore-path", Usage: "Path to ignore during the build.", @@ -421,6 +439,8 @@ func run(c *cli.Context) error { AutoTagSuffix: c.String("auto-tag-suffix"), ExpandTag: c.Bool("expand-tag"), Args: c.StringSlice("args"), + ArgsNew: c.Generic("args-new").(*utils.CustomStringSliceFlag).GetValue(), + IsMultipleBuildArgs: c.Bool("plugin-multiple-build-agrs"), Target: c.String("target"), Repo: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-repo")), Mirrors: c.StringSlice("registry-mirrors"), diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 8693ebe..bde087f 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -30,6 +30,7 @@ import ( kaniko "github.com/drone/drone-kaniko" "github.com/drone/drone-kaniko/pkg/artifact" "github.com/drone/drone-kaniko/pkg/docker" + "github.com/drone/drone-kaniko/pkg/utils" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/crane" ) @@ -132,7 +133,7 @@ func main() { Name: "args-new", Usage: "build args new", EnvVar: "PLUGIN_BUILD_ARGS_NEW", - Value: new(CustomStringSliceFlag), + Value: new(utils.CustomStringSliceFlag), }, cli.BoolFlag{ Name: "plugin-multiple-build-agrs", @@ -504,7 +505,7 @@ func run(c *cli.Context) error { AutoTagSuffix: c.String("auto-tag-suffix"), ExpandTag: c.Bool("expand-tag"), Args: c.StringSlice("args"), - ArgsNew: c.Generic("args-new").(*CustomStringSliceFlag).GetValue(), + ArgsNew: c.Generic("args-new").(*utils.CustomStringSliceFlag).GetValue(), IsMultipleBuildArgs: c.Bool("plugin-multiple-build-agrs"), Target: c.String("target"), Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), diff --git a/cmd/kaniko-gar/main.go b/cmd/kaniko-gar/main.go index 29c8559..d8d2cbf 100644 --- a/cmd/kaniko-gar/main.go +++ b/cmd/kaniko-gar/main.go @@ -18,6 +18,8 @@ import ( "github.com/drone/drone-kaniko/pkg/docker" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/crane" + "github.com/drone/drone-kaniko/pkg/utils" + ) const ( @@ -96,6 +98,17 @@ func main() { Usage: "build args", EnvVar: "PLUGIN_BUILD_ARGS", }, + cli.GenericFlag{ + Name: "args-new", + Usage: "build args new", + EnvVar: "PLUGIN_BUILD_ARGS_NEW", + Value: new(utils.CustomStringSliceFlag), + }, + cli.BoolFlag{ + Name: "plugin-multiple-build-agrs", + Usage: "plugin multiple build agrs", + EnvVar: "PLUGIN_MULTIPLE_BUILD_ARGS", + }, cli.StringFlag{ Name: "target", Usage: "build target", @@ -401,6 +414,8 @@ func run(c *cli.Context) error { AutoTagSuffix: c.String("auto-tag-suffix"), ExpandTag: c.Bool("expand-tag"), Args: c.StringSlice("args"), + ArgsNew: c.Generic("args-new").(*utils.CustomStringSliceFlag).GetValue(), + IsMultipleBuildArgs: c.Bool("plugin-multiple-build-agrs"), Target: c.String("target"), Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), Mirrors: c.StringSlice("registry-mirrors"), diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index 3eb44b7..cb76393 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -13,6 +13,7 @@ import ( kaniko "github.com/drone/drone-kaniko" "github.com/drone/drone-kaniko/pkg/artifact" "github.com/drone/drone-kaniko/pkg/docker" + "github.com/drone/drone-kaniko/pkg/utils" ) const ( @@ -333,6 +334,18 @@ func main() { Usage: "Number of retries for downloading base images.", EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY", }, + cli.GenericFlag{ + Name: "args-new", + Usage: "build args new", + EnvVar: "PLUGIN_BUILD_ARGS_NEW", + Value: new(utils.CustomStringSliceFlag), + }, + cli.BoolFlag{ + Name: "plugin-multiple-build-agrs", + Usage: "plugin multiple build agrs", + EnvVar: "PLUGIN_MULTIPLE_BUILD_ARGS", + }, + } if err := app.Run(os.Args); err != nil { diff --git a/cmd/kaniko-ecr/custom_string_slice.go b/pkg/utils/custom_string_slice.go similarity index 77% rename from cmd/kaniko-ecr/custom_string_slice.go rename to pkg/utils/custom_string_slice.go index 5e43581..2d489fb 100644 --- a/cmd/kaniko-ecr/custom_string_slice.go +++ b/pkg/utils/custom_string_slice.go @@ -1,4 +1,4 @@ -package main +package utils import ( "strings" @@ -10,6 +10,7 @@ type CustomStringSliceFlag struct { Value []string } +// GetValue returns the slice of strings stored in the flag func (f *CustomStringSliceFlag) GetValue() []string { if f.Value == nil { return make([]string, 0) @@ -17,6 +18,7 @@ func (f *CustomStringSliceFlag) GetValue() []string { return f.Value } +// String returns a string representation of the flag func (f *CustomStringSliceFlag) String() string { if f.Value == nil { return "" @@ -24,6 +26,7 @@ func (f *CustomStringSliceFlag) String() string { return strings.Join(f.Value, ";") } +// Set sets the value of the flag from a string func (f *CustomStringSliceFlag) Set(v string) error { for _, s := range strings.Split(v, ";") { s = strings.TrimSpace(s)