mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-17 20:17:11 +02:00
Allow multiple destinations
This commit is contained in:
@@ -21,23 +21,23 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// The buildArg type is used to pass in multiple --build-arg flags
|
||||
type buildArg []string
|
||||
// This type is used to supported passing in multiple flags
|
||||
type multiArg []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 {
|
||||
func (b *multiArg) 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)
|
||||
func (b *multiArg) Set(value string) error {
|
||||
logrus.Infof("appending to multi args %s", value)
|
||||
*b = append(*b, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *buildArg) Type() string {
|
||||
return "build-arg type"
|
||||
func (b *multiArg) Type() string {
|
||||
return "multi-arg type"
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ import (
|
||||
|
||||
var (
|
||||
dockerfilePath string
|
||||
destination string
|
||||
destinations multiArg
|
||||
srcContext string
|
||||
snapshotMode string
|
||||
bucket string
|
||||
dockerInsecureSkipTLSVerify bool
|
||||
logLevel string
|
||||
force bool
|
||||
buildArgs buildArg
|
||||
buildArgs multiArg
|
||||
tarPath string
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ func init() {
|
||||
RootCmd.PersistentFlags().StringVarP(&dockerfilePath, "dockerfile", "f", "Dockerfile", "Path to the dockerfile to be built.")
|
||||
RootCmd.PersistentFlags().StringVarP(&srcContext, "context", "c", "/workspace/", "Path to the dockerfile build context.")
|
||||
RootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
|
||||
RootCmd.PersistentFlags().StringVarP(&destination, "destination", "d", "", "Registry the final image should be pushed to (ex: gcr.io/test/example:latest)")
|
||||
RootCmd.PersistentFlags().VarP(&destinations, "destination", "d", "Registry the final image should be pushed to. Set it repeatedly for multiple destinations.")
|
||||
RootCmd.MarkPersistentFlagRequired("destination")
|
||||
RootCmd.PersistentFlags().StringVarP(&snapshotMode, "snapshotMode", "", "full", "Set this flag to change the file attributes inspected during snapshotting")
|
||||
RootCmd.PersistentFlags().VarP(&buildArgs, "build-arg", "", "This flag allows you to pass in ARG values at build time. Set it repeatedly for multiple values.")
|
||||
@@ -84,10 +84,13 @@ var RootCmd = &cobra.Command{
|
||||
logrus.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := executor.DoPush(ref, image, destination, tarPath); err != nil {
|
||||
logrus.Error(err)
|
||||
os.Exit(1)
|
||||
|
||||
for _, destination := range destinations {
|
||||
if err := executor.DoPush(ref, image, destination, tarPath); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user