1
0
mirror of synced 2026-02-13 13:06:56 +00:00

Fix flux push artifact not working with --provider

Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
This commit is contained in:
Matheus Pimenta
2025-10-01 08:01:19 +01:00
parent 66b8aca399
commit 039d79b3c2
6 changed files with 12 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ import (
"context"
"fmt"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/crane"
"github.com/fluxcd/pkg/auth"
@@ -28,14 +29,14 @@ import (
)
// 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
if provider == azure.ProviderName {
opts = append(opts, auth.WithAllowShellOut())
}
authenticator, err := authutils.GetArtifactRegistryCredentials(ctx, provider, url, opts...)
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
}