Skip to content

Commit

Permalink
Merge pull request #15 from castai/fix-username-password-auth
Browse files Browse the repository at this point in the history
Fix username/password auth
  • Loading branch information
anjmao authored Apr 30, 2024
2 parents 4a32152 + e516689 commit 98111c4
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 98111c4

Please sign in to comment.