Skip to content

Commit

Permalink
Add digest source 'tag' to use tag without digest (#5436)
Browse files Browse the repository at this point in the history
* Add digest source 'tag' to use tag without digest

* Update comment in pkg/skaffold/runner/build_deploy.go

Co-authored-by: Marlon Gamez <marlongamez@google.com>
  • Loading branch information
fengye87 and MarlonGamez authored Mar 4, 2021
1 parent 14d4128 commit 7a04427
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs/references/cli/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/skaffold/runner/build_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
const (
remoteDigestSource = "remote"
noneDigestSource = "none"
tagDigestSource = "tag"
)

// Runner is responsible for running the skaffold build, test and deploy config.
Expand Down

0 comments on commit 7a04427

Please sign in to comment.