diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index a4a9802..5eb3a09 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -410,7 +410,6 @@ func run(c *cli.Context) error { CacheCopyLayers: c.Bool("cache-copy-layers"), CacheRunLayers: c.Bool("cache-run-layers"), Cleanup: c.Bool("cleanup"), - CompressedCaching: c.Bool("compressed-caching"), ContextSubPath: c.String("context-sub-path"), CustomPlatform: c.String("custom-platform"), Force: c.Bool("force"), @@ -434,7 +433,6 @@ func run(c *cli.Context) error { SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), UseNewRun: c.Bool("use-new-run"), - IgnoreVarRun: c.Bool("ignore-var-run"), IgnorePath: c.String("ignore-path"), ImageFSExtractRetry: c.Int("image-fs-extract-retry"), ImageDownloadRetry: c.Int("image-download-retry"), @@ -447,6 +445,14 @@ func run(c *cli.Context) error { RegistryType: artifact.Docker, }, } + if c.IsSet("compressed-caching") { + flag := c.Bool("compressed-caching") + plugin.Build.CompressedCaching = &flag + } + if c.IsSet("ignore-var-run") { + flag := c.Bool("ignore-var-run") + plugin.Build.IgnoreVarRun = &flag + } return plugin.Exec() } diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index 16e62e2..d1b5de2 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -406,7 +406,6 @@ func run(c *cli.Context) error { CacheCopyLayers: c.Bool("cache-copy-layers"), CacheRunLayers: c.Bool("cache-run-layers"), Cleanup: c.Bool("cleanup"), - CompressedCaching: c.Bool("compressed-caching"), ContextSubPath: c.String("context-sub-path"), CustomPlatform: c.String("custom-platform"), Force: c.Bool("force"), @@ -430,7 +429,6 @@ func run(c *cli.Context) error { SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), UseNewRun: c.Bool("use-new-run"), - IgnoreVarRun: c.Bool("ignore-var-run"), IgnorePath: c.String("ignore-path"), ImageFSExtractRetry: c.Int("image-fs-extract-retry"), ImageDownloadRetry: c.Int("image-download-retry"), @@ -446,6 +444,14 @@ func run(c *cli.Context) error { OutputFile: c.String("output-file"), }, } + if c.IsSet("compressed-caching") { + flag := c.Bool("compressed-caching") + plugin.Build.CompressedCaching = &flag + } + if c.IsSet("ignore-var-run") { + flag := c.Bool("ignore-var-run") + plugin.Build.IgnoreVarRun = &flag + } return plugin.Exec() } diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 1015dfb..050c0bc 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -480,7 +480,6 @@ func run(c *cli.Context) error { CacheCopyLayers: c.Bool("cache-copy-layers"), CacheRunLayers: c.Bool("cache-run-layers"), Cleanup: c.Bool("cleanup"), - CompressedCaching: c.Bool("compressed-caching"), ContextSubPath: c.String("context-sub-path"), CustomPlatform: c.String("custom-platform"), Force: c.Bool("force"), @@ -504,7 +503,6 @@ func run(c *cli.Context) error { SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), UseNewRun: c.Bool("use-new-run"), - IgnoreVarRun: c.Bool("ignore-var-run"), IgnorePath: c.String("ignore-path"), ImageFSExtractRetry: c.Int("image-fs-extract-retry"), ImageDownloadRetry: c.Int("image-download-retry"), @@ -517,6 +515,14 @@ func run(c *cli.Context) error { RegistryType: artifact.ECR, }, } + if c.IsSet("compressed-caching") { + flag := c.Bool("compressed-caching") + plugin.Build.CompressedCaching = &flag + } + if c.IsSet("ignore-var-run") { + flag := c.Bool("ignore-var-run") + plugin.Build.IgnoreVarRun = &flag + } return plugin.Exec() } diff --git a/cmd/kaniko-gar/main.go b/cmd/kaniko-gar/main.go index cf38645..d065b23 100644 --- a/cmd/kaniko-gar/main.go +++ b/cmd/kaniko-gar/main.go @@ -363,7 +363,6 @@ func run(c *cli.Context) error { CacheCopyLayers: c.Bool("cache-copy-layers"), CacheRunLayers: c.Bool("cache-run-layers"), Cleanup: c.Bool("cleanup"), - CompressedCaching: c.Bool("compressed-caching"), ContextSubPath: c.String("context-sub-path"), CustomPlatform: c.String("custom-platform"), Force: c.Bool("force"), @@ -387,7 +386,6 @@ func run(c *cli.Context) error { SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), UseNewRun: c.Bool("use-new-run"), - IgnoreVarRun: c.Bool("ignore-var-run"), IgnorePath: c.String("ignore-path"), ImageFSExtractRetry: c.Int("image-fs-extract-retry"), ImageDownloadRetry: c.Int("image-download-retry"), @@ -400,6 +398,14 @@ func run(c *cli.Context) error { RegistryType: artifact.GAR, }, } + if c.IsSet("compressed-caching") { + flag := c.Bool("compressed-caching") + plugin.Build.CompressedCaching = &flag + } + if c.IsSet("ignore-var-run") { + flag := c.Bool("ignore-var-run") + plugin.Build.IgnoreVarRun = &flag + } return plugin.Exec() } diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index add4eef..095b19c 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -364,7 +364,6 @@ func run(c *cli.Context) error { CacheCopyLayers: c.Bool("cache-copy-layers"), CacheRunLayers: c.Bool("cache-run-layers"), Cleanup: c.Bool("cleanup"), - CompressedCaching: c.Bool("compressed-caching"), ContextSubPath: c.String("context-sub-path"), CustomPlatform: c.String("custom-platform"), Force: c.Bool("force"), @@ -388,7 +387,6 @@ func run(c *cli.Context) error { SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), UseNewRun: c.Bool("use-new-run"), - IgnoreVarRun: c.Bool("ignore-var-run"), IgnorePath: c.String("ignore-path"), ImageFSExtractRetry: c.Int("image-fs-extract-retry"), ImageDownloadRetry: c.Int("image-download-retry"), @@ -401,6 +399,14 @@ func run(c *cli.Context) error { RegistryType: artifact.GCR, }, } + if c.IsSet("compressed-caching") { + flag := c.Bool("compressed-caching") + plugin.Build.CompressedCaching = &flag + } + if c.IsSet("ignore-var-run") { + flag := c.Bool("ignore-var-run") + plugin.Build.IgnoreVarRun = &flag + } return plugin.Exec() } diff --git a/kaniko.go b/kaniko.go index 2a11a1b..0b65461 100644 --- a/kaniko.go +++ b/kaniko.go @@ -46,7 +46,7 @@ type ( CacheCopyLayers bool // Enable or disable copying layers from the cache. CacheRunLayers bool // Enable or disable running layers from the cache. Cleanup bool // Enable or disable cleanup of temporary files. - CompressedCaching bool // Enable or disable compressed caching. + CompressedCaching *bool // Enable or disable compressed caching. ContextSubPath string // Sub-path within the context to build. CustomPlatform string // Platform to use for building. Force bool // Force building the image even if it already exists. @@ -72,7 +72,7 @@ type ( SkipTLSVerifyPull bool // Skip TLS verification when pulling. SkipTLSVerifyRegistry bool // Skip TLS verification when connecting to a registry. UseNewRun bool // Use the new container runtime (`runc`) for builds. - IgnoreVarRun bool // Ignore `/var/run` when copying from the context. + IgnoreVarRun *bool // Ignore `/var/run` when copying from the context. IgnorePath string // Ignore files matching the specified path pattern. ImageFSExtractRetry int // Number of times to retry extracting the image filesystem. ImageDownloadRetry int // Number of times to retry downloading layers. @@ -273,9 +273,8 @@ func (p Plugin) Exec() error { cmdArgs = append(cmdArgs, "--cleanup=true") } - _, ok := os.LookupEnv("PLUGIN_COMPRESSED_CACHING") - if ok { - if p.Build.CompressedCaching { + if p.Build.CompressedCaching != nil { + if *p.Build.CompressedCaching { cmdArgs = append(cmdArgs, "--compressed-caching=true") } else { cmdArgs = append(cmdArgs, "--compressed-caching=false") @@ -370,9 +369,8 @@ func (p Plugin) Exec() error { cmdArgs = append(cmdArgs, "--use-new-run") } - _, ok = os.LookupEnv("PLUGIN_IGNORE_VAR_RUN") - if ok { - if p.Build.IgnoreVarRun { + if p.Build.IgnoreVarRun != nil { + if *p.Build.IgnoreVarRun { cmdArgs = append(cmdArgs, "--ignore-var-run=true") } else { cmdArgs = append(cmdArgs, "--ignore-var-run=false")