|
|
@ -20,6 +20,7 @@ import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/google/go-containerregistry/pkg/authn"
|
|
|
|
"github.com/google/go-containerregistry/pkg/crane"
|
|
|
|
"github.com/google/go-containerregistry/pkg/crane"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/fluxcd/pkg/auth"
|
|
|
|
"github.com/fluxcd/pkg/auth"
|
|
|
@ -28,14 +29,14 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// loginWithProvider gets a crane authentication option for the given provider and URL.
|
|
|
|
// loginWithProvider gets a crane authentication option for the given provider and URL.
|
|
|
|
func loginWithProvider(ctx context.Context, url, provider string) (crane.Option, error) {
|
|
|
|
func loginWithProvider(ctx context.Context, url, provider string) (crane.Option, authn.Authenticator, error) {
|
|
|
|
var opts []auth.Option
|
|
|
|
var opts []auth.Option
|
|
|
|
if provider == azure.ProviderName {
|
|
|
|
if provider == azure.ProviderName {
|
|
|
|
opts = append(opts, auth.WithAllowShellOut())
|
|
|
|
opts = append(opts, auth.WithAllowShellOut())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
authenticator, err := authutils.GetArtifactRegistryCredentials(ctx, provider, url, opts...)
|
|
|
|
authenticator, err := authutils.GetArtifactRegistryCredentials(ctx, provider, url, opts...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("could not login to provider %s with url %s: %w", provider, url, err)
|
|
|
|
return nil, nil, fmt.Errorf("could not login to provider %s with url %s: %w", provider, url, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return crane.WithAuth(authenticator), nil
|
|
|
|
return crane.WithAuth(authenticator), authenticator, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|