-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matthew Penner <[email protected]>
- Loading branch information
Showing
9 changed files
with
231 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package image | ||
|
||
import ( | ||
v1 "github.com/google/go-containerregistry/pkg/v1" | ||
"github.com/hashicorp/go-multierror" | ||
) | ||
|
||
// Index represents a container image index. | ||
type Index struct { | ||
// index is the raw index manifest and content provider from the GCR lib | ||
index v1.ImageIndex | ||
// images is a list of images associated with an index. | ||
images []*Image | ||
} | ||
|
||
// NewIndex provides a new image index object. | ||
func NewIndex(index v1.ImageIndex, images []*Image) *Index { | ||
return &Index{ | ||
index: index, | ||
images: images, | ||
} | ||
} | ||
|
||
// Images returns a list of images associated with an index. | ||
func (i *Index) Images() []*Image { | ||
return i.images | ||
} | ||
|
||
// Cleanup removes all temporary files created from parsing the index and associated images. | ||
// Future calls to image will not function correctly after this call. | ||
func (i *Index) Cleanup() error { | ||
if i == nil { | ||
return nil | ||
} | ||
var errs error | ||
for _, img := range i.images { | ||
if err := img.Cleanup(); err != nil { | ||
errs = multierror.Append(errs, err) | ||
} | ||
} | ||
return errs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
24 changes: 24 additions & 0 deletions
24
pkg/image/oci/test-fixtures/valid_manifest_index/index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"schemaVersion": 2, | ||
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", | ||
"manifests": [ | ||
{ | ||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json", | ||
"size": 424, | ||
"digest": "sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b", | ||
"platform": { | ||
"architecture": "arm64", | ||
"os": "linux" | ||
} | ||
}, | ||
{ | ||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json", | ||
"size": 424, | ||
"digest": "sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513c", | ||
"platform": { | ||
"architecture": "amd64", | ||
"os": "linux" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters