Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the upstream option --ignore-var-run #85

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/kaniko-acr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
Expand Down
7 changes: 7 additions & 0 deletions cmd/kaniko-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
Expand Down
7 changes: 7 additions & 0 deletions cmd/kaniko-ecr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
Expand Down
7 changes: 7 additions & 0 deletions cmd/kaniko-gcr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
Expand Down
5 changes: 5 additions & 0 deletions kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down