mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
API: report multiple digests for images
Be prepared to report multiple image digests for images which contain multiple manifests but, because they continue to have the same set of layers and the same configuration, are considered to be the same image. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
2
API.md
2
API.md
@@ -1675,6 +1675,8 @@ id [string](https://godoc.org/builtin#string)
|
||||
|
||||
digest [string](https://godoc.org/builtin#string)
|
||||
|
||||
digests [[]string](#[]string)
|
||||
|
||||
parentId [string](https://godoc.org/builtin#string)
|
||||
|
||||
repoTags [[]string](#[]string)
|
||||
|
||||
@@ -27,6 +27,7 @@ type imagesTemplateParams struct {
|
||||
Tag string
|
||||
ID string
|
||||
Digest digest.Digest
|
||||
Digests []digest.Digest
|
||||
Created string
|
||||
CreatedTime time.Time
|
||||
Size string
|
||||
@@ -34,12 +35,13 @@ type imagesTemplateParams struct {
|
||||
}
|
||||
|
||||
type imagesJSONParams struct {
|
||||
ID string `json:"id"`
|
||||
Name []string `json:"names"`
|
||||
Digest digest.Digest `json:"digest"`
|
||||
Created time.Time `json:"created"`
|
||||
Size *uint64 `json:"size"`
|
||||
ReadOnly bool `json:"readonly"`
|
||||
ID string `json:"id"`
|
||||
Name []string `json:"names"`
|
||||
Digest digest.Digest `json:"digest"`
|
||||
Digests []digest.Digest `json:"digests"`
|
||||
Created time.Time `json:"created"`
|
||||
Size *uint64 `json:"size"`
|
||||
ReadOnly bool `json:"readonly"`
|
||||
}
|
||||
|
||||
type imagesOptions struct {
|
||||
@@ -290,6 +292,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
|
||||
Tag: tag,
|
||||
ID: imageID,
|
||||
Digest: img.Digest(),
|
||||
Digests: img.Digests(),
|
||||
CreatedTime: createdTime,
|
||||
Created: units.HumanDuration(time.Since(createdTime)) + " ago",
|
||||
Size: sizeStr,
|
||||
@@ -321,6 +324,7 @@ func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage)
|
||||
ID: img.ID(),
|
||||
Name: img.Names(),
|
||||
Digest: img.Digest(),
|
||||
Digests: img.Digests(),
|
||||
Created: img.Created(),
|
||||
Size: size,
|
||||
ReadOnly: img.IsReadOnly(),
|
||||
|
||||
@@ -58,7 +58,8 @@ type VolumeRemoveOpts (
|
||||
|
||||
type Image (
|
||||
id: string,
|
||||
digest: string,
|
||||
digest: string,
|
||||
digests: []string,
|
||||
parentId: string,
|
||||
repoTags: []string,
|
||||
repoDigests: []string,
|
||||
|
||||
@@ -299,6 +299,11 @@ func (i *Image) Digest() digest.Digest {
|
||||
return i.image.Digest
|
||||
}
|
||||
|
||||
// Digests returns the image's digests
|
||||
func (i *Image) Digests() []digest.Digest {
|
||||
return i.image.Digests
|
||||
}
|
||||
|
||||
// GetManifest returns the image's manifest as a byte array
|
||||
// and manifest type as a string.
|
||||
func (i *Image) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
|
||||
|
||||
@@ -146,6 +146,7 @@ type remoteImage struct {
|
||||
InputName string
|
||||
Names []string
|
||||
Digest digest.Digest
|
||||
Digests []digest.Digest
|
||||
isParent bool
|
||||
Runtime *LocalRuntime
|
||||
TopLayer string
|
||||
@@ -226,10 +227,15 @@ func imageInListToContainerImage(i iopodman.Image, name string, runtime *LocalRu
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var digests []digest.Digest
|
||||
for _, d := range i.Digests {
|
||||
digests = append(digests, digest.Digest(d))
|
||||
}
|
||||
ri := remoteImage{
|
||||
InputName: name,
|
||||
ID: i.Id,
|
||||
Digest: digest.Digest(i.Digest),
|
||||
Digests: digests,
|
||||
Labels: i.Labels,
|
||||
RepoTags: i.RepoTags,
|
||||
RepoDigests: i.RepoTags,
|
||||
@@ -352,6 +358,11 @@ func (ci *ContainerImage) Digest() digest.Digest {
|
||||
return ci.remoteImage.Digest
|
||||
}
|
||||
|
||||
// Digests returns the image's digests
|
||||
func (ci *ContainerImage) Digests() []digest.Digest {
|
||||
return append([]digest.Digest{}, ci.remoteImage.Digests...)
|
||||
}
|
||||
|
||||
// Labels returns a map of the image's labels
|
||||
func (ci *ContainerImage) Labels(ctx context.Context) (map[string]string, error) {
|
||||
return ci.remoteImage.Labels, nil
|
||||
|
||||
Reference in New Issue
Block a user