in cmd/acr/annotate.go [216:270]
func getManifestsToAnnotate(ctx context.Context,
acrClient api.AcrCLIClientInterface,
orasClient api.ORASClientInterface,
loginURL string,
repoName string,
filter *regexp2.Regexp,
lastTag string, artifactType string, dryRun bool) (*[]string, string, error) {
resultTags, err := acrClient.GetAcrTags(ctx, repoName, "timedesc", lastTag)
if err != nil {
if resultTags != nil && resultTags.Response.Response != nil && resultTags.StatusCode == http.StatusNotFound {
fmt.Printf("%s repository not found\n", repoName)
return nil, "", nil
}
return nil, "", err
}
newLastTag := ""
if resultTags != nil && resultTags.TagsAttributes != nil && len(*resultTags.TagsAttributes) > 0 {
tags := *resultTags.TagsAttributes
manifestsToAnnotate := []string{}
for _, tag := range tags {
matches, err := filter.MatchString(*tag.Name)
if err != nil {
// The only error that regexp2 will return is a timeout error
return nil, "", err
}
if !matches {
// If a tag does not match the regex then it's not added to the list
continue
}
// If a tag is changable, then it is returned as a tag to annotate
if *tag.ChangeableAttributes.WriteEnabled {
ref := fmt.Sprintf("%s/%s:%s", loginURL, repoName, *tag.Name)
skip, err := orasClient.DiscoverLifecycleAnnotation(ctx, ref, artifactType)
if err != nil {
return nil, "", err
}
if !skip {
// Only print what would be annotated during a dry-run. Successfully annotated manifests
// will be logged after the annotation.
if dryRun {
fmt.Printf("%s/%s:%s\n", loginURL, repoName, *tag.Name)
}
manifestsToAnnotate = append(manifestsToAnnotate, *tag.Digest)
}
}
}
newLastTag = common.GetLastTagFromResponse(resultTags)
return &manifestsToAnnotate, newLastTag, nil
}
return nil, "", nil
}