Skip to content

Commit

Permalink
export manifest for tar file (#1033)
Browse files Browse the repository at this point in the history
Signed-off-by: 刘畅 <basefly@outlook.com>
  • Loading branch information
hhstu authored Jun 9, 2021
1 parent 6118d45 commit f0ce227
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/v1/tarball/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ type Descriptor struct {
// Manifest represents the manifests of all images as the `manifest.json` file in a `docker save` tarball.
type Manifest []Descriptor

// LoadManifest load manifest
func LoadManifest(opener Opener) (Manifest, error) {
m, err := opener()
if err != nil {
return nil, err
}
defer m.Close()

var manifest Manifest

if err := json.NewDecoder(m).Decode(&manifest); err != nil {
return nil, err
}
return manifest, nil
}

func (m Manifest) findDescriptor(tag *name.Tag) (*Descriptor, error) {
if tag == nil {
if len(m) != 1 {
Expand Down

0 comments on commit f0ce227

Please sign in to comment.