Skip to content

Commit 4d2f0bf

Browse files
author
jahan
committed
Use the override url if specified in the annotations
Signed-off-by: Jahan Syed <[email protected]>
1 parent ce06ad0 commit 4d2f0bf

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ enrich version checking on image tags:
100100
used to change the URL for where to lookup where the latest image version
101101
is. In this example, the current version of `my-container` will be compared
102102
against the image versions in the `docker.io/bitnami/etcd` registry.
103-
103+
- `resolve-sha-to-tags.version-checker.io/my-container`: is used to
104+
resolve images specified using sha256 in kubernetes manifests to valid semver
105+
tags. To enable this the annotation value must be set to "true".
104106

105107
## Metrics
106108

pkg/controller/checker/checker.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ func (c *Checker) Container(ctx context.Context, log *logrus.Entry,
4646
usingTag := len(currentTag) > 0
4747

4848
if opts.ResolveSHAToTags {
49-
fmt.Println("Resolving SHA to Tags is required")
49+
50+
if len(*opts.OverrideURL) > 0 {
51+
imageURL = *opts.OverrideURL
52+
}
5053
resolvedTag, err := c.search.ResolveSHAToTag(ctx, imageURL, currentSHA)
5154

52-
if len(resolvedTag) > 0 && err != nil {
53-
fmt.Println("Successfully resolved tag")
55+
if len(resolvedTag) > 0 && err == nil {
56+
log.Infof("Successfully resolved tag for sha256: %s at url: %s", currentSHA, imageURL)
5457
currentTag = resolvedTag
5558
usingSHA = false
56-
usingTag = true
59+
usingTag = true
5760
}
5861
}
5962

pkg/controller/search/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (s *Search) ResolveSHAToTag(ctx context.Context, imageURL string, imageSHA
7171

7272
tag, err := s.versionGetter.ResolveSHAToTag(ctx, imageURL, imageSHA)
7373
if err != nil {
74-
fmt.Println("failed to resolve the sha" + err.Error())
74+
fmt.Println("failed to resolve the sha " + err.Error())
7575
return "", fmt.Errorf("failed to resolve sha to tag")
7676
}
7777

0 commit comments

Comments
 (0)