Skip to content

Commit

Permalink
fix --resolve-image-digests
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed May 16, 2024
1 parent eb5e018 commit 73ba69d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions cmd/compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ func runConfig(ctx context.Context, dockerCli command.Cli, opts configOptions, s
return err
}

if opts.resolveImageDigests {
project, err = project.WithImagesResolved(compose.ImageDigestResolver(ctx, dockerCli.ConfigFile(), dockerCli.Client()))
if err != nil {
return err
}
}

if !opts.noConsistency {
err := project.CheckContainerNameUnicity()
if err != nil {
Expand Down Expand Up @@ -342,6 +349,7 @@ func runConfigImages(ctx context.Context, dockerCli command.Cli, opts configOpti
if err != nil {
return err
}

for _, s := range project.Services {
fmt.Fprintln(dockerCli.Out(), api.GetImageNameOrDefault(s, project.Name))
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/Microsoft/go-winio v0.6.2
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/buger/goterm v1.0.4
github.com/compose-spec/compose-go/v2 v2.1.0
github.com/compose-spec/compose-go/v2 v2.1.1-0.20240516145816-197e6352c64a
github.com/containerd/console v1.0.4
github.com/containerd/containerd v1.7.16
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+g
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4=
github.com/compose-spec/compose-go/v2 v2.1.0 h1:qdW2qISQlCQG8v1O2TChcdxgAWTUGgUX/CPSO+ES9+E=
github.com/compose-spec/compose-go/v2 v2.1.0/go.mod h1:bEPizBkIojlQ20pi2vNluBa58tevvj0Y18oUSHPyfdc=
github.com/compose-spec/compose-go/v2 v2.1.1-0.20240516145816-197e6352c64a h1:R0ufvPulvRvFa8JaFEWzSJmkhjfeArXD9vKk0jpmpM4=
github.com/compose-spec/compose-go/v2 v2.1.1-0.20240516145816-197e6352c64a/go.mod h1:bEPizBkIojlQ20pi2vNluBa58tevvj0Y18oUSHPyfdc=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro=
Expand Down
3 changes: 2 additions & 1 deletion pkg/compose/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ func ImageDigestResolver(ctx context.Context, file *configfile.ConfigFile, apiCl
}
inspect, err := apiClient.DistributionInspect(ctx, named.String(), auth)
if err != nil {
return "", err
return "",
fmt.Errorf("failed ot resolve digest for %s: %w", named.String(), err)
}
return inspect.Descriptor.Digest, nil
}
Expand Down

0 comments on commit 73ba69d

Please sign in to comment.