Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Natalie Arellano <narellano@vmware.com>
Co-authored-by: Ralf Pannemans <ralf.pannemans@googlemail.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent 989f1a1 commit f722312
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/builder/image_fetcher_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type ImageFetcher interface {
// attempt to pull a remote image first.
Fetch(ctx context.Context, name string, options image.FetchOptions) (imgutil.Image, error)

// CheckReadAccess verifies if an image accessible with read permissions
// CheckReadAccess verifies if an image is accessible with read permissions
// When FetchOptions.Daemon is true and the image doesn't exist in the daemon,
// the behavior is dictated by the pullPolicy, which can have the following behavior
// the behavior is dictated by the pull policy, which can have the following behavior
// - PullNever: returns false
// - PullAlways Or PullIfNotPResent: it will check read access for the remote image.
// - PullAlways Or PullIfNotPresent: it will check read access for the remote image.
// When FetchOptions.Daemon is false it will check read access for the remote image.
CheckReadAccess(repo string, options image.FetchOptions) bool
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ type ImageFetcher interface {

// CheckReadAccess verifies if an image is accessible with read permissions
// When FetchOptions.Daemon is true and the image doesn't exist in the daemon,
// the behavior is dictated by the pullPolicy, which can have the following behavior
// the behavior is dictated by the pull policy, which can have the following behavior
// - PullNever: returns false
// - PullAlways Or PullIfNotPResent: it will check read access for the remote image.
// - PullAlways Or PullIfNotPresent: it will check read access for the remote image.
// When FetchOptions.Daemon is false it will check read access for the remote image.
CheckReadAccess(repo string, options image.FetchOptions) bool
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/image/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,16 @@ func (f *Fetcher) CheckReadAccess(repo string, options FetchOptions) bool {
if _, err := f.fetchDaemonImage(repo); err != nil {
if errors.Is(err, ErrNotFound) {
// Image doesn't exist in the daemon
// Pull Never: should failed
// Pull Never: should fail
// Pull If Not Present: need to check the registry
if options.PullPolicy == PullNever {
return false
}
return f.checkRemoteReadAccess(repo)
}
f.logger.Debugf("failed reading image from the daemon %s, error: %s", repo, err.Error())
f.logger.Debugf("failed reading image %s from the daemon, error: %s", repo, err.Error())
return false
}
// no-op
return true
}

Expand Down

0 comments on commit f722312

Please sign in to comment.