mirror of
https://github.com/containers/skopeo.git
synced 2025-07-30 14:10:36 +00:00
show tag and taglist
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
b33e09491c
commit
2dbacbb786
19
inspect.go
19
inspect.go
@ -41,6 +41,7 @@ type manifestFetcher interface {
|
||||
|
||||
type imageInspect struct {
|
||||
V1ID string `json:"V1Id"`
|
||||
Tag string
|
||||
RepoTags []string
|
||||
RepoDigests []string
|
||||
Parent string
|
||||
@ -246,20 +247,7 @@ func validateRepoName(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeImageInspect(repoInfo *registry.RepositoryInfo, img *image.Image, tag string, dgst digest.Digest) *imageInspect {
|
||||
var repoTags = make([]string, 0, 1)
|
||||
if tagged, isTagged := repoInfo.Named.(reference.NamedTagged); isTagged || tag != "" {
|
||||
if !isTagged {
|
||||
newTagged, err := reference.WithTag(repoInfo, tag)
|
||||
if err == nil {
|
||||
tagged = newTagged
|
||||
}
|
||||
}
|
||||
if tagged != nil {
|
||||
repoTags = append(repoTags, tagged.String())
|
||||
}
|
||||
}
|
||||
|
||||
func makeImageInspect(repoInfo *registry.RepositoryInfo, img *image.Image, tag string, tagList []string, dgst digest.Digest) *imageInspect {
|
||||
var repoDigests = make([]string, 0, 1)
|
||||
if err := dgst.Validate(); err == nil {
|
||||
repoDigests = append(repoDigests, dgst.String())
|
||||
@ -267,7 +255,8 @@ func makeImageInspect(repoInfo *registry.RepositoryInfo, img *image.Image, tag s
|
||||
|
||||
return &imageInspect{
|
||||
V1ID: img.V1Image.ID,
|
||||
RepoTags: repoTags,
|
||||
Tag: tag,
|
||||
RepoTags: tagList,
|
||||
RepoDigests: repoDigests,
|
||||
Parent: img.Parent.String(),
|
||||
Comment: img.Comment,
|
||||
|
@ -89,7 +89,9 @@ func (mf *v1ManifestFetcher) fetchWithSession(ctx context.Context, askedTag stri
|
||||
return nil, fmt.Errorf("No tags available for remote repository %s", mf.repoInfo.FullName())
|
||||
}
|
||||
|
||||
tagList := []string{}
|
||||
for tag, id := range tagsList {
|
||||
tagList = append(tagList, tag)
|
||||
repoData.ImgList[id] = ®istry.ImgData{
|
||||
ID: id,
|
||||
Tag: tag,
|
||||
@ -143,7 +145,7 @@ func (mf *v1ManifestFetcher) fetchWithSession(ctx context.Context, askedTag stri
|
||||
return nil, fmt.Errorf("No such image %s:%s", mf.repoInfo.FullName(), askedTag)
|
||||
}
|
||||
|
||||
return makeImageInspect(mf.repoInfo, pulledImg, askedTag, ""), nil
|
||||
return makeImageInspect(mf.repoInfo, pulledImg, askedTag, tagList, ""), nil
|
||||
}
|
||||
|
||||
func (mf *v1ManifestFetcher) pullImageJSON(imgID, endpoint string, token []string) (*image.Image, error) {
|
||||
|
@ -62,6 +62,7 @@ func (mf *v2ManifestFetcher) fetchWithRepository(ctx context.Context, ref refere
|
||||
var (
|
||||
manifest distribution.Manifest
|
||||
tagOrDigest string // Used for logging/progress only
|
||||
tagList = []string{}
|
||||
|
||||
tag string
|
||||
)
|
||||
@ -71,6 +72,15 @@ func (mf *v2ManifestFetcher) fetchWithRepository(ctx context.Context, ref refere
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tagList, err = mf.repo.Tags(ctx).All(ctx)
|
||||
if err != nil {
|
||||
return nil, allowV1Fallback(err)
|
||||
}
|
||||
// The v2 registry knows about this repository, so we will not
|
||||
// allow fallback to the v1 protocol even if we encounter an
|
||||
// error later on.
|
||||
mf.confirmedV2 = true
|
||||
|
||||
if digested, isDigested := ref.(reference.Canonical); isDigested {
|
||||
manifest, err = manSvc.Get(ctx, digested.Digest())
|
||||
if err != nil {
|
||||
@ -82,16 +92,6 @@ func (mf *v2ManifestFetcher) fetchWithRepository(ctx context.Context, ref refere
|
||||
tagOrDigest = tagged.Tag()
|
||||
tag = tagOrDigest
|
||||
} else {
|
||||
tagList, err := mf.repo.Tags(ctx).All(ctx)
|
||||
if err != nil {
|
||||
return nil, allowV1Fallback(err)
|
||||
}
|
||||
|
||||
// The v2 registry knows about this repository, so we will not
|
||||
// allow fallback to the v1 protocol even if we encounter an
|
||||
// error later on.
|
||||
mf.confirmedV2 = true
|
||||
|
||||
for _, t := range tagList {
|
||||
if t == reference.DefaultTag {
|
||||
tag = t
|
||||
@ -146,7 +146,7 @@ func (mf *v2ManifestFetcher) fetchWithRepository(ctx context.Context, ref refere
|
||||
return nil, errors.New("unsupported manifest format")
|
||||
}
|
||||
|
||||
return makeImageInspect(mf.repoInfo, image, tag, manifestDigest), nil
|
||||
return makeImageInspect(mf.repoInfo, image, tag, tagList, manifestDigest), nil
|
||||
}
|
||||
|
||||
func (mf *v2ManifestFetcher) pullSchema1(ctx context.Context, ref reference.Named, unverifiedManifest *schema1.SignedManifest) (img *image.Image, manifestDigest digest.Digest, err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user