Skip to content

Commit

Permalink
fix(pusher): correctly report artifact type
Browse files Browse the repository at this point in the history
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
  • Loading branch information
alacuku authored and poiana committed Feb 13, 2024
1 parent 5d2bfa7 commit 43f1d3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/registry/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (o *pushOptions) runPush(ctx context.Context, args []string) error {
return err
}

logger.Info("Artifact pushed", logger.Args("name", args[0], "type", res.Type, "digest", res.Digest))
logger.Info("Artifact pushed", logger.Args("name", args[0], "type", res.Type, "digest", res.RootDigest))

return nil
}
3 changes: 2 additions & 1 deletion pkg/oci/pusher/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ func (p *Pusher) Push(ctx context.Context, artifactType oci.ArtifactType,
}

return &oci.RegistryResult{
Digest: string(rootDesc.Digest),
RootDigest: string(rootDesc.Digest),
Type: artifactType,
}, nil
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/oci/pusher/pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var _ = Describe("Pusher", func() {
Expect(err).ToNot(HaveOccurred())
// Being the artifact of type plugin we expect that the retrieved descriptor is of type image index.
Expect(d.MediaType).To(Equal(v1.MediaTypeImageIndex))
Expect(d.Digest.String()).To(Equal(result.Digest))
Expect(d.Digest.String()).To(Equal(result.RootDigest))
Expect(index.Manifests).To(HaveLen(1))
Expect(fmt.Sprintf("%s/%s", index.Manifests[0].Platform.OS, index.Manifests[0].Platform.Architecture)).To(Equal(testPluginPlatform1))
// Check layer and config media types.
Expand Down Expand Up @@ -188,7 +188,7 @@ var _ = Describe("Pusher", func() {
Expect(err).ToNot(HaveOccurred())
// Being the artifact of type plugin we expect that the retrieved descriptor is of type image index.
Expect(d.MediaType).To(Equal(v1.MediaTypeImageIndex))
Expect(d.Digest.String()).To(Equal(result.Digest))
Expect(d.Digest.String()).To(Equal(result.RootDigest))
Expect(index.Manifests).To(HaveLen(3))
Expect(fmt.Sprintf("%s/%s", index.Manifests[0].Platform.OS, index.Manifests[0].Platform.Architecture)).To(Equal(testPluginPlatform1))
Expect(fmt.Sprintf("%s/%s", index.Manifests[1].Platform.OS, index.Manifests[1].Platform.Architecture)).To(Equal(testPluginPlatform2))
Expand Down Expand Up @@ -225,7 +225,7 @@ var _ = Describe("Pusher", func() {
Expect(err).ToNot(HaveOccurred())
// Being the artifact of type rulesfile we expect that the retrieved descriptor is of type manifest.
Expect(d.MediaType).To(Equal(v1.MediaTypeImageManifest))
Expect(d.Digest.String()).To(Equal(result.Digest))
Expect(d.Digest.String()).To(Equal(result.RootDigest))
// It must have only one layer since no config layer is configured.
Expect(manifest.Layers).To(HaveLen(1))
// It must have the rulesfile's layer mediatype.
Expand Down Expand Up @@ -276,7 +276,7 @@ var _ = Describe("Pusher", func() {
Expect(err).ToNot(HaveOccurred())
// Being the artifact of type rulesfile we expect that the retrieved descriptor is of type manifest.
Expect(d.MediaType).To(Equal(v1.MediaTypeImageManifest))
Expect(d.Digest.String()).To(Equal(result.Digest))
Expect(d.Digest.String()).To(Equal(result.RootDigest))
// It must have only one layer since no config layer is configured.
Expect(manifest.Layers).To(HaveLen(1))
// It must have the rulesfile's layer mediatype.
Expand Down Expand Up @@ -348,7 +348,7 @@ var _ = Describe("Pusher", func() {
// Being the artifact of type asset we expect that the retrieved descriptor is of type manifest.
Expect(d.MediaType).To(Equal(v1.MediaTypeImageManifest))
// Checking the digest is correct.
Expect(d.Digest.String()).To(Equal(result.Digest))
Expect(d.Digest.String()).To(Equal(result.RootDigest))
// It must have only one layer since no config layer is configured.
Expect(manifest.Layers).To(HaveLen(1))
// The layer has to be of type asset.
Expand Down

0 comments on commit 43f1d3c

Please sign in to comment.