mirror of https://github.com/containers/podman.git
auto update: fix authfile detection
Fix a bug were an authfile label in a container would mistakenly override the authfile path for all subsequent checks. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
parent
db26e1ef94
commit
eda8d1f584
|
@ -165,8 +165,8 @@ func AutoUpdate(runtime *libpod.Runtime, options Options) ([]string, []error) {
|
||||||
if rawImageName == "" {
|
if rawImageName == "" {
|
||||||
errs = append(errs, errors.Errorf("error registry auto-updating container %q: raw-image name is empty", cid))
|
errs = append(errs, errors.Errorf("error registry auto-updating container %q: raw-image name is empty", cid))
|
||||||
}
|
}
|
||||||
readAuthenticationPath(registryCtr, options)
|
authfile := getAuthfilePath(registryCtr, options)
|
||||||
needsUpdate, err := newerRemoteImageAvailable(runtime, image, rawImageName, options)
|
needsUpdate, err := newerRemoteImageAvailable(runtime, image, rawImageName, authfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, errors.Wrapf(err, "error registry auto-updating container %q: image check for %q failed", cid, rawImageName))
|
errs = append(errs, errors.Wrapf(err, "error registry auto-updating container %q: image check for %q failed", cid, rawImageName))
|
||||||
continue
|
continue
|
||||||
|
@ -280,18 +280,20 @@ func imageContainersMap(runtime *libpod.Runtime) (map[string]policyMapper, []err
|
||||||
return containerMap, errors
|
return containerMap, errors
|
||||||
}
|
}
|
||||||
|
|
||||||
// readAuthenticationPath reads a container's labels and reads authentication path into options
|
// getAuthfilePath returns an authfile path, if set. The authfile label in the
|
||||||
func readAuthenticationPath(ctr *libpod.Container, options Options) {
|
// container, if set, as precedence over the one set in the options.
|
||||||
|
func getAuthfilePath(ctr *libpod.Container, options Options) string {
|
||||||
labels := ctr.Labels()
|
labels := ctr.Labels()
|
||||||
authFilePath, exists := labels[AuthfileLabel]
|
authFilePath, exists := labels[AuthfileLabel]
|
||||||
if exists {
|
if exists {
|
||||||
options.Authfile = authFilePath
|
return authFilePath
|
||||||
}
|
}
|
||||||
|
return options.Authfile
|
||||||
}
|
}
|
||||||
|
|
||||||
// newerRemoteImageAvailable returns true if there corresponding image on the remote
|
// newerRemoteImageAvailable returns true if there corresponding image on the remote
|
||||||
// registry is newer.
|
// registry is newer.
|
||||||
func newerRemoteImageAvailable(runtime *libpod.Runtime, img *libimage.Image, origName string, options Options) (bool, error) {
|
func newerRemoteImageAvailable(runtime *libpod.Runtime, img *libimage.Image, origName string, authfile string) (bool, error) {
|
||||||
remoteRef, err := docker.ParseReference("//" + origName)
|
remoteRef, err := docker.ParseReference("//" + origName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -303,7 +305,9 @@ func newerRemoteImageAvailable(runtime *libpod.Runtime, img *libimage.Image, ori
|
||||||
}
|
}
|
||||||
|
|
||||||
sys := runtime.SystemContext()
|
sys := runtime.SystemContext()
|
||||||
sys.AuthFilePath = options.Authfile
|
if authfile != "" {
|
||||||
|
sys.AuthFilePath = authfile
|
||||||
|
}
|
||||||
|
|
||||||
// We need to account for the arch that the image uses. It seems
|
// We need to account for the arch that the image uses. It seems
|
||||||
// common on ARM to tweak this option to pull the correct image. See
|
// common on ARM to tweak this option to pull the correct image. See
|
||||||
|
|
Loading…
Reference in New Issue