diff options
| author | jannfis <jann@mistrust.net> | 2021-06-15 09:56:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-15 09:56:21 +0200 |
| commit | 1d19e6a2f5dc5658c4c6539cf8a4518a1233bb4e (patch) | |
| tree | dfcaeb922875d5245f447c6225dbaeafa7b582cb /pkg | |
| parent | 45e648658e53839f9a2d86cd443fb7a98ddaf86b (diff) | |
fix: Fix a possible race condition in metadata retrieval (#215)
Signed-off-by: jannfis <jann@mistrust.net>
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/registry/registry.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index ecd4053..e39f0d3 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -28,7 +28,6 @@ const ( // GetTags returns a list of available tags for the given image func (endpoint *RegistryEndpoint) GetTags(img *image.ContainerImage, regClient RegistryClient, vc *image.VersionConstraint) (*tag.ImageTagList, error) { var tagList *tag.ImageTagList = tag.NewImageTagList() - var imgTag *tag.ImageTag var err error // Some registries have a default namespace that is used when the image name @@ -76,7 +75,7 @@ func (endpoint *RegistryEndpoint) GetTags(img *image.ContainerImage, regClient R } else if endpoint.TagListSort == SortLatestLast { ts = i } - imgTag = tag.NewImageTag(tagStr, time.Unix(int64(ts), 0), "") + imgTag := tag.NewImageTag(tagStr, time.Unix(int64(ts), 0), "") tagList.Add(imgTag) } return tagList, nil @@ -97,7 +96,7 @@ func (endpoint *RegistryEndpoint) GetTags(img *image.ContainerImage, regClient R // an error, we treat it as a cache miss and just go ahead to invalidate // the entry. if vc.SortMode.IsCacheable() { - imgTag, err = endpoint.Cache.GetTag(nameInRegistry, tagStr) + imgTag, err := endpoint.Cache.GetTag(nameInRegistry, tagStr) if err != nil { log.Warnf("invalid entry for %s:%s in cache, invalidating.", nameInRegistry, imgTag.TagName) } else if imgTag != nil { @@ -153,7 +152,7 @@ func (endpoint *RegistryEndpoint) GetTags(img *image.ContainerImage, regClient R } log.Tracef("Found date %s", ti.CreatedAt.String()) - + var imgTag *tag.ImageTag if vc.SortMode == image.VersionSortDigest { imgTag = tag.NewImageTag(tagStr, ti.CreatedAt, fmt.Sprintf("sha256:%x", ti.Digest)) } else { |
