From b9ad37de0c466082ac1d5033ed9f10d866394ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20St=C3=A4bler?= Date: Mon, 11 Sep 2023 10:08:36 +0200 Subject: [PATCH 1/3] Add option to disable the overwrite of the base images entrypoint --- pkg/build/gobuild.go | 95 +++++++++++++++++++---------------- pkg/build/gobuild_test.go | 52 +++++++++++++++++++ pkg/build/options.go | 7 +++ pkg/commands/options/build.go | 15 +++--- pkg/commands/resolver.go | 4 ++ 5 files changed, 124 insertions(+), 49 deletions(-) diff --git a/pkg/build/gobuild.go b/pkg/build/gobuild.go index 884460473d..ed681d8ba1 100644 --- a/pkg/build/gobuild.go +++ b/pkg/build/gobuild.go @@ -71,20 +71,21 @@ type platformMatcher struct { } type gobuild struct { - ctx context.Context - getBase GetBase - creationTime v1.Time - kodataCreationTime v1.Time - build builder - sbom sbomber - sbomDir string - disableOptimizations bool - trimpath bool - buildConfigs map[string]Config - platformMatcher *platformMatcher - dir string - labels map[string]string - semaphore *semaphore.Weighted + ctx context.Context + getBase GetBase + creationTime v1.Time + kodataCreationTime v1.Time + build builder + sbom sbomber + sbomDir string + disableOptimizations bool + trimpath bool + buildConfigs map[string]Config + platformMatcher *platformMatcher + dir string + labels map[string]string + disableEntrypointOverwrite bool + semaphore *semaphore.Weighted cache *layerCache } @@ -93,20 +94,21 @@ type gobuild struct { type Option func(*gobuildOpener) error type gobuildOpener struct { - ctx context.Context - getBase GetBase - creationTime v1.Time - kodataCreationTime v1.Time - build builder - sbom sbomber - sbomDir string - disableOptimizations bool - trimpath bool - buildConfigs map[string]Config - platforms []string - labels map[string]string - dir string - jobs int + ctx context.Context + getBase GetBase + creationTime v1.Time + kodataCreationTime v1.Time + build builder + sbom sbomber + sbomDir string + disableOptimizations bool + trimpath bool + buildConfigs map[string]Config + platforms []string + labels map[string]string + dir string + jobs int + disableEntrypointOverwrite bool } func (gbo *gobuildOpener) Open() (Interface, error) { @@ -121,19 +123,20 @@ func (gbo *gobuildOpener) Open() (Interface, error) { gbo.jobs = runtime.GOMAXPROCS(0) } return &gobuild{ - ctx: gbo.ctx, - getBase: gbo.getBase, - creationTime: gbo.creationTime, - kodataCreationTime: gbo.kodataCreationTime, - build: gbo.build, - sbom: gbo.sbom, - sbomDir: gbo.sbomDir, - disableOptimizations: gbo.disableOptimizations, - trimpath: gbo.trimpath, - buildConfigs: gbo.buildConfigs, - labels: gbo.labels, - dir: gbo.dir, - platformMatcher: matcher, + ctx: gbo.ctx, + getBase: gbo.getBase, + creationTime: gbo.creationTime, + kodataCreationTime: gbo.kodataCreationTime, + build: gbo.build, + sbom: gbo.sbom, + sbomDir: gbo.sbomDir, + disableOptimizations: gbo.disableOptimizations, + trimpath: gbo.trimpath, + buildConfigs: gbo.buildConfigs, + labels: gbo.labels, + dir: gbo.dir, + disableEntrypointOverwrite: gbo.disableEntrypointOverwrite, + platformMatcher: matcher, cache: &layerCache{ buildToDiff: map[string]buildIDToDiffID{}, diffToDesc: map[string]diffIDToDescriptor{}, @@ -897,13 +900,19 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl } cfg = cfg.DeepCopy() - cfg.Config.Entrypoint = []string{appPath} cfg.Config.Cmd = nil if platform.OS == "windows" { - cfg.Config.Entrypoint = []string{`C:\ko-app\` + appFileName} + if !g.disableEntrypointOverwrite { + cfg.Config.Entrypoint = []string{`C:\ko-app\` + appFileName} + } + updatePath(cfg, `C:\ko-app`) cfg.Config.Env = append(cfg.Config.Env, `KO_DATA_PATH=C:\var\run\ko`) } else { + if !g.disableEntrypointOverwrite { + cfg.Config.Entrypoint = []string{appPath} + } + updatePath(cfg, appDir) cfg.Config.Env = append(cfg.Config.Env, "KO_DATA_PATH="+kodataRoot) } diff --git a/pkg/build/gobuild_test.go b/pkg/build/gobuild_test.go index 923a9bd3d2..7f9059bbc1 100644 --- a/pkg/build/gobuild_test.go +++ b/pkg/build/gobuild_test.go @@ -513,6 +513,58 @@ func TestGoBuildNoKoData(t *testing.T) { }) } +func TestDisableEntrypointOverwrite(t *testing.T) { + baseImageEntrypoint := "/my/custom/entrypoint.sh" + + base, err := random.Image(1024, 3) + if err != nil { + t.Fatalf("random.Image() = %v", err) + } + importpath := "github.com/google/ko" + + baseWithEntrypoint, err := mutate.Config(base, v1.Config{ + Entrypoint: []string{baseImageEntrypoint}, + }) + if err != nil { + t.Errorf("mutate.Config() = %v", err) + } + + ng, err := NewGo( + context.Background(), + "", + WithBaseImages(func(context.Context, string) (name.Reference, Result, error) { return baseRef, baseWithEntrypoint, nil }), + WithPlatforms("all"), + WithDisabledEntrypointOverwrite(), + ) + if err != nil { + t.Fatalf("NewGo() = %v", err) + } + + result, err := ng.Build(context.Background(), StrictScheme+importpath) + if err != nil { + t.Fatalf("Build() = %v", err) + } + + img, ok := result.(v1.Image) + if !ok { + t.Fatalf("Build() not an Image: %T", result) + } + + // Check that the entrypoint of the image is not overwritten + cfg, err := img.ConfigFile() + if err != nil { + t.Errorf("ConfigFile() = %v", err) + } + entrypoint := cfg.Config.Entrypoint + if got, want := len(entrypoint), 1; got != want { + t.Errorf("len(entrypoint) = %v, want %v", got, want) + } + + if got, want := entrypoint[0], baseImageEntrypoint; got != want { + t.Errorf("entrypoint = %v, want %v", got, want) + } +} + func validateImage(t *testing.T, img oci.SignedImage, baseLayers int64, creationTime v1.Time, checkAnnotations bool, expectSBOM bool) { t.Helper() diff --git a/pkg/build/options.go b/pkg/build/options.go index 4cedf4d0fb..f32b81bd2c 100644 --- a/pkg/build/options.go +++ b/pkg/build/options.go @@ -177,3 +177,10 @@ func WithSBOMDir(dir string) Option { return nil } } + +func WithDisabledEntrypointOverwrite() Option { + return func(gbo *gobuildOpener) error { + gbo.disableEntrypointOverwrite = true + return nil + } +} diff --git a/pkg/commands/options/build.go b/pkg/commands/options/build.go index a16c1033ad..344c697aa4 100644 --- a/pkg/commands/options/build.go +++ b/pkg/commands/options/build.go @@ -49,12 +49,13 @@ type BuildOptions struct { // Empty string means the current working directory. WorkingDirectory string - ConcurrentBuilds int - DisableOptimizations bool - SBOM string - SBOMDir string - Platforms []string - Labels []string + ConcurrentBuilds int + DisableOptimizations bool + SBOM string + SBOMDir string + Platforms []string + Labels []string + DisableEntrypointOverwrite bool // UserAgent enables overriding the default value of the `User-Agent` HTTP // request header used when retrieving the base image. UserAgent string @@ -84,6 +85,8 @@ func AddBuildOptions(cmd *cobra.Command, bo *BuildOptions) { "Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]*") cmd.Flags().StringSliceVar(&bo.Labels, "image-label", []string{}, "Which labels (key=value) to add to the image.") + cmd.Flags().BoolVar(&bo.DisableEntrypointOverwrite, "disable-entrypoint-overwrite", bo.DisableEntrypointOverwrite, + "Disable overwriting the images ENTRYPOINT and keep it from the base image.") bo.Trimpath = true } diff --git a/pkg/commands/resolver.go b/pkg/commands/resolver.go index 8a348f0e24..e487ed8f7f 100644 --- a/pkg/commands/resolver.go +++ b/pkg/commands/resolver.go @@ -125,6 +125,10 @@ func gobuildOptions(bo *options.BuildOptions) ([]build.Option, error) { opts = append(opts, build.WithSBOMDir(bo.SBOMDir)) } + if bo.DisableEntrypointOverwrite { + opts = append(opts, build.WithDisabledEntrypointOverwrite()) + } + return opts, nil } From 91db75cd2dde98273112257c90b22679675c752a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20St=C3=A4bler?= Date: Mon, 11 Sep 2023 10:09:03 +0200 Subject: [PATCH 2/3] Add env var which points to ko app --- pkg/build/gobuild.go | 2 ++ pkg/build/gobuild_test.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pkg/build/gobuild.go b/pkg/build/gobuild.go index ed681d8ba1..58f6e181c9 100644 --- a/pkg/build/gobuild.go +++ b/pkg/build/gobuild.go @@ -908,6 +908,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl updatePath(cfg, `C:\ko-app`) cfg.Config.Env = append(cfg.Config.Env, `KO_DATA_PATH=C:\var\run\ko`) + cfg.Config.Env = append(cfg.Config.Env, `KO_APP_PATH=C:\ko-app\`+appFileName) } else { if !g.disableEntrypointOverwrite { cfg.Config.Entrypoint = []string{appPath} @@ -915,6 +916,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl updatePath(cfg, appDir) cfg.Config.Env = append(cfg.Config.Env, "KO_DATA_PATH="+kodataRoot) + cfg.Config.Env = append(cfg.Config.Env, "KO_APP_PATH="+appPath) } cfg.Author = "github.com/ko-build/ko" diff --git a/pkg/build/gobuild_test.go b/pkg/build/gobuild_test.go index 7f9059bbc1..5d0f0788e8 100644 --- a/pkg/build/gobuild_test.go +++ b/pkg/build/gobuild_test.go @@ -669,6 +669,23 @@ func validateImage(t *testing.T, img oci.SignedImage, baseLayers int64, creation } }) + // Check that the environment contains the KO_APP_PATH environment variable. + t.Run("check KO_APP_PATH env var", func(t *testing.T) { + cfg, err := img.ConfigFile() + if err != nil { + t.Errorf("ConfigFile() = %v", err) + } + found := false + for _, entry := range cfg.Config.Env { + if entry == "KO_APP_PATH=/ko-app/test" { + found = true + } + } + if !found { + t.Error("Didn't find KO_APP_PATH.") + } + }) + // Check that PATH contains the directory of the produced binary. t.Run("check PATH env var", func(t *testing.T) { cfg, err := img.ConfigFile() From cdcb9298c7806e76ae7583a0e6383a0f05fd5260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20St=C3=A4bler?= Date: Mon, 11 Sep 2023 10:13:55 +0200 Subject: [PATCH 3/3] Update docs --- docs/reference/ko_apply.md | 43 ++++++++++++++++++------------------ docs/reference/ko_build.md | 37 ++++++++++++++++--------------- docs/reference/ko_create.md | 43 ++++++++++++++++++------------------ docs/reference/ko_resolve.md | 43 ++++++++++++++++++------------------ docs/reference/ko_run.md | 37 ++++++++++++++++--------------- 5 files changed, 104 insertions(+), 99 deletions(-) diff --git a/docs/reference/ko_apply.md b/docs/reference/ko_apply.md index b492120985..780c14eb5a 100644 --- a/docs/reference/ko_apply.md +++ b/docs/reference/ko_apply.md @@ -45,27 +45,28 @@ ko apply -f FILENAME [flags] ### Options ``` - --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). - -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). - --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. - -f, --filename strings Filename, directory, or URL to files to use to create the resource - -h, --help help for apply - --image-label strings Which labels (key=value) to add to the image. - --image-refs string Path to file where a list of the published image references will be written. - --insecure-registry Whether to skip TLS verification on the registry - -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) - -L, --local Load into images to local docker daemon. - --oci-layout-path string Path to save the OCI image layout of the built images - --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* - -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. - --push Push images to KO_DOCKER_REPO (default true) - -R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. - --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") - --sbom-dir string Path to file where the SBOM will be written. - -l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) - --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. - -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) - --tarball string File to save images tarballs + --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). + -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). + --disable-entrypoint-overwrite Disable overwriting the images ENTRYPOINT and keep it from the base image. + --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. + -f, --filename strings Filename, directory, or URL to files to use to create the resource + -h, --help help for apply + --image-label strings Which labels (key=value) to add to the image. + --image-refs string Path to file where a list of the published image references will be written. + --insecure-registry Whether to skip TLS verification on the registry + -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) + -L, --local Load into images to local docker daemon. + --oci-layout-path string Path to save the OCI image layout of the built images + --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* + -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. + --push Push images to KO_DOCKER_REPO (default true) + -R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. + --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") + --sbom-dir string Path to file where the SBOM will be written. + -l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) + --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. + -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) + --tarball string File to save images tarballs ``` ### Options inherited from parent commands diff --git a/docs/reference/ko_build.md b/docs/reference/ko_build.md index 8c4d97d6e1..9926eeffd0 100644 --- a/docs/reference/ko_build.md +++ b/docs/reference/ko_build.md @@ -42,24 +42,25 @@ ko build IMPORTPATH... [flags] ### Options ``` - --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). - -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). - --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. - -h, --help help for build - --image-label strings Which labels (key=value) to add to the image. - --image-refs string Path to file where a list of the published image references will be written. - --insecure-registry Whether to skip TLS verification on the registry - -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) - -L, --local Load into images to local docker daemon. - --oci-layout-path string Path to save the OCI image layout of the built images - --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* - -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. - --push Push images to KO_DOCKER_REPO (default true) - --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") - --sbom-dir string Path to file where the SBOM will be written. - --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. - -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) - --tarball string File to save images tarballs + --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). + -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). + --disable-entrypoint-overwrite Disable overwriting the images ENTRYPOINT and keep it from the base image. + --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. + -h, --help help for build + --image-label strings Which labels (key=value) to add to the image. + --image-refs string Path to file where a list of the published image references will be written. + --insecure-registry Whether to skip TLS verification on the registry + -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) + -L, --local Load into images to local docker daemon. + --oci-layout-path string Path to save the OCI image layout of the built images + --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* + -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. + --push Push images to KO_DOCKER_REPO (default true) + --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") + --sbom-dir string Path to file where the SBOM will be written. + --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. + -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) + --tarball string File to save images tarballs ``` ### Options inherited from parent commands diff --git a/docs/reference/ko_create.md b/docs/reference/ko_create.md index 700f94340c..89358b97e9 100644 --- a/docs/reference/ko_create.md +++ b/docs/reference/ko_create.md @@ -45,27 +45,28 @@ ko create -f FILENAME [flags] ### Options ``` - --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). - -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). - --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. - -f, --filename strings Filename, directory, or URL to files to use to create the resource - -h, --help help for create - --image-label strings Which labels (key=value) to add to the image. - --image-refs string Path to file where a list of the published image references will be written. - --insecure-registry Whether to skip TLS verification on the registry - -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) - -L, --local Load into images to local docker daemon. - --oci-layout-path string Path to save the OCI image layout of the built images - --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* - -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. - --push Push images to KO_DOCKER_REPO (default true) - -R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. - --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") - --sbom-dir string Path to file where the SBOM will be written. - -l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) - --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. - -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) - --tarball string File to save images tarballs + --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). + -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). + --disable-entrypoint-overwrite Disable overwriting the images ENTRYPOINT and keep it from the base image. + --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. + -f, --filename strings Filename, directory, or URL to files to use to create the resource + -h, --help help for create + --image-label strings Which labels (key=value) to add to the image. + --image-refs string Path to file where a list of the published image references will be written. + --insecure-registry Whether to skip TLS verification on the registry + -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) + -L, --local Load into images to local docker daemon. + --oci-layout-path string Path to save the OCI image layout of the built images + --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* + -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. + --push Push images to KO_DOCKER_REPO (default true) + -R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. + --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") + --sbom-dir string Path to file where the SBOM will be written. + -l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) + --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. + -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) + --tarball string File to save images tarballs ``` ### Options inherited from parent commands diff --git a/docs/reference/ko_resolve.md b/docs/reference/ko_resolve.md index 9466bbb308..50bdd7d5bf 100644 --- a/docs/reference/ko_resolve.md +++ b/docs/reference/ko_resolve.md @@ -38,27 +38,28 @@ ko resolve -f FILENAME [flags] ### Options ``` - --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). - -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). - --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. - -f, --filename strings Filename, directory, or URL to files to use to create the resource - -h, --help help for resolve - --image-label strings Which labels (key=value) to add to the image. - --image-refs string Path to file where a list of the published image references will be written. - --insecure-registry Whether to skip TLS verification on the registry - -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) - -L, --local Load into images to local docker daemon. - --oci-layout-path string Path to save the OCI image layout of the built images - --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* - -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. - --push Push images to KO_DOCKER_REPO (default true) - -R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. - --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") - --sbom-dir string Path to file where the SBOM will be written. - -l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) - --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. - -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) - --tarball string File to save images tarballs + --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). + -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). + --disable-entrypoint-overwrite Disable overwriting the images ENTRYPOINT and keep it from the base image. + --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. + -f, --filename strings Filename, directory, or URL to files to use to create the resource + -h, --help help for resolve + --image-label strings Which labels (key=value) to add to the image. + --image-refs string Path to file where a list of the published image references will be written. + --insecure-registry Whether to skip TLS verification on the registry + -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) + -L, --local Load into images to local docker daemon. + --oci-layout-path string Path to save the OCI image layout of the built images + --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* + -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. + --push Push images to KO_DOCKER_REPO (default true) + -R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. + --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") + --sbom-dir string Path to file where the SBOM will be written. + -l, --selector string Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) + --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. + -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) + --tarball string File to save images tarballs ``` ### Options inherited from parent commands diff --git a/docs/reference/ko_run.md b/docs/reference/ko_run.md index 5e2c88b045..81e43c3adb 100644 --- a/docs/reference/ko_run.md +++ b/docs/reference/ko_run.md @@ -30,24 +30,25 @@ ko run IMPORTPATH [flags] ### Options ``` - --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). - -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). - --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. - -h, --help help for run - --image-label strings Which labels (key=value) to add to the image. - --image-refs string Path to file where a list of the published image references will be written. - --insecure-registry Whether to skip TLS verification on the registry - -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) - -L, --local Load into images to local docker daemon. - --oci-layout-path string Path to save the OCI image layout of the built images - --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* - -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. - --push Push images to KO_DOCKER_REPO (default true) - --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") - --sbom-dir string Path to file where the SBOM will be written. - --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. - -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) - --tarball string File to save images tarballs + --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags). + -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags). + --disable-entrypoint-overwrite Disable overwriting the images ENTRYPOINT and keep it from the base image. + --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container. + -h, --help help for run + --image-label strings Which labels (key=value) to add to the image. + --image-refs string Path to file where a list of the published image references will be written. + --insecure-registry Whether to skip TLS verification on the registry + -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS) + -L, --local Load into images to local docker daemon. + --oci-layout-path string Path to save the OCI image layout of the built images + --platform strings Which platform to use when pulling a multi-platform base. Format: all | [/[/]][,platform]* + -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO. + --push Push images to KO_DOCKER_REPO (default true) + --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx") + --sbom-dir string Path to file where the SBOM will be written. + --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated. + -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest]) + --tarball string File to save images tarballs ``` ### Options inherited from parent commands