From 7a044273f2f8e2cb377c0ecc5ae921c08bcbf35a Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Fri, 5 Mar 2021 04:22:29 +0800 Subject: [PATCH] Add digest source 'tag' to use tag without digest (#5436) * Add digest source 'tag' to use tag without digest * Update comment in pkg/skaffold/runner/build_deploy.go Co-authored-by: Marlon Gamez --- cmd/skaffold/app/cmd/render.go | 2 +- docs/content/en/docs/references/cli/_index.md | 2 +- pkg/skaffold/runner/build_deploy.go | 5 +++-- pkg/skaffold/runner/runner.go | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/skaffold/app/cmd/render.go b/cmd/skaffold/app/cmd/render.go index a7e036d4789..85a03a69413 100644 --- a/cmd/skaffold/app/cmd/render.go +++ b/cmd/skaffold/app/cmd/render.go @@ -48,7 +48,7 @@ func NewCmdRender() *cobra.Command { {Value: &renderFromBuildOutputFile, Name: "build-artifacts", Shorthand: "a", Usage: "File containing build result from a previous 'skaffold build --file-output'"}, {Value: &offline, Name: "offline", DefValue: false, Usage: `Do not connect to Kubernetes API server for manifest creation and validation. This is helpful when no Kubernetes cluster is available (e.g. GitOps model). No metadata.namespace attribute is injected in this case - the manifest content does not get changed.`, IsEnum: true}, {Value: &renderOutputPath, Name: "output", DefValue: "", Usage: "file to write rendered manifests to"}, - {Value: &opts.DigestSource, Name: "digest-source", DefValue: "local", Usage: "Set to 'local' to build images locally and use digests from built images; Set to 'remote' to resolve the digest of images by tag from the remote registry; Set to 'none' to use tags directly from the Kubernetes manifests", IsEnum: true}, + {Value: &opts.DigestSource, Name: "digest-source", DefValue: "local", Usage: "Set to 'local' to build images locally and use digests from built images; Set to 'remote' to resolve the digest of images by tag from the remote registry; Set to 'none' to use tags directly from the Kubernetes manifests. Set to 'tag' to use tags directly from the build.", IsEnum: true}, }). WithHouseKeepingMessages(). NoArgs(doRender) diff --git a/docs/content/en/docs/references/cli/_index.md b/docs/content/en/docs/references/cli/_index.md index 634e94d85c8..fe43f61a137 100644 --- a/docs/content/en/docs/references/cli/_index.md +++ b/docs/content/en/docs/references/cli/_index.md @@ -826,7 +826,7 @@ Options: --add-skaffold-labels=true: Add Skaffold-specific labels to rendered manifest. If false, custom labels are still applied. Helpful for GitOps model where Skaffold is not the deployer. -a, --build-artifacts=: File containing build result from a previous 'skaffold build --file-output' -d, --default-repo='': Default repository value (overrides global config) - --digest-source='local': Set to 'local' to build images locally and use digests from built images; Set to 'remote' to resolve the digest of images by tag from the remote registry; Set to 'none' to use tags directly from the Kubernetes manifests + --digest-source='local': Set to 'local' to build images locally and use digests from built images; Set to 'remote' to resolve the digest of images by tag from the remote registry; Set to 'none' to use tags directly from the Kubernetes manifests. Set to 'tag' to use tags directly from the build. -f, --filename='skaffold.yaml': Path or URL to the Skaffold config file -l, --label=[]: Add custom labels to deployed objects. Set multiple times for multiple labels --loud=false: Show the build logs and output diff --git a/pkg/skaffold/runner/build_deploy.go b/pkg/skaffold/runner/build_deploy.go index 9fe27a2cf49..1abe1c8460a 100644 --- a/pkg/skaffold/runner/build_deploy.go +++ b/pkg/skaffold/runner/build_deploy.go @@ -49,8 +49,9 @@ func (r *SkaffoldRunner) Build(ctx context.Context, out io.Writer, artifacts []* return nil, err } - // In dry-run mode or with --digest-source set to 'remote', we don't build anything, just return the tag for each artifact. - if r.runCtx.DryRun() || (r.runCtx.DigestSource() == remoteDigestSource) { + // In dry-run mode or with --digest-source set to 'remote' or 'tag', we don't build anything, just return the tag for each artifact. + if r.runCtx.DryRun() || (r.runCtx.DigestSource() == remoteDigestSource) || + (r.runCtx.DigestSource() == tagDigestSource) { var bRes []build.Artifact for _, artifact := range artifacts { bRes = append(bRes, build.Artifact{ diff --git a/pkg/skaffold/runner/runner.go b/pkg/skaffold/runner/runner.go index 4c418752ab8..6920e9cbf2a 100644 --- a/pkg/skaffold/runner/runner.go +++ b/pkg/skaffold/runner/runner.go @@ -38,6 +38,7 @@ import ( const ( remoteDigestSource = "remote" noneDigestSource = "none" + tagDigestSource = "tag" ) // Runner is responsible for running the skaffold build, test and deploy config.