Skip to content

Commit

Permalink
Return digest instead of the random initialTag
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot committed Dec 26, 2018
1 parent f8a57cf commit 19dd9ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions pkg/skaffold/build/kaniko/kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,11 @@ func (b *Builder) Build(ctx context.Context, out io.Writer, tagger tag.Tagger, a
}

func (b *Builder) buildArtifactWithKaniko(ctx context.Context, out io.Writer, tagger tag.Tagger, artifact *latest.Artifact) (string, error) {
initialTag, err := b.run(ctx, out, artifact)
digest, err := b.runKaniko(ctx, out, artifact)
if err != nil {
return "", errors.Wrapf(err, "kaniko build for [%s]", artifact.ImageName)
}

digest, err := docker.RemoteDigest(initialTag)
if err != nil {
return "", errors.Wrap(err, "getting digest")
}

tag, err := tagger.GenerateFullyQualifiedImageName(artifact.Workspace, tag.Options{
ImageName: artifact.ImageName,
Digest: digest,
Expand All @@ -57,7 +52,7 @@ func (b *Builder) buildArtifactWithKaniko(ctx context.Context, out io.Writer, ta
return "", errors.Wrap(err, "generating tag")
}

if err := docker.AddTag(initialTag, tag); err != nil {
if err := docker.AddTag(digest, tag); err != nil {
return "", errors.Wrap(err, "tagging image")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/kaniko/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func (b *Builder) run(ctx context.Context, out io.Writer, artifact *latest.Artifact) (string, error) {
func (b *Builder) runKaniko(ctx context.Context, out io.Writer, artifact *latest.Artifact) (string, error) {
initialTag := util.RandomID()

s := sources.Retrieve(b.KanikoBuild)
Expand Down Expand Up @@ -87,5 +87,5 @@ func (b *Builder) run(ctx context.Context, out io.Writer, artifact *latest.Artif

waitForLogs()

return imageDst, nil
return docker.RemoteDigest(imageDst)
}

0 comments on commit 19dd9ab

Please sign in to comment.