5
5
"errors"
6
6
"fmt"
7
7
"net/http"
8
- "os"
9
8
"strings"
10
9
"sync"
11
10
@@ -22,8 +21,6 @@ import (
22
21
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
23
22
autorestazure "github.com/Azure/go-autorest/autorest/azure"
24
23
"github.com/Azure/go-autorest/autorest/to"
25
- "github.com/Azure/msi-dataplane/pkg/dataplane"
26
- "k8s.io/klog/v2"
27
24
)
28
25
29
26
const (
@@ -97,7 +94,7 @@ func New(opts *Options) (*Client, error) {
97
94
}, nil
98
95
}
99
96
100
- func (c * Client ) getCreds (ctx context.Context ) (azcore.TokenCredential , error ) {
97
+ func (c * Client ) getCreds (_ context.Context ) (azcore.TokenCredential , error ) {
101
98
if c .creds != nil {
102
99
return c .creds , nil
103
100
}
@@ -106,29 +103,7 @@ func (c *Client) getCreds(ctx context.Context) (azcore.TokenCredential, error) {
106
103
err error
107
104
creds azcore.TokenCredential
108
105
)
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 ) == "" {
132
107
options := azidentity.WorkloadIdentityCredentialOptions {
133
108
ClientOptions : * c .clientOpts ,
134
109
ClientID : c .opts .ClientID ,
@@ -154,7 +129,7 @@ func (c *Client) getCreds(ctx context.Context) (azcore.TokenCredential, error) {
154
129
}
155
130
}
156
131
if creds == nil {
157
- return nil , errors .New ("Unknown authentication method" )
132
+ return nil , errors .New ("unknown authentication method" )
158
133
}
159
134
c .creds = creds
160
135
return c .creds , nil
0 commit comments