From 5df1de3028e4a4e9ea1e049eb5ffa0a1702308b5 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 15 Aug 2023 10:16:45 +0200 Subject: [PATCH] Add the upstream option --ignore-var-run --- cmd/kaniko-acr/main.go | 7 +++++++ cmd/kaniko-docker/main.go | 7 +++++++ cmd/kaniko-ecr/main.go | 7 +++++++ cmd/kaniko-gcr/main.go | 7 +++++++ kaniko.go | 5 +++++ 5 files changed, 33 insertions(+) diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index ff60c55..5b9e04b 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -206,6 +206,12 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "ignore-var-run", + Usage: "Set it to false to preserve /var/run/* in destination image", + Value: "True", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, } if err := app.Run(os.Args); err != nil { @@ -254,6 +260,7 @@ func run(c *cli.Context) error { Verbosity: c.String("verbosity"), Platform: c.String("platform"), SkipUnusedStages: c.Bool("skip-unused-stages"), + IgnoreVarRun: c.String("ignore-var-run"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index a0511da..b4b460c 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -201,6 +201,12 @@ func main() { Usage: "Output file location that will be generated by the plugin. This file will include information of the output that are exported by the plugin.", EnvVar: "DRONE_OUTPUT", }, + cli.StringFlag{ + Name: "ignore-var-run", + Usage: "Set it to false to preserve /var/run/* in destination image", + Value: "True", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, } if err := app.Run(os.Args); err != nil { @@ -251,6 +257,7 @@ func run(c *cli.Context) error { Verbosity: c.String("verbosity"), Platform: c.String("platform"), SkipUnusedStages: c.Bool("skip-unused-stages"), + IgnoreVarRun: c.String("ignore-var-run"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 1652369..7ee983a 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -234,6 +234,12 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "ignore-var-run", + Usage: "Set it to false to preserve /var/run/* in destination image", + Value: "True", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, } if err := app.Run(os.Args); err != nil { @@ -325,6 +331,7 @@ func run(c *cli.Context) error { Verbosity: c.String("verbosity"), Platform: c.String("platform"), SkipUnusedStages: c.Bool("skip-unused-stages"), + IgnoreVarRun: c.String("ignore-var-run"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index 74bb2e5..37e0d36 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -165,6 +165,12 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "ignore-var-run", + Usage: "Set it to false to preserve /var/run/* in destination image", + Value: "True", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, } if err := app.Run(os.Args); err != nil { @@ -209,6 +215,7 @@ func run(c *cli.Context) error { Verbosity: c.String("verbosity"), Platform: c.String("platform"), SkipUnusedStages: c.Bool("skip-unused-stages"), + IgnoreVarRun: c.String("ignore-var-run"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/kaniko.go b/kaniko.go index 62d324c..2891a24 100644 --- a/kaniko.go +++ b/kaniko.go @@ -40,6 +40,7 @@ type ( Platform string // Allows to build with another default platform than the host, similarly to docker build --platform SkipUnusedStages bool // Build only used stages TarPath string // Set this flag to save the image as a tarball at path + IgnoreVarRun string // Set it to false to preserve /var/run/* in destination image } // Artifact defines content of artifact file @@ -224,6 +225,10 @@ func (p Plugin) Exec() error { if p.Build.TarPath != "" { cmdArgs = append(cmdArgs, fmt.Sprintf("--tar-path=%s", p.Build.TarPath)) } + + if p.Build.IgnoreVarRun != "" { + cmdArgs = append(cmdArgs, fmt.Sprintf("--ignore-var-run=%s", p.Build.IgnoreVarRun)) + } cmd := exec.Command("/kaniko/executor", cmdArgs...) cmd.Stdout = os.Stdout