func()

in tooling/image-sync/internal/repository.go [117:144]


func (q *QuayRegistry) GetTags(ctx context.Context, image string) ([]string, error) {
	Log().Debugw("Getting tags for image", "image", image)

	var tags []string
	hasAdditional := true

	// hard coded limit of 100, to make sure process does not get stuck
	for page := 1; len(tags) < q.numberOftags && hasAdditional && page < 100; page++ {
		tagsResponse, err := q.getTagPage(ctx, image, page)
		if err != nil {
			return nil, fmt.Errorf("failed to get tags: %v", err)
		}
		for _, tag := range tagsResponse.Tags {
			if tag.Name == "latest" {
				continue
			}
			tags = append(tags, tag.Name)
			// Check length again, cause pagesize might be way bigger than number of tags
			if len(tags) >= q.numberOftags {
				return tags, nil
			}
		}
		if !tagsResponse.HasAdditional {
			break
		}
	}
	return tags, nil
}