Skip to content

Commit 3bdc326

Browse files
committed
WIP
1 parent b59ac0d commit 3bdc326

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

pkg/storage/azure/azureclient/azureclient.go

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"net/http"
8-
"os"
98
"strings"
109
"sync"
1110

@@ -22,8 +21,6 @@ import (
2221
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
2322
autorestazure "github.com/Azure/go-autorest/autorest/azure"
2423
"github.com/Azure/go-autorest/autorest/to"
25-
"github.com/Azure/msi-dataplane/pkg/dataplane"
26-
"k8s.io/klog/v2"
2724
)
2825

2926
const (
@@ -97,7 +94,7 @@ func New(opts *Options) (*Client, error) {
9794
}, nil
9895
}
9996

100-
func (c *Client) getCreds(ctx context.Context) (azcore.TokenCredential, error) {
97+
func (c *Client) getCreds(_ context.Context) (azcore.TokenCredential, error) {
10198
if c.creds != nil {
10299
return c.creds, nil
103100
}
@@ -106,29 +103,7 @@ func (c *Client) getCreds(ctx context.Context) (azcore.TokenCredential, error) {
106103
err error
107104
creds azcore.TokenCredential
108105
)
109-
userAssignedIdentityCredentialsFilePath := os.Getenv("MANAGED_AZURE_HCP_CREDENTIALS_FILE_PATH")
110-
if userAssignedIdentityCredentialsFilePath != "" {
111-
var ok bool
112-
113-
// We need to only store the Azure credentials once and reuse them after that.
114-
storedCreds, found := c.azureCredentials.Load(userAssignedIdentityCredentialsFilePath)
115-
if !found {
116-
klog.V(2).Info("Using UserAssignedIdentityCredentials for Azure authentication for managed Azure HCP")
117-
clientOptions := azcore.ClientOptions{
118-
Cloud: c.clientOpts.Cloud,
119-
}
120-
creds, err = dataplane.NewUserAssignedIdentityCredential(ctx, userAssignedIdentityCredentialsFilePath, dataplane.WithClientOpts(clientOptions))
121-
if err != nil {
122-
return nil, err
123-
}
124-
c.azureCredentials.Store(azureCredentialsKey, creds)
125-
} else {
126-
creds, ok = storedCreds.(azcore.TokenCredential)
127-
if !ok {
128-
return nil, fmt.Errorf("expected %T to be a TokenCredential", storedCreds)
129-
}
130-
}
131-
} else if strings.TrimSpace(c.opts.ClientSecret) == "" {
106+
if strings.TrimSpace(c.opts.ClientSecret) == "" {
132107
options := azidentity.WorkloadIdentityCredentialOptions{
133108
ClientOptions: *c.clientOpts,
134109
ClientID: c.opts.ClientID,
@@ -154,7 +129,7 @@ func (c *Client) getCreds(ctx context.Context) (azcore.TokenCredential, error) {
154129
}
155130
}
156131
if creds == nil {
157-
return nil, errors.New("Unknown authentication method")
132+
return nil, errors.New("unknown authentication method")
158133
}
159134
c.creds = creds
160135
return c.creds, nil

0 commit comments

Comments
 (0)