Skip to content

Commit

Permalink
auto update: minor style nits
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jul 13, 2021
1 parent a90a4ec commit 6fcf0b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 4 additions & 9 deletions pkg/autoupdate/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/systemd"
systemdDefine "github.com/containers/podman/v3/pkg/systemd/define"
"github.com/pkg/errors"
Expand Down Expand Up @@ -118,7 +119,7 @@ func ValidateImageReference(imageName string) error {
//
// It returns a slice of successfully restarted systemd units and a slice of
// errors encountered during auto update.
func AutoUpdate(ctx context.Context, runtime *libpod.Runtime, options Options) ([]string, []error) {
func AutoUpdate(ctx context.Context, runtime *libpod.Runtime, options Options) (*entities.AutoUpdateReport, []error) {
// Create a map from `image ID -> []*Container`.
containerMap, errs := imageContainersMap(runtime)
if len(containerMap) == 0 {
Expand Down Expand Up @@ -224,7 +225,7 @@ func AutoUpdate(ctx context.Context, runtime *libpod.Runtime, options Options) (
updatedUnits = append(updatedUnits, unit)
}

return updatedUnits, errs
return &entities.AutoUpdateReport{Units: updatedUnits}, errs
}

// imageContainersMap generates a map[image ID] -> [containers using the image]
Expand Down Expand Up @@ -297,7 +298,6 @@ func newerRemoteImageAvailable(ctx context.Context, runtime *libpod.Runtime, img
if err != nil {
return false, err
}

return img.HasDifferentDigest(ctx, remoteRef)
}

Expand All @@ -307,12 +307,7 @@ func newerLocalImageAvailable(runtime *libpod.Runtime, img *libimage.Image, rawI
if err != nil {
return false, err
}

localDigest := localImg.Digest().String()

ctrDigest := img.Digest().String()

return localDigest != ctrDigest, nil
return localImg.Digest().String() != img.Digest().String(), nil
}

// updateImage pulls the specified image.
Expand Down
3 changes: 1 addition & 2 deletions pkg/domain/infra/abi/auto-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ func (ic *ContainerEngine) AutoUpdate(ctx context.Context, options entities.Auto
// them in the entities package as low-level packages must not leak
// into the remote client.
autoOpts := autoupdate.Options{Authfile: options.Authfile}
units, failures := autoupdate.AutoUpdate(ctx, ic.Libpod, autoOpts)
return &entities.AutoUpdateReport{Units: units}, failures
return autoupdate.AutoUpdate(ctx, ic.Libpod, autoOpts)
}

0 comments on commit 6fcf0b2

Please sign in to comment.