Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Use credentials when checking to see if an image is remote #1923

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/controller/appdefinition/pullappimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func pullAppImage(transport http.RoundTripper, client pullClient) router.Handler
isLocal bool
)
// Only attempt to resolve locally if auto-upgrade is not on, or if auto-upgrade is on but we know the image is not remote.
if !autoUpgradeOn || !images.IsImageRemote(target, true, remote.WithTransport(transport)) {
if !autoUpgradeOn || !images.IsImageRemote(req.Ctx, req.Client, appInstance.Namespace, target, true, remote.WithTransport(transport)) {
resolved, isLocal, err = client.resolve(req.Ctx, req.Client, appInstance.Namespace, target)
if err != nil {
cond.Error(err)
Expand Down
7 changes: 6 additions & 1 deletion pkg/images/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func ResolveTag(tag imagename.Reference, image string) string {
// IsImageRemote checks the remote registry to see if the given image name exists.
// If noDefaultRegistry is true, and the image does not have a specified registry, this function will return false
// without attempting to check any remote registries.
func IsImageRemote(image string, noDefaultRegistry bool, opts ...remote.Option) bool {
func IsImageRemote(ctx context.Context, c client.Reader, namespace, image string, noDefaultRegistry bool, opts ...remote.Option) bool {
var (
ref imagename.Reference
err error
Expand All @@ -134,6 +134,11 @@ func IsImageRemote(image string, noDefaultRegistry bool, opts ...remote.Option)
return false
}

opts, err = GetAuthenticationRemoteOptions(ctx, c, namespace, opts...)
if err != nil {
return false
}

_, err = remote.Index(ref, opts...)

return err == nil
Expand Down