in internal/tag/tag.go [24:53]
func ListTags(ctx context.Context, acrClient api.AcrCLIClientInterface, repoName string) ([]acr.TagAttributesBase, error) {
lastTag := ""
resultTags, err := acrClient.GetAcrTags(ctx, repoName, "", lastTag)
if err != nil {
return nil, errors.Wrap(&ListTagsError{msg: "failed to list tags"}, err.Error())
}
var tagList []acr.TagAttributesBase
tagList = append(tagList, *resultTags.TagsAttributes...)
// A for loop is used because the GetAcrTags method returns by default only 100 tags and their attributes.
for resultTags != nil && resultTags.TagsAttributes != nil {
tags := *resultTags.TagsAttributes
// Since the GetAcrTags supports pagination when supplied with the last digest that was returned the last tag name
// digest is saved, the tag array contains at least one element because if it was empty the API would return
// a nil pointer instead of a pointer to a length 0 array.
lastTag = *tags[len(tags)-1].Name
resultTags, err = acrClient.GetAcrTags(ctx, repoName, "", lastTag)
if err != nil {
return nil, err
}
if resultTags != nil && resultTags.TagsAttributes != nil {
tagList = append(tagList, *resultTags.TagsAttributes...)
}
}
return tagList, nil
}