|
|
@ -19,7 +19,6 @@ package main
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
@ -34,9 +33,6 @@ import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"sigs.k8s.io/yaml"
|
|
|
|
"sigs.k8s.io/yaml"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/fluxcd/pkg/auth"
|
|
|
|
|
|
|
|
"github.com/fluxcd/pkg/auth/azure"
|
|
|
|
|
|
|
|
authutils "github.com/fluxcd/pkg/auth/utils"
|
|
|
|
|
|
|
|
"github.com/fluxcd/pkg/oci"
|
|
|
|
"github.com/fluxcd/pkg/oci"
|
|
|
|
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
|
|
|
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
|
|
|
|
|
|
|
|
|
|
@ -229,18 +225,11 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
|
|
|
|
|
|
|
|
|
|
|
|
if provider := pushArtifactArgs.provider.String(); provider != sourcev1.GenericOCIProvider {
|
|
|
|
if provider := pushArtifactArgs.provider.String(); provider != sourcev1.GenericOCIProvider {
|
|
|
|
logger.Actionf("logging in to registry with provider credentials")
|
|
|
|
logger.Actionf("logging in to registry with provider credentials")
|
|
|
|
var authOpts []auth.Option
|
|
|
|
authOpt, err := loginWithProvider(ctx, url, provider)
|
|
|
|
if provider == azure.ProviderName {
|
|
|
|
|
|
|
|
authOpts = append(authOpts, auth.WithAllowShellOut())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
authenticator, err = authutils.GetArtifactRegistryCredentials(ctx, provider, url, authOpts...)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("error during login with provider: %w", err)
|
|
|
|
return fmt.Errorf("error during login with provider: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if authenticator == nil {
|
|
|
|
opts = append(opts, authOpt)
|
|
|
|
return errors.New("unsupported provider")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
opts = append(opts, crane.WithAuth(authenticator))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if rootArgs.timeout != 0 {
|
|
|
|
if rootArgs.timeout != 0 {
|
|
|
|