1
0
mirror of https://github.com/containers/podman.git synced 2026-02-05 15:45:08 +01:00

auto update: fix usage of --authfile

The --authfile flag has been ignored.  Fix that and add a test to make
sure we won't regress another time.  Requires a new --tls-verify flag
to actually test the code.

Also bump c/common since common/pull/1538 is required to correctly check
for updates.  Note that I had to use the go-mod-edit-replace trick on
c/common as c/buildah would otherwise be moved back to 1.30.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2218315
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-06-29 11:34:49 +02:00
parent 10615e784b
commit d874790bc6
12 changed files with 117 additions and 13 deletions

View File

@@ -282,7 +282,10 @@ func (t *task) registryUpdateAvailable(ctx context.Context) (bool, error) {
if err != nil {
return false, err
}
options := &libimage.HasDifferentDigestOptions{AuthFilePath: t.authfile}
options := &libimage.HasDifferentDigestOptions{
AuthFilePath: t.authfile,
InsecureSkipTLSVerify: t.auto.options.InsecureSkipTLSVerify,
}
return t.image.HasDifferentDigest(ctx, remoteRef, options)
}
@@ -296,6 +299,7 @@ func (t *task) registryUpdate(ctx context.Context) error {
pullOptions := &libimage.PullOptions{}
pullOptions.AuthFilePath = t.authfile
pullOptions.Writer = os.Stderr
pullOptions.InsecureSkipTLSVerify = t.auto.options.InsecureSkipTLSVerify
if _, err := t.auto.runtime.LibimageRuntime().Pull(ctx, t.rawImageName, config.PullPolicyAlways, pullOptions); err != nil {
return err
}
@@ -416,8 +420,14 @@ func (u *updater) assembleTasks(ctx context.Context) []error {
continue
}
// Use user-specified auth file (CLI or env variable) unless
// the container was created with the auth-file label.
authfile := u.options.Authfile
if fromContainer, ok := labels[define.AutoUpdateAuthfileLabel]; ok {
authfile = fromContainer
}
t := task{
authfile: labels[define.AutoUpdateAuthfileLabel],
authfile: authfile,
auto: u,
container: ctr,
policy: policy,