mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: log missing image name
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
096c6ba6b2
commit
1a9209eb1f
@ -1445,15 +1445,19 @@ func TestWithDigest(t *testing.T) {
|
||||
Type: artifact.DockerImage,
|
||||
})
|
||||
|
||||
t.Run("good", func(t *testing.T) {
|
||||
require.Equal(t, "owner/img:t1@sha256:d1", withDigest("owner/img:t1", artifacts.List()))
|
||||
})
|
||||
for _, use := range []string{useDocker, useBuildx} {
|
||||
t.Run(use, func(t *testing.T) {
|
||||
t.Run("good", func(t *testing.T) {
|
||||
require.Equal(t, "localhost:5050/owner/img:t1@sha256:d1", withDigest(use, "localhost:5050/owner/img:t1", artifacts.List()))
|
||||
})
|
||||
|
||||
t.Run("no digest", func(t *testing.T) {
|
||||
require.Equal(t, "owner/img:t3", withDigest("owner/img:t3", artifacts.List()))
|
||||
})
|
||||
t.Run("no digest", func(t *testing.T) {
|
||||
require.Equal(t, "localhost:5050/owner/img:t3", withDigest(use, "localhost:5050/owner/img:t3", artifacts.List()))
|
||||
})
|
||||
|
||||
t.Run("no match", func(t *testing.T) {
|
||||
require.Equal(t, "owner/img:t4", withDigest("owner/img:t4", artifacts.List()))
|
||||
})
|
||||
t.Run("no match", func(t *testing.T) {
|
||||
require.Equal(t, "localhost:5050/owner/img:t4", withDigest(use, "localhost:5050/owner/img:t4", artifacts.List()))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func manifestImages(ctx *context.Context, manifest config.DockerManifest) ([]str
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
imgs = append(imgs, withDigest(str, artifacts))
|
||||
imgs = append(imgs, withDigest(manifest.Use, str, artifacts))
|
||||
}
|
||||
if strings.TrimSpace(strings.Join(manifest.ImageTemplates, "")) == "" {
|
||||
return imgs, pipe.Skip("manifest has no images")
|
||||
@ -131,7 +131,7 @@ func manifestImages(ctx *context.Context, manifest config.DockerManifest) ([]str
|
||||
return imgs, nil
|
||||
}
|
||||
|
||||
func withDigest(name string, images []*artifact.Artifact) string {
|
||||
func withDigest(use, name string, images []*artifact.Artifact) string {
|
||||
for _, art := range images {
|
||||
if art.Name == name {
|
||||
if digest := artifact.ExtraOr(*art, artifact.ExtraDigest, ""); digest != "" {
|
||||
@ -140,6 +140,6 @@ func withDigest(name string, images []*artifact.Artifact) string {
|
||||
break
|
||||
}
|
||||
}
|
||||
log.Warnf("did not find the digest for %s, defaulting to insecure mode")
|
||||
log.Warnf("did not find the digest for %s using %s, defaulting to insecure mode", name, use)
|
||||
return name
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user