Skip to content

Commit

Permalink
Expose IndexManifest
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Dillmann <[email protected]>
  • Loading branch information
modulo11 committed Jan 31, 2025
1 parent 186f89b commit 7c8fe1c
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cnb_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func (h *CNBIndex) Annotations(digest name.Digest) (annotations map[string]strin
return desc.Annotations, nil
}

func (h *CNBIndex) IndexManifest() (*v1.IndexManifest, error) {
return getIndexManifest(h.ImageIndex)
}

// setters

func (h *CNBIndex) SetAnnotations(digest name.Digest, annotations map[string]string) (err error) {
Expand Down
99 changes: 99 additions & 0 deletions fakes/image_index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package fakes

import (
"github.com/buildpacks/imgutil"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
)

var _ imgutil.ImageIndex = ImageIndex{}

type ImageIndex struct {
Manifests []v1.Descriptor
}

// AddManifest implements imgutil.ImageIndex.
func (i ImageIndex) AddManifest(image v1.Image) {
panic("unimplemented")

Check failure on line 17 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-windows

unused-parameter: parameter 'image' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 17 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-linux

unused-parameter: parameter 'image' seems to be unused, consider removing or renaming it as _ (revive)
}

// Annotations implements imgutil.ImageIndex.
func (i ImageIndex) Annotations(digest name.Digest) (annotations map[string]string, err error) {
panic("unimplemented")

Check failure on line 22 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-windows

unused-parameter: parameter 'digest' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 22 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-linux

unused-parameter: parameter 'digest' seems to be unused, consider removing or renaming it as _ (revive)
}

// Architecture implements imgutil.ImageIndex.
func (i ImageIndex) Architecture(digest name.Digest) (arch string, err error) {
panic("unimplemented")

Check failure on line 27 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-windows

unused-parameter: parameter 'digest' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 27 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-linux

unused-parameter: parameter 'digest' seems to be unused, consider removing or renaming it as _ (revive)
}

// DeleteDir implements imgutil.ImageIndex.
func (i ImageIndex) DeleteDir() error {
panic("unimplemented")
}

// Inspect implements imgutil.ImageIndex.
func (i ImageIndex) Inspect() (string, error) {
panic("unimplemented")
}

// OS implements imgutil.ImageIndex.
func (i ImageIndex) OS(digest name.Digest) (os string, err error) {
panic("unimplemented")

Check failure on line 42 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-windows

unused-parameter: parameter 'digest' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 42 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-linux

unused-parameter: parameter 'digest' seems to be unused, consider removing or renaming it as _ (revive)
}

// OSFeatures implements imgutil.ImageIndex.
func (i ImageIndex) OSFeatures(digest name.Digest) (osFeatures []string, err error) {
panic("unimplemented")
}

// OSVersion implements imgutil.ImageIndex.
func (i ImageIndex) OSVersion(digest name.Digest) (osVersion string, err error) {
panic("unimplemented")
}

// Push implements imgutil.ImageIndex.
func (i ImageIndex) Push(ops ...imgutil.IndexOption) error {
panic("unimplemented")

Check failure on line 57 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-windows

unused-parameter: parameter 'ops' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 57 in fakes/image_index.go

View workflow job for this annotation

GitHub Actions / test-and-build-linux

unused-parameter: parameter 'ops' seems to be unused, consider removing or renaming it as _ (revive)
}

// RemoveManifest implements imgutil.ImageIndex.
func (i ImageIndex) RemoveManifest(digest name.Digest) error {
panic("unimplemented")
}

// SaveDir implements imgutil.ImageIndex.
func (i ImageIndex) SaveDir() error {
panic("unimplemented")
}

// SetAnnotations implements imgutil.ImageIndex.
func (i ImageIndex) SetAnnotations(digest name.Digest, annotations map[string]string) (err error) {
panic("unimplemented")
}

// SetArchitecture implements imgutil.ImageIndex.
func (i ImageIndex) SetArchitecture(digest name.Digest, arch string) (err error) {
panic("unimplemented")
}

// SetOS implements imgutil.ImageIndex.
func (i ImageIndex) SetOS(digest name.Digest, os string) (err error) {
panic("unimplemented")
}

// SetVariant implements imgutil.ImageIndex.
func (i ImageIndex) SetVariant(digest name.Digest, osVariant string) (err error) {
panic("unimplemented")
}

// Variant implements imgutil.ImageIndex.
func (i ImageIndex) Variant(digest name.Digest) (osVariant string, err error) {
panic("unimplemented")
}

func (i ImageIndex) IndexManifest() (*v1.IndexManifest, error) {
return &v1.IndexManifest{
Manifests: i.Manifests,
}, nil
}
1 change: 1 addition & 0 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ImageIndex interface {
Inspect() (string, error)
AddManifest(image v1.Image)
RemoveManifest(digest name.Digest) error
IndexManifest() (*v1.IndexManifest, error)

Push(ops ...IndexOption) error
SaveDir() error
Expand Down

0 comments on commit 7c8fe1c

Please sign in to comment.