mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-16 14:49:02 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71882ec961 | |||
| fbb03e26c6 | |||
| 2ce6d5f6fc |
@@ -207,6 +207,157 @@ func main() {
|
|||||||
Usage: "build only used stages",
|
Usage: "build only used stages",
|
||||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cache-dir",
|
||||||
|
Usage: "Set this flag to specify a local directory cache for base images",
|
||||||
|
EnvVar: "PLUGIN_CACHE_DIR",
|
||||||
|
},
|
||||||
|
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-copy-layers",
|
||||||
|
Usage: "Enable or disable copying layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_COPY_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-run-layers",
|
||||||
|
Usage: "Enable or disable running layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_RUN_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cleanup",
|
||||||
|
Usage: "Enable or disable cleanup of temporary files.",
|
||||||
|
EnvVar: "PLUGIN_CLEANUP",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "compressed-caching",
|
||||||
|
Usage: "Enable or disable compressed caching.",
|
||||||
|
EnvVar: "PLUGIN_COMPRESSED_CACHING",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "context-sub-path",
|
||||||
|
Usage: "Sub-path within the context to build.",
|
||||||
|
EnvVar: "PLUGIN_CONTEXT_SUB_PATH",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "custom-platform",
|
||||||
|
Usage: "Platform to use for building.",
|
||||||
|
EnvVar: "PLUGIN_CUSTOM_PLATFORM",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "Force building the image even if it already exists.",
|
||||||
|
EnvVar: "PLUGIN_FORCE",
|
||||||
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "image-name-with-digest-file",
|
||||||
|
Usage: "Write image name with digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-tag-with-digest-file",
|
||||||
|
Usage: "Write image name with tag and digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure",
|
||||||
|
Usage: "Allow connecting to registries without TLS.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure-pull",
|
||||||
|
Usage: "Allow insecure pulls from the registry.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_PULL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "insecure-registry",
|
||||||
|
Usage: "Use plain HTTP for registry communication.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "log-format",
|
||||||
|
Usage: "Set the log format for build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_FORMAT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "log-timestamp",
|
||||||
|
Usage: "Show timestamps in build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_TIMESTAMP",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "oci-layout-path",
|
||||||
|
Usage: "Directory to store OCI layout.",
|
||||||
|
EnvVar: "PLUGIN_OCI_LAYOUT_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "push-retry",
|
||||||
|
Usage: "Number of times to retry pushing an image.",
|
||||||
|
EnvVar: "PLUGIN_PUSH_RETRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-certificate",
|
||||||
|
Usage: "Path to a file containing a registry certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CERTIFICATE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-client-cert",
|
||||||
|
Usage: "Path to a file containing a registry client certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-default-registry-fallback",
|
||||||
|
Usage: "Skip Docker Hub and default registry fallback.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "reproducible",
|
||||||
|
Usage: "Create a reproducible image.",
|
||||||
|
EnvVar: "PLUGIN_REPRODUCIBLE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "single-snapshot",
|
||||||
|
Usage: "Only create a single snapshot of the image.",
|
||||||
|
EnvVar: "PLUGIN_SINGLE_SNAPSHOT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-push-permission-check",
|
||||||
|
Usage: "Skip permission check when pushing.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-pull",
|
||||||
|
Usage: "Skip TLS verification when pulling.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-registry",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "use-new-run",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_USE_NEW_RUN",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "ignore-var-run",
|
||||||
|
Usage: "Ignore the /var/run directory during build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_VAR_RUN",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "ignore-path",
|
||||||
|
Usage: "Path to ignore during the build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-fs-extract-retry",
|
||||||
|
Usage: "Number of retries for extracting filesystem layers.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-download-retry",
|
||||||
|
Usage: "Number of retries for downloading base images.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -255,6 +406,36 @@ func run(c *cli.Context) error {
|
|||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
|
CacheDir: c.String("cache-dir"),
|
||||||
|
CacheCopyLayers: c.Bool("cache-copy-layers"),
|
||||||
|
CacheRunLayers: c.Bool("cache-run-layers"),
|
||||||
|
Cleanup: c.Bool("cleanup"),
|
||||||
|
ContextSubPath: c.String("context-sub-path"),
|
||||||
|
CustomPlatform: c.String("custom-platform"),
|
||||||
|
Force: c.Bool("force"),
|
||||||
|
ImageNameWithDigestFile: c.String("image-name-with-digest-file"),
|
||||||
|
ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"),
|
||||||
|
Insecure: c.Bool("insecure"),
|
||||||
|
InsecurePull: c.Bool("insecure-pull"),
|
||||||
|
InsecureRegistry: c.String("insecure-registry"),
|
||||||
|
Label: c.String("label"),
|
||||||
|
LogFormat: c.String("log-format"),
|
||||||
|
LogTimestamp: c.Bool("log-timestamp"),
|
||||||
|
OCILayoutPath: c.String("oci-layout-path"),
|
||||||
|
PushRetry: c.Int("push-retry"),
|
||||||
|
RegistryCertificate: c.String("registry-certificate"),
|
||||||
|
RegistryClientCert: c.String("registry-client-cert"),
|
||||||
|
SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"),
|
||||||
|
Reproducible: c.Bool("reproducible"),
|
||||||
|
SingleSnapshot: c.Bool("single-snapshot"),
|
||||||
|
SkipTLSVerify: c.Bool("skip-tls-verify"),
|
||||||
|
SkipPushPermissionCheck: c.Bool("skip-push-permission-check"),
|
||||||
|
SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"),
|
||||||
|
SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"),
|
||||||
|
UseNewRun: c.Bool("use-new-run"),
|
||||||
|
IgnorePath: c.String("ignore-path"),
|
||||||
|
ImageFSExtractRetry: c.Int("image-fs-extract-retry"),
|
||||||
|
ImageDownloadRetry: c.Int("image-download-retry"),
|
||||||
},
|
},
|
||||||
Artifact: kaniko.Artifact{
|
Artifact: kaniko.Artifact{
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
@@ -264,6 +445,14 @@ func run(c *cli.Context) error {
|
|||||||
RegistryType: artifact.Docker,
|
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()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,157 @@ 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.",
|
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",
|
EnvVar: "DRONE_OUTPUT",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cache-dir",
|
||||||
|
Usage: "Set this flag to specify a local directory cache for base images",
|
||||||
|
EnvVar: "PLUGIN_CACHE_DIR",
|
||||||
|
},
|
||||||
|
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-copy-layers",
|
||||||
|
Usage: "Enable or disable copying layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_COPY_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-run-layers",
|
||||||
|
Usage: "Enable or disable running layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_RUN_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cleanup",
|
||||||
|
Usage: "Enable or disable cleanup of temporary files.",
|
||||||
|
EnvVar: "PLUGIN_CLEANUP",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "compressed-caching",
|
||||||
|
Usage: "Enable or disable compressed caching.",
|
||||||
|
EnvVar: "PLUGIN_COMPRESSED_CACHING",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "context-sub-path",
|
||||||
|
Usage: "Sub-path within the context to build.",
|
||||||
|
EnvVar: "PLUGIN_CONTEXT_SUB_PATH",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "custom-platform",
|
||||||
|
Usage: "Platform to use for building.",
|
||||||
|
EnvVar: "PLUGIN_CUSTOM_PLATFORM",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "Force building the image even if it already exists.",
|
||||||
|
EnvVar: "PLUGIN_FORCE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-with-digest-file",
|
||||||
|
Usage: "Write image name with digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-tag-with-digest-file",
|
||||||
|
Usage: "Write image name with tag and digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure",
|
||||||
|
Usage: "Allow connecting to registries without TLS.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure-pull",
|
||||||
|
Usage: "Allow insecure pulls from the registry.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_PULL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "insecure-registry",
|
||||||
|
Usage: "Use plain HTTP for registry communication.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "log-format",
|
||||||
|
Usage: "Set the log format for build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_FORMAT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "log-timestamp",
|
||||||
|
Usage: "Show timestamps in build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_TIMESTAMP",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "oci-layout-path",
|
||||||
|
Usage: "Directory to store OCI layout.",
|
||||||
|
EnvVar: "PLUGIN_OCI_LAYOUT_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "push-retry",
|
||||||
|
Usage: "Number of times to retry pushing an image.",
|
||||||
|
EnvVar: "PLUGIN_PUSH_RETRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-certificate",
|
||||||
|
Usage: "Path to a file containing a registry certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CERTIFICATE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-client-cert",
|
||||||
|
Usage: "Path to a file containing a registry client certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-default-registry-fallback",
|
||||||
|
Usage: "Skip Docker Hub and default registry fallback.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "reproducible",
|
||||||
|
Usage: "Create a reproducible image.",
|
||||||
|
EnvVar: "PLUGIN_REPRODUCIBLE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "single-snapshot",
|
||||||
|
Usage: "Only create a single snapshot of the image.",
|
||||||
|
EnvVar: "PLUGIN_SINGLE_SNAPSHOT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-push-permission-check",
|
||||||
|
Usage: "Skip permission check when pushing.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-pull",
|
||||||
|
Usage: "Skip TLS verification when pulling.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-registry",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "use-new-run",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_USE_NEW_RUN",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "ignore-var-run",
|
||||||
|
Usage: "Ignore the /var/run directory during build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_VAR_RUN",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "ignore-path",
|
||||||
|
Usage: "Path to ignore during the build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-fs-extract-retry",
|
||||||
|
Usage: "Number of retries for extracting filesystem layers.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-download-retry",
|
||||||
|
Usage: "Number of retries for downloading base images.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -251,6 +402,36 @@ func run(c *cli.Context) error {
|
|||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
|
CacheDir: c.String("cache-dir"),
|
||||||
|
CacheCopyLayers: c.Bool("cache-copy-layers"),
|
||||||
|
CacheRunLayers: c.Bool("cache-run-layers"),
|
||||||
|
Cleanup: c.Bool("cleanup"),
|
||||||
|
ContextSubPath: c.String("context-sub-path"),
|
||||||
|
CustomPlatform: c.String("custom-platform"),
|
||||||
|
Force: c.Bool("force"),
|
||||||
|
ImageNameWithDigestFile: c.String("image-name-with-digest-file"),
|
||||||
|
ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"),
|
||||||
|
Insecure: c.Bool("insecure"),
|
||||||
|
InsecurePull: c.Bool("insecure-pull"),
|
||||||
|
InsecureRegistry: c.String("insecure-registry"),
|
||||||
|
Label: c.String("label"),
|
||||||
|
LogFormat: c.String("log-format"),
|
||||||
|
LogTimestamp: c.Bool("log-timestamp"),
|
||||||
|
OCILayoutPath: c.String("oci-layout-path"),
|
||||||
|
PushRetry: c.Int("push-retry"),
|
||||||
|
RegistryCertificate: c.String("registry-certificate"),
|
||||||
|
RegistryClientCert: c.String("registry-client-cert"),
|
||||||
|
SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"),
|
||||||
|
Reproducible: c.Bool("reproducible"),
|
||||||
|
SingleSnapshot: c.Bool("single-snapshot"),
|
||||||
|
SkipTLSVerify: c.Bool("skip-tls-verify"),
|
||||||
|
SkipPushPermissionCheck: c.Bool("skip-push-permission-check"),
|
||||||
|
SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"),
|
||||||
|
SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"),
|
||||||
|
UseNewRun: c.Bool("use-new-run"),
|
||||||
|
IgnorePath: c.String("ignore-path"),
|
||||||
|
ImageFSExtractRetry: c.Int("image-fs-extract-retry"),
|
||||||
|
ImageDownloadRetry: c.Int("image-download-retry"),
|
||||||
},
|
},
|
||||||
Artifact: kaniko.Artifact{
|
Artifact: kaniko.Artifact{
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
@@ -263,6 +444,14 @@ func run(c *cli.Context) error {
|
|||||||
OutputFile: c.String("output-file"),
|
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()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,157 @@ func main() {
|
|||||||
Usage: "build only used stages",
|
Usage: "build only used stages",
|
||||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cache-dir",
|
||||||
|
Usage: "Set this flag to specify a local directory cache for base images",
|
||||||
|
EnvVar: "PLUGIN_CACHE_DIR",
|
||||||
|
},
|
||||||
|
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-copy-layers",
|
||||||
|
Usage: "Enable or disable copying layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_COPY_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-run-layers",
|
||||||
|
Usage: "Enable or disable running layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_RUN_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cleanup",
|
||||||
|
Usage: "Enable or disable cleanup of temporary files.",
|
||||||
|
EnvVar: "PLUGIN_CLEANUP",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "compressed-caching",
|
||||||
|
Usage: "Enable or disable compressed caching.",
|
||||||
|
EnvVar: "PLUGIN_COMPRESSED_CACHING",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "context-sub-path",
|
||||||
|
Usage: "Sub-path within the context to build.",
|
||||||
|
EnvVar: "PLUGIN_CONTEXT_SUB_PATH",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "custom-platform",
|
||||||
|
Usage: "Platform to use for building.",
|
||||||
|
EnvVar: "PLUGIN_CUSTOM_PLATFORM",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "Force building the image even if it already exists.",
|
||||||
|
EnvVar: "PLUGIN_FORCE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-with-digest-file",
|
||||||
|
Usage: "Write image name with digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-tag-with-digest-file",
|
||||||
|
Usage: "Write image name with tag and digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure",
|
||||||
|
Usage: "Allow connecting to registries without TLS.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure-pull",
|
||||||
|
Usage: "Allow insecure pulls from the registry.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_PULL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "insecure-registry",
|
||||||
|
Usage: "Use plain HTTP for registry communication.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "log-format",
|
||||||
|
Usage: "Set the log format for build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_FORMAT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "log-timestamp",
|
||||||
|
Usage: "Show timestamps in build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_TIMESTAMP",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "oci-layout-path",
|
||||||
|
Usage: "Directory to store OCI layout.",
|
||||||
|
EnvVar: "PLUGIN_OCI_LAYOUT_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "push-retry",
|
||||||
|
Usage: "Number of times to retry pushing an image.",
|
||||||
|
EnvVar: "PLUGIN_PUSH_RETRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-certificate",
|
||||||
|
Usage: "Path to a file containing a registry certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CERTIFICATE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-client-cert",
|
||||||
|
Usage: "Path to a file containing a registry client certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-default-registry-fallback",
|
||||||
|
Usage: "Skip Docker Hub and default registry fallback.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "reproducible",
|
||||||
|
Usage: "Create a reproducible image.",
|
||||||
|
EnvVar: "PLUGIN_REPRODUCIBLE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "single-snapshot",
|
||||||
|
Usage: "Only create a single snapshot of the image.",
|
||||||
|
EnvVar: "PLUGIN_SINGLE_SNAPSHOT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-push-permission-check",
|
||||||
|
Usage: "Skip permission check when pushing.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-pull",
|
||||||
|
Usage: "Skip TLS verification when pulling.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-registry",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "use-new-run",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_USE_NEW_RUN",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "ignore-var-run",
|
||||||
|
Usage: "Ignore the /var/run directory during build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_VAR_RUN",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "ignore-path",
|
||||||
|
Usage: "Path to ignore during the build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-fs-extract-retry",
|
||||||
|
Usage: "Number of retries for extracting filesystem layers.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-download-retry",
|
||||||
|
Usage: "Number of retries for downloading base images.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -325,6 +476,36 @@ func run(c *cli.Context) error {
|
|||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
|
CacheDir: c.String("cache-dir"),
|
||||||
|
CacheCopyLayers: c.Bool("cache-copy-layers"),
|
||||||
|
CacheRunLayers: c.Bool("cache-run-layers"),
|
||||||
|
Cleanup: c.Bool("cleanup"),
|
||||||
|
ContextSubPath: c.String("context-sub-path"),
|
||||||
|
CustomPlatform: c.String("custom-platform"),
|
||||||
|
Force: c.Bool("force"),
|
||||||
|
ImageNameWithDigestFile: c.String("image-name-with-digest-file"),
|
||||||
|
ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"),
|
||||||
|
Insecure: c.Bool("insecure"),
|
||||||
|
InsecurePull: c.Bool("insecure-pull"),
|
||||||
|
InsecureRegistry: c.String("insecure-registry"),
|
||||||
|
Label: c.String("label"),
|
||||||
|
LogFormat: c.String("log-format"),
|
||||||
|
LogTimestamp: c.Bool("log-timestamp"),
|
||||||
|
OCILayoutPath: c.String("oci-layout-path"),
|
||||||
|
PushRetry: c.Int("push-retry"),
|
||||||
|
RegistryCertificate: c.String("registry-certificate"),
|
||||||
|
RegistryClientCert: c.String("registry-client-cert"),
|
||||||
|
SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"),
|
||||||
|
Reproducible: c.Bool("reproducible"),
|
||||||
|
SingleSnapshot: c.Bool("single-snapshot"),
|
||||||
|
SkipTLSVerify: c.Bool("skip-tls-verify"),
|
||||||
|
SkipPushPermissionCheck: c.Bool("skip-push-permission-check"),
|
||||||
|
SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"),
|
||||||
|
SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"),
|
||||||
|
UseNewRun: c.Bool("use-new-run"),
|
||||||
|
IgnorePath: c.String("ignore-path"),
|
||||||
|
ImageFSExtractRetry: c.Int("image-fs-extract-retry"),
|
||||||
|
ImageDownloadRetry: c.Int("image-download-retry"),
|
||||||
},
|
},
|
||||||
Artifact: kaniko.Artifact{
|
Artifact: kaniko.Artifact{
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
@@ -334,6 +515,14 @@ func run(c *cli.Context) error {
|
|||||||
RegistryType: artifact.ECR,
|
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()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,6 +164,157 @@ func main() {
|
|||||||
Usage: "build only used stages",
|
Usage: "build only used stages",
|
||||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cache-dir",
|
||||||
|
Usage: "Set this flag to specify a local directory cache for base images",
|
||||||
|
EnvVar: "PLUGIN_CACHE_DIR",
|
||||||
|
},
|
||||||
|
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-copy-layers",
|
||||||
|
Usage: "Enable or disable copying layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_COPY_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-run-layers",
|
||||||
|
Usage: "Enable or disable running layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_RUN_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cleanup",
|
||||||
|
Usage: "Enable or disable cleanup of temporary files.",
|
||||||
|
EnvVar: "PLUGIN_CLEANUP",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "compressed-caching",
|
||||||
|
Usage: "Enable or disable compressed caching.",
|
||||||
|
EnvVar: "PLUGIN_COMPRESSED_CACHING",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "context-sub-path",
|
||||||
|
Usage: "Sub-path within the context to build.",
|
||||||
|
EnvVar: "PLUGIN_CONTEXT_SUB_PATH",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "custom-platform",
|
||||||
|
Usage: "Platform to use for building.",
|
||||||
|
EnvVar: "PLUGIN_CUSTOM_PLATFORM",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "Force building the image even if it already exists.",
|
||||||
|
EnvVar: "PLUGIN_FORCE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-with-digest-file",
|
||||||
|
Usage: "Write image name with digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-tag-with-digest-file",
|
||||||
|
Usage: "Write image name with tag and digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure",
|
||||||
|
Usage: "Allow connecting to registries without TLS.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure-pull",
|
||||||
|
Usage: "Allow insecure pulls from the registry.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_PULL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "insecure-registry",
|
||||||
|
Usage: "Use plain HTTP for registry communication.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "log-format",
|
||||||
|
Usage: "Set the log format for build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_FORMAT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "log-timestamp",
|
||||||
|
Usage: "Show timestamps in build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_TIMESTAMP",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "oci-layout-path",
|
||||||
|
Usage: "Directory to store OCI layout.",
|
||||||
|
EnvVar: "PLUGIN_OCI_LAYOUT_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "push-retry",
|
||||||
|
Usage: "Number of times to retry pushing an image.",
|
||||||
|
EnvVar: "PLUGIN_PUSH_RETRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-certificate",
|
||||||
|
Usage: "Path to a file containing a registry certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CERTIFICATE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-client-cert",
|
||||||
|
Usage: "Path to a file containing a registry client certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-default-registry-fallback",
|
||||||
|
Usage: "Skip Docker Hub and default registry fallback.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "reproducible",
|
||||||
|
Usage: "Create a reproducible image.",
|
||||||
|
EnvVar: "PLUGIN_REPRODUCIBLE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "single-snapshot",
|
||||||
|
Usage: "Only create a single snapshot of the image.",
|
||||||
|
EnvVar: "PLUGIN_SINGLE_SNAPSHOT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-push-permission-check",
|
||||||
|
Usage: "Skip permission check when pushing.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-pull",
|
||||||
|
Usage: "Skip TLS verification when pulling.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-registry",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "use-new-run",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_USE_NEW_RUN",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "ignore-var-run",
|
||||||
|
Usage: "Ignore the /var/run directory during build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_VAR_RUN",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "ignore-path",
|
||||||
|
Usage: "Path to ignore during the build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-fs-extract-retry",
|
||||||
|
Usage: "Number of retries for extracting filesystem layers.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-download-retry",
|
||||||
|
Usage: "Number of retries for downloading base images.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -208,6 +359,36 @@ func run(c *cli.Context) error {
|
|||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
|
CacheDir: c.String("cache-dir"),
|
||||||
|
CacheCopyLayers: c.Bool("cache-copy-layers"),
|
||||||
|
CacheRunLayers: c.Bool("cache-run-layers"),
|
||||||
|
Cleanup: c.Bool("cleanup"),
|
||||||
|
ContextSubPath: c.String("context-sub-path"),
|
||||||
|
CustomPlatform: c.String("custom-platform"),
|
||||||
|
Force: c.Bool("force"),
|
||||||
|
ImageNameWithDigestFile: c.String("image-name-with-digest-file"),
|
||||||
|
ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"),
|
||||||
|
Insecure: c.Bool("insecure"),
|
||||||
|
InsecurePull: c.Bool("insecure-pull"),
|
||||||
|
InsecureRegistry: c.String("insecure-registry"),
|
||||||
|
Label: c.String("label"),
|
||||||
|
LogFormat: c.String("log-format"),
|
||||||
|
LogTimestamp: c.Bool("log-timestamp"),
|
||||||
|
OCILayoutPath: c.String("oci-layout-path"),
|
||||||
|
PushRetry: c.Int("push-retry"),
|
||||||
|
RegistryCertificate: c.String("registry-certificate"),
|
||||||
|
RegistryClientCert: c.String("registry-client-cert"),
|
||||||
|
SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"),
|
||||||
|
Reproducible: c.Bool("reproducible"),
|
||||||
|
SingleSnapshot: c.Bool("single-snapshot"),
|
||||||
|
SkipTLSVerify: c.Bool("skip-tls-verify"),
|
||||||
|
SkipPushPermissionCheck: c.Bool("skip-push-permission-check"),
|
||||||
|
SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"),
|
||||||
|
SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"),
|
||||||
|
UseNewRun: c.Bool("use-new-run"),
|
||||||
|
IgnorePath: c.String("ignore-path"),
|
||||||
|
ImageFSExtractRetry: c.Int("image-fs-extract-retry"),
|
||||||
|
ImageDownloadRetry: c.Int("image-download-retry"),
|
||||||
},
|
},
|
||||||
Artifact: kaniko.Artifact{
|
Artifact: kaniko.Artifact{
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
@@ -217,6 +398,14 @@ func run(c *cli.Context) error {
|
|||||||
RegistryType: artifact.GAR,
|
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()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,157 @@ func main() {
|
|||||||
Usage: "build only used stages",
|
Usage: "build only used stages",
|
||||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "cache-dir",
|
||||||
|
Usage: "Set this flag to specify a local directory cache for base images",
|
||||||
|
EnvVar: "PLUGIN_CACHE_DIR",
|
||||||
|
},
|
||||||
|
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-copy-layers",
|
||||||
|
Usage: "Enable or disable copying layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_COPY_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cache-run-layers",
|
||||||
|
Usage: "Enable or disable running layers from the cache.",
|
||||||
|
EnvVar: "PLUGIN_CACHE_RUN_LAYERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "cleanup",
|
||||||
|
Usage: "Enable or disable cleanup of temporary files.",
|
||||||
|
EnvVar: "PLUGIN_CLEANUP",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "compressed-caching",
|
||||||
|
Usage: "Enable or disable compressed caching.",
|
||||||
|
EnvVar: "PLUGIN_COMPRESSED_CACHING",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "context-sub-path",
|
||||||
|
Usage: "Sub-path within the context to build.",
|
||||||
|
EnvVar: "PLUGIN_CONTEXT_SUB_PATH",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "custom-platform",
|
||||||
|
Usage: "Platform to use for building.",
|
||||||
|
EnvVar: "PLUGIN_CUSTOM_PLATFORM",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "Force building the image even if it already exists.",
|
||||||
|
EnvVar: "PLUGIN_FORCE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-with-digest-file",
|
||||||
|
Usage: "Write image name with digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "image-name-tag-with-digest-file",
|
||||||
|
Usage: "Write image name with tag and digest to a file.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure",
|
||||||
|
Usage: "Allow connecting to registries without TLS.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "insecure-pull",
|
||||||
|
Usage: "Allow insecure pulls from the registry.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_PULL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "insecure-registry",
|
||||||
|
Usage: "Use plain HTTP for registry communication.",
|
||||||
|
EnvVar: "PLUGIN_INSECURE_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "log-format",
|
||||||
|
Usage: "Set the log format for build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_FORMAT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "log-timestamp",
|
||||||
|
Usage: "Show timestamps in build output.",
|
||||||
|
EnvVar: "PLUGIN_LOG_TIMESTAMP",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "oci-layout-path",
|
||||||
|
Usage: "Directory to store OCI layout.",
|
||||||
|
EnvVar: "PLUGIN_OCI_LAYOUT_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "push-retry",
|
||||||
|
Usage: "Number of times to retry pushing an image.",
|
||||||
|
EnvVar: "PLUGIN_PUSH_RETRY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-certificate",
|
||||||
|
Usage: "Path to a file containing a registry certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CERTIFICATE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "registry-client-cert",
|
||||||
|
Usage: "Path to a file containing a registry client certificate.",
|
||||||
|
EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-default-registry-fallback",
|
||||||
|
Usage: "Skip Docker Hub and default registry fallback.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "reproducible",
|
||||||
|
Usage: "Create a reproducible image.",
|
||||||
|
EnvVar: "PLUGIN_REPRODUCIBLE",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "single-snapshot",
|
||||||
|
Usage: "Only create a single snapshot of the image.",
|
||||||
|
EnvVar: "PLUGIN_SINGLE_SNAPSHOT",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-push-permission-check",
|
||||||
|
Usage: "Skip permission check when pushing.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-pull",
|
||||||
|
Usage: "Skip TLS verification when pulling.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-tls-verify-registry",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "use-new-run",
|
||||||
|
Usage: "Skip TLS verification when connecting to a registry.",
|
||||||
|
EnvVar: "PLUGIN_USE_NEW_RUN",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "ignore-var-run",
|
||||||
|
Usage: "Ignore the /var/run directory during build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_VAR_RUN",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "ignore-path",
|
||||||
|
Usage: "Path to ignore during the build.",
|
||||||
|
EnvVar: "PLUGIN_IGNORE_PATH",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-fs-extract-retry",
|
||||||
|
Usage: "Number of retries for extracting filesystem layers.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "image-download-retry",
|
||||||
|
Usage: "Number of retries for downloading base images.",
|
||||||
|
EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -209,6 +360,36 @@ func run(c *cli.Context) error {
|
|||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
|
CacheDir: c.String("cache-dir"),
|
||||||
|
CacheCopyLayers: c.Bool("cache-copy-layers"),
|
||||||
|
CacheRunLayers: c.Bool("cache-run-layers"),
|
||||||
|
Cleanup: c.Bool("cleanup"),
|
||||||
|
ContextSubPath: c.String("context-sub-path"),
|
||||||
|
CustomPlatform: c.String("custom-platform"),
|
||||||
|
Force: c.Bool("force"),
|
||||||
|
ImageNameWithDigestFile: c.String("image-name-with-digest-file"),
|
||||||
|
ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"),
|
||||||
|
Insecure: c.Bool("insecure"),
|
||||||
|
InsecurePull: c.Bool("insecure-pull"),
|
||||||
|
InsecureRegistry: c.String("insecure-registry"),
|
||||||
|
Label: c.String("label"),
|
||||||
|
LogFormat: c.String("log-format"),
|
||||||
|
LogTimestamp: c.Bool("log-timestamp"),
|
||||||
|
OCILayoutPath: c.String("oci-layout-path"),
|
||||||
|
PushRetry: c.Int("push-retry"),
|
||||||
|
RegistryCertificate: c.String("registry-certificate"),
|
||||||
|
RegistryClientCert: c.String("registry-client-cert"),
|
||||||
|
SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"),
|
||||||
|
Reproducible: c.Bool("reproducible"),
|
||||||
|
SingleSnapshot: c.Bool("single-snapshot"),
|
||||||
|
SkipTLSVerify: c.Bool("skip-tls-verify"),
|
||||||
|
SkipPushPermissionCheck: c.Bool("skip-push-permission-check"),
|
||||||
|
SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"),
|
||||||
|
SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"),
|
||||||
|
UseNewRun: c.Bool("use-new-run"),
|
||||||
|
IgnorePath: c.String("ignore-path"),
|
||||||
|
ImageFSExtractRetry: c.Int("image-fs-extract-retry"),
|
||||||
|
ImageDownloadRetry: c.Int("image-download-retry"),
|
||||||
},
|
},
|
||||||
Artifact: kaniko.Artifact{
|
Artifact: kaniko.Artifact{
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
@@ -218,6 +399,14 @@ func run(c *cli.Context) error {
|
|||||||
RegistryType: artifact.GCR,
|
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()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,42 @@ type (
|
|||||||
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
||||||
SkipUnusedStages bool // Build only used stages
|
SkipUnusedStages bool // Build only used stages
|
||||||
TarPath string // Set this flag to save the image as a tarball at path
|
TarPath string // Set this flag to save the image as a tarball at path
|
||||||
|
|
||||||
|
Cache bool // Enable or disable caching during the build process.
|
||||||
|
CacheDir string // Directory to store cached layers.
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
Git bool // Branch to clone if build context is a git repository .
|
||||||
|
ImageNameWithDigestFile string // Write image name with digest to a file.
|
||||||
|
ImageNameTagWithDigestFile string // Write image name with tag and digest to a file.
|
||||||
|
Insecure bool // Allow connecting to registries without TLS.
|
||||||
|
InsecurePull bool // Allow insecure pulls from the registry.
|
||||||
|
InsecureRegistry string // Use plain HTTP for registry communication.
|
||||||
|
Label string // Add metadata to an image.
|
||||||
|
LogFormat string // Set the log format for build output.
|
||||||
|
LogTimestamp bool // Show timestamps in build output.
|
||||||
|
OCILayoutPath string // Directory to store OCI layout.
|
||||||
|
PushRetry int // Number of times to retry pushing an image.
|
||||||
|
RegistryCertificate string // Path to a file containing a registry certificate.
|
||||||
|
RegistryClientCert string // Path to a file containing a registry client certificate.
|
||||||
|
RegistryMirror string // Mirror for registry pulls.
|
||||||
|
SkipDefaultRegistryFallback bool // Skip Docker Hub and default registry fallback.
|
||||||
|
Reproducible bool // Create a reproducible image.
|
||||||
|
SingleSnapshot bool // Only create a single snapshot of the image.
|
||||||
|
SkipTLSVerify bool // Skip TLS verification when connecting to the registry.
|
||||||
|
SkipPushPermissionCheck bool // Skip permission check when pushing.
|
||||||
|
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.
|
||||||
|
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Artifact defines content of artifact file
|
// Artifact defines content of artifact file
|
||||||
@@ -64,11 +100,6 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const kanikoArgsEnabled = "DRONE_KANIKO_ADDIONAL_ARGS_ENABLED"
|
|
||||||
|
|
||||||
// Allowed variables
|
|
||||||
var allowList = []string{"PLUGIN_BUILD_ARG", "PLUGIN_CACHE", "PLUGIN_CACHE_DIR", "PLUGIN_CACHE_REPO", "PLUGIN_CACHE_COPY_LAYERS", "PLUGIN_CACHE_RUN_LAYERS", "PLUGIN_CACHE_TTL", "PLUGIN_CLEANUP", "PLUGIN_COMPRESSED_CACHING", "PLUGIN_CONTEXT_SUB_PATH", "PLUGIN_CUSTOM_PLATFORM", "PLUGIN_DIGEST_FILE", "PLUGIN_DOCKERFILE", "PLUGIN_FORCE", "PLUGIN_GIT", "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE", "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE", "PLUGIN_INSECURE", "PLUGIN_INSECURE_PULL", "PLUGIN_INSECURE_REGISTRY", "PLUGIN_LABEL", "PLUGIN_LOG_FORMAT", "PLUGIN_LOG_TIMESTAMP", "PLUGIN_NO_PUSH", "PLUGIN_OCI_LAYOUT_PATH", "PLUGIN_PUSH_RETRY", "PLUGIN_REGISTRY_CERTIFICATE", "PLUGIN_REGISTRY_CLIENT_CERT", "PLUGIN_REGISTRY_MIRROR", "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK", "PLUGIN_REPRODUCIBLE", "PLUGIN_SINGLE_SNAPSHOT", "PLUGIN_SKIP_TLS_VERIFY", "PLUGIN_SKIP_PUSH_PERMISSION_CHECK", "PLUGIN_SKIP_TLS_VERIFY_PULL", "PLUGIN_SKIP_TLS_VERIFY_REGISTRY", "PLUGIN_SKIP_UNUSED_STAGES", "PLUGIN_SNAPSHOT_MODE", "PLUGIN_TAR_PATH", "PLUGIN_TARGET", "PLUGIN_USE_NEW_RUN", "PLUGIN_VERBOSITY", "PLUGIN_IGNORE_VAR_RUN", "PLUGIN_IGNORE_PATH", "PLUGIN_IMAGE_FS_EXTRACT_RETRY", "PLUGIN_IMAGE_DOWNLOAD_RETRY"}
|
|
||||||
|
|
||||||
// labelsForTag returns the labels to use for the given tag, subject to the value of ExpandTag.
|
// labelsForTag returns the labels to use for the given tag, subject to the value of ExpandTag.
|
||||||
//
|
//
|
||||||
// Build information (e.g. +linux_amd64) is carried through to all labels.
|
// Build information (e.g. +linux_amd64) is carried through to all labels.
|
||||||
@@ -230,15 +261,132 @@ func (p Plugin) Exec() error {
|
|||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--tar-path=%s", p.Build.TarPath))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--tar-path=%s", p.Build.TarPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Read all PLUGIN_ env vars if FF is enabled
|
if p.Build.CacheCopyLayers {
|
||||||
//parse them such that PLUGIN_ENV_ARG is set to the value of --env-arg
|
cmdArgs = append(cmdArgs, "--cache-copy-layers")
|
||||||
//Add the value of --env-arg to cmdArgs if it does not exist
|
|
||||||
argsEnabled, ok := os.LookupEnv(kanikoArgsEnabled)
|
|
||||||
if ok {
|
|
||||||
fmt.Fprintf(os.Stdout, "%s env is set with value: %s ", kanikoArgsEnabled, argsEnabled)
|
|
||||||
}
|
}
|
||||||
if argsEnabled == "true" {
|
|
||||||
cmdArgs = getPluginEnvVars(cmdArgs)
|
if p.Build.CacheRunLayers {
|
||||||
|
cmdArgs = append(cmdArgs, "--cache-run-layers=true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.Cleanup {
|
||||||
|
cmdArgs = append(cmdArgs, "--cleanup=true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.CompressedCaching != nil {
|
||||||
|
if *p.Build.CompressedCaching {
|
||||||
|
cmdArgs = append(cmdArgs, "--compressed-caching=true")
|
||||||
|
} else {
|
||||||
|
cmdArgs = append(cmdArgs, "--compressed-caching=false")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.ContextSubPath != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--context-sub-path=%s", p.Build.ContextSubPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.CustomPlatform != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--custom-platform=%s", p.Build.CustomPlatform))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.Force {
|
||||||
|
cmdArgs = append(cmdArgs, "--force")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.Git {
|
||||||
|
cmdArgs = append(cmdArgs, "--git")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.ImageNameWithDigestFile != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--image-name-with-digest-file=%s", p.Build.ImageNameWithDigestFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.ImageNameTagWithDigestFile != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--image-name-tag-with-digest-file=%s", p.Build.ImageNameTagWithDigestFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.Insecure {
|
||||||
|
cmdArgs = append(cmdArgs, "--insecure")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.InsecurePull {
|
||||||
|
cmdArgs = append(cmdArgs, "--insecure-pull")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.InsecureRegistry != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--insecure-registry=%s", p.Build.InsecureRegistry))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.LogFormat != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--log-format=%s", p.Build.LogFormat))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.LogTimestamp {
|
||||||
|
cmdArgs = append(cmdArgs, "--log-timestamp")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.OCILayoutPath != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--oci-layout-path=%s", p.Build.OCILayoutPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.PushRetry != 0 {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--push-retry=%d", p.Build.PushRetry))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.RegistryCertificate != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--registry-certificate=%s", p.Build.RegistryCertificate))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.RegistryClientCert != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--registry-client-cert=%s", p.Build.RegistryClientCert))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.SkipDefaultRegistryFallback {
|
||||||
|
cmdArgs = append(cmdArgs, "--skip-default-registry-fallback")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.Reproducible {
|
||||||
|
cmdArgs = append(cmdArgs, "--reproducible")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.SingleSnapshot {
|
||||||
|
cmdArgs = append(cmdArgs, "--single-snapshot")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.SkipPushPermissionCheck {
|
||||||
|
cmdArgs = append(cmdArgs, "--skip-push-permission-check")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.SkipTLSVerifyPull {
|
||||||
|
cmdArgs = append(cmdArgs, "--skip-tls-verify-pull")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.SkipTLSVerifyRegistry {
|
||||||
|
cmdArgs = append(cmdArgs, "--skip-tls-verify-registry")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.UseNewRun {
|
||||||
|
cmdArgs = append(cmdArgs, "--use-new-run")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.IgnoreVarRun != nil {
|
||||||
|
if *p.Build.IgnoreVarRun {
|
||||||
|
cmdArgs = append(cmdArgs, "--ignore-var-run=true")
|
||||||
|
} else {
|
||||||
|
cmdArgs = append(cmdArgs, "--ignore-var-run=false")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.IgnorePath != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--ignore-path=%s", p.Build.IgnorePath))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.ImageFSExtractRetry != 0 {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--image-fs-extract-retry=%d", p.Build.ImageFSExtractRetry))
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Build.ImageDownloadRetry != 0 {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--image-download-retry=%d", p.Build.ImageDownloadRetry))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("/kaniko/executor", cmdArgs...)
|
cmd := exec.Command("/kaniko/executor", cmdArgs...)
|
||||||
@@ -280,60 +428,3 @@ func getDigest(digestFile string) string {
|
|||||||
func trace(cmd *exec.Cmd) {
|
func trace(cmd *exec.Cmd) {
|
||||||
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPluginEnvVars(cmdArgs []string) []string {
|
|
||||||
envVars := os.Environ()
|
|
||||||
|
|
||||||
// Iterate through environment variables
|
|
||||||
for _, envVar := range envVars {
|
|
||||||
// Check if the variable starts with PLUGIN_
|
|
||||||
if strings.HasPrefix(envVar, "PLUGIN_") && contains(allowList, envVar) {
|
|
||||||
// Split the variable into key and value
|
|
||||||
parts := strings.SplitN(envVar, "=", 2)
|
|
||||||
if len(parts) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
key := parts[0]
|
|
||||||
value := parts[1]
|
|
||||||
|
|
||||||
// Trim the "PLUGIN_" prefix
|
|
||||||
flagName := strings.TrimPrefix(key, "PLUGIN_")
|
|
||||||
|
|
||||||
// Replace underscores with hyphens and convert to lowercase
|
|
||||||
flagName = strings.ReplaceAll(flagName, "_", "-")
|
|
||||||
flagName = strings.ToLower(flagName)
|
|
||||||
|
|
||||||
// Format the flag name with "--" prefix
|
|
||||||
flag := "--" + flagName
|
|
||||||
|
|
||||||
// Check if the flag already exists in cmdArgs
|
|
||||||
exists := false
|
|
||||||
for _, arg := range cmdArgs {
|
|
||||||
if strings.HasPrefix(arg, flag) {
|
|
||||||
exists = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the flag does not exist, add it to cmdArgs
|
|
||||||
if !exists {
|
|
||||||
if value == "" {
|
|
||||||
cmdArgs = append(cmdArgs, flag)
|
|
||||||
} else {
|
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("%s=%s", flag, value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cmdArgs
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to check if a string is in a slice
|
|
||||||
func contains(slice []string, str string) bool {
|
|
||||||
for _, s := range slice {
|
|
||||||
if strings.HasPrefix(str, s) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user