Skip to content

Commit 0a58142

Browse files
authored
Merge pull request #1536 from huww98/passthrough-scheme
passthrough ALICLOUD_CLIENT_SCHEME
2 parents 71bb530 + bad464b commit 0a58142

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

pkg/bmcpfs/controllerserver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ func newEfloClient(region string) (*efloclient.Client, error) {
204204
config = config.SetEndpoint(fmt.Sprintf("eflo-controller-vpc.%s.aliyuncs.com", region))
205205
}
206206
// set protocol
207-
scheme := strings.ToUpper(os.Getenv("ALICLOUD_CLIENT_SCHEME"))
207+
scheme := "HTTPS"
208208
if strings.Contains(region, "test") {
209209
// must use HTTP in lingjun test regions
210210
scheme = "HTTP"
211211
}
212-
if scheme != "HTTP" {
213-
scheme = "HTTPS"
212+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
213+
scheme = e
214214
}
215215
config = config.SetProtocol(scheme)
216216
// init client

pkg/disk/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ var ecsEndpointOnce sync.Once
118118

119119
func newEcsClient(regionID string, cred credentials.CredentialsProvider) (ecsClient *ecs.Client) {
120120
scheme := "HTTPS"
121-
if os.Getenv("ALICLOUD_CLIENT_SCHEME") == "HTTP" {
122-
scheme = "HTTP"
121+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
122+
scheme = e
123123
}
124124
config := sdk.NewConfig().WithScheme(scheme).WithUserAgent(KubernetesAlicloudIdentity)
125125

pkg/nas/cloud/nas_client_v1.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66
"os"
7-
"strings"
87

98
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
109
aliyunep "github.com/aliyun/alibaba-cloud-sdk-go/sdk/endpoints"
@@ -34,9 +33,9 @@ func newNasClientV1(region string) (interfaces.NasV1Interface, error) {
3433
if config == nil {
3534
config = sdk.NewConfig()
3635
}
37-
scheme := strings.ToUpper(os.Getenv("ALICLOUD_CLIENT_SCHEME"))
38-
if scheme != "HTTP" {
39-
scheme = "HTTPS"
36+
scheme := "HTTPS"
37+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
38+
scheme = e
4039
}
4140
config = config.WithScheme(scheme).WithUserAgent(KubernetesAlicloudIdentity)
4241
headers := utilshttp.MustParseHeaderEnv("NAS_HEADERS")

pkg/nas/cloud/nas_client_v2.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66
"os"
7-
"strings"
87

98
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
109
sdk "github.com/alibabacloud-go/nas-20170626/v4/client"
@@ -49,9 +48,9 @@ func NewNasClientV2(region string) (*sdk.Client, error) {
4948
}
5049
config = config.SetEndpoint(ep)
5150
// set protocol
52-
scheme := strings.ToUpper(os.Getenv("ALICLOUD_CLIENT_SCHEME"))
53-
if scheme != "HTTP" {
54-
scheme = "HTTPS"
51+
scheme := "HTTPS"
52+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
53+
scheme = e
5554
}
5655
config = config.SetProtocol(scheme)
5756
// init client

pkg/utils/auth.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func ValidatePath(path string) (bool, error) {
9393
func getManagedAddonToken() AccessControl {
9494
tokens := getManagedToken()
9595
scheme := "https"
96-
if os.Getenv("ALICLOUD_CLIENT_SCHEME") == "HTTP" {
97-
scheme = "http"
96+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
97+
scheme = e
9898
}
9999
config := sdk.NewConfig().WithScheme(scheme)
100100
credent := &cre.StsTokenCredential{
@@ -146,8 +146,8 @@ func GetEnvAK() AccessControl {
146146
accessSecret = os.Getenv("ACCESS_KEY_SECRET")
147147

148148
scheme := "https"
149-
if os.Getenv("ALICLOUD_CLIENT_SCHEME") == "HTTP" {
150-
scheme = "http"
149+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
150+
scheme = e
151151
}
152152
config := sdk.NewConfig().WithScheme(scheme)
153153

@@ -161,8 +161,8 @@ func GetEnvAK() AccessControl {
161161
// GetStsToken get STS token and token from ecs meta server
162162
func getStsToken() AccessControl {
163163
scheme := "https"
164-
if os.Getenv("ALICLOUD_CLIENT_SCHEME") == "HTTP" {
165-
scheme = "http"
164+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
165+
scheme = e
166166
}
167167
config := sdk.NewConfig().WithScheme(scheme)
168168
return AccessControl{UseMode: Credential, Config: config, Credential: cre.NewEcsRamRoleCredential("")}
@@ -202,8 +202,8 @@ func getCredentialAK() AccessControl {
202202
}
203203
}
204204
scheme := "https"
205-
if os.Getenv("ALICLOUD_CLIENT_SCHEME") == "HTTP" {
206-
scheme = "http"
205+
if e := os.Getenv("ALICLOUD_CLIENT_SCHEME"); e != "" {
206+
scheme = e
207207
}
208208
config := sdk.NewConfig().WithScheme(scheme)
209209
return AccessControl{Config: config, Credential: credential, UseMode: Credential}

0 commit comments

Comments
 (0)