summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@redhat.com>2022-08-03 13:37:06 +0200
committerValentin Rothberg <vrothberg@redhat.com>2022-08-04 13:07:58 +0200
commit42c4c17c01af746cd1424878a397cb6eeb9c65dd (patch)
tree1917f76fe4325269bf2dfd65819d0d7846753106
parent3f1928d76714e6cd11a4036b2b99b897937e0586 (diff)
downloadpodman-42c4c17c01af746cd1424878a397cb6eeb9c65dd.tar.gz
podman-42c4c17c01af746cd1424878a397cb6eeb9c65dd.tar.bz2
podman-42c4c17c01af746cd1424878a397cb6eeb9c65dd.zip
pkg/autoupdate: move authfile into `tasks`
Will simplify the code and speed up things as we do not consult a container's labels multiple times. [NO NEW TESTS NEEDED] - should not change behavior. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
-rw-r--r--pkg/autoupdate/autoupdate.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go
index e892ad301..89d0a1ac3 100644
--- a/pkg/autoupdate/autoupdate.go
+++ b/pkg/autoupdate/autoupdate.go
@@ -62,6 +62,7 @@ type updater struct {
// task includes data and state for updating a container
type task struct {
+ authfile string // Container-specific authfile
auto *updater // Reverse pointer to the updater
container *libpod.Container // Container to update
policy Policy // Update policy
@@ -244,8 +245,7 @@ func (t *task) updateRegistry(ctx context.Context) (*entities.AutoUpdateReport,
return report, nil
}
- authfile := getAuthfilePath(t.container, t.auto.options)
- needsUpdate, err := newerRemoteImageAvailable(ctx, t.image, rawImageName, authfile)
+ needsUpdate, err := newerRemoteImageAvailable(ctx, t.image, rawImageName, t.authfile)
if err != nil {
return report, fmt.Errorf("registry auto-updating container %q: image check for %q failed: %w", cid, rawImageName, err)
}
@@ -260,7 +260,7 @@ func (t *task) updateRegistry(ctx context.Context) (*entities.AutoUpdateReport,
return report, nil
}
- if _, err := pullImage(ctx, t.auto.runtime, rawImageName, authfile); err != nil {
+ if _, err := pullImage(ctx, t.auto.runtime, rawImageName, t.authfile); err != nil {
return report, fmt.Errorf("registry auto-updating container %q: image update for %q failed: %w", cid, rawImageName, err)
}
t.auto.updatedRawImages[rawImageName] = true
@@ -432,6 +432,7 @@ func (u *updater) assembleTasks(ctx context.Context) []error {
}
t := task{
+ authfile: labels[AuthfileLabel],
auto: u,
container: ctr,
policy: policy,
@@ -446,17 +447,6 @@ func (u *updater) assembleTasks(ctx context.Context) []error {
return errors
}
-// getAuthfilePath returns an authfile path, if set. The authfile label in the
-// container, if set, as precedence over the one set in the options.
-func getAuthfilePath(ctr *libpod.Container, options *entities.AutoUpdateOptions) string {
- labels := ctr.Labels()
- authFilePath, exists := labels[AuthfileLabel]
- if exists {
- return authFilePath
- }
- return options.Authfile
-}
-
// newerRemoteImageAvailable returns true if there corresponding image on the remote
// registry is newer.
func newerRemoteImageAvailable(ctx context.Context, img *libimage.Image, origName string, authfile string) (bool, error) {