Skip to content

Commit

Permalink
Fix username/password auth
Browse files Browse the repository at this point in the history
  • Loading branch information
anjmao committed Apr 30, 2024
1 parent 4a32152 commit e516689
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions image/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@ func NewFromRemote(ctx context.Context, imageName string, option types.ImageOpti
}

func tryRemote(ctx context.Context, imageName string, ref name.Reference, option types.ImageOptions) (ImageWithIndex, error) {
var remoteOpts []remote.Option
remoteOpts := []remote.Option{
remote.WithContext(ctx),
}
if option.RegistryOptions.Insecure {
t := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
}
remoteOpts = append(remoteOpts, remote.WithTransport(t))
}
remoteOpts = append(remoteOpts, remote.WithContext(ctx))

// Username/Password based auth.
for _, cred := range option.RegistryOptions.Credentials {
remoteOpts = append(remoteOpts, remote.WithAuth(&authn.Basic{
Username: cred.Username,
Password: cred.Password,
}))
}

domain := ref.Context().RegistryStr()
auth := registry.GetToken(ctx, domain, option.RegistryOptions)
Expand Down

0 comments on commit e516689

Please sign in to comment.