Skip to content

Commit 382509f

Browse files
committed
remove vpcID and subnetID from the command line arguments and specify vpcID and subnetID through the parameters field in the CSI object
1 parent c3436ce commit 382509f

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

pkg/config/config.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,10 @@ type TencentCloudConfig struct {
6868
SecretID string
6969
// Secret Key of Tencent Cloud
7070
SecretKey string
71-
// VpcID used in TencentCloud CFS storage
72-
VpcID string
73-
// SubnetID used in TencentCloud CFS storage
74-
SubnetID string
7571
}
7672

7773
// AddFlags add the TencentCloud configurations to global flag.
7874
func (c *TencentCloudConfig) AddFlags() {
7975
flag.StringVar(&c.SecretID, "tencent-cloud-secret-id", "admin", "API Secret ID of Tencent Cloud")
8076
flag.StringVar(&c.SecretKey, "tencent-cloud-secret-key", "admin", "API Secret Key of Tencent Cloud")
81-
flag.StringVar(&c.VpcID, "tencent-cloud-cfs-vpc-id", "vpc-xxxxxxxx", "VpcID used in TencentCloud CFS storage")
82-
flag.StringVar(&c.SubnetID, "tencent-cloud-cfs-subnet-id", "subnet-xxxxxxxx", "SubnetID used in TencentCloud CFS storage")
8377
}

pkg/controller/csi/enhancer/tencentCloud.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package enhancer
2020
import (
2121
"encoding/base64"
2222
"fmt"
23+
2324
csiv1 "tkestack.io/csi-operator/pkg/apis/storage/v1"
2425
"tkestack.io/csi-operator/pkg/config"
2526
"tkestack.io/csi-operator/pkg/types"
@@ -331,26 +332,26 @@ func (e *tencentCloudEnhancer) getTencentInfo(csiDeploy *csiv1.CSI) (*tencentClo
331332
secretKey = e.config.SecretKey
332333
}
333334

334-
vpcID := csiDeploy.Spec.Parameters[vpcID]
335-
if len(vpcID) == 0 {
336-
vpcID = e.config.VpcID
335+
if len(secretID) == 0 || len(secretKey) == 0 {
336+
return nil, fmt.Errorf("no tencent info of secretID, secretKey in csiDeploy.Spec.Parameters: %v", csiDeploy.Spec.Parameters)
337337
}
338338

339+
vpcID := csiDeploy.Spec.Parameters[vpcID]
340+
339341
subnetID := csiDeploy.Spec.Parameters[subnetID]
340-
if len(subnetID) == 0 {
341-
subnetID = e.config.SubnetID
342-
}
343342

344-
if len(secretID) > 0 && len(secretKey) > 0 && len(subnetID) > 0 && len(vpcID) > 0 {
345-
return &tencentCloudInfo{
346-
SecretID: secretID,
347-
SecretKey: secretKey,
348-
VpcID: vpcID,
349-
SubnetID: subnetID,
350-
}, nil
343+
if csiDeploy.Spec.DriverName == csiv1.CSIDriverTencentCFS {
344+
if len(vpcID) == 0 || len(subnetID) == 0 {
345+
return nil, fmt.Errorf("no tencent info of vpcID, subnetID in csiDeploy.Spec.Parameters: %v", csiDeploy.Spec.Parameters)
346+
}
351347
}
352348

353-
return nil, fmt.Errorf("no tencent info of secretID, secretKey, vpcID or subnetID found in csiDeploy.Spec.Parameters: %v", csiDeploy.Spec.Parameters)
349+
return &tencentCloudInfo{
350+
SecretID: secretID,
351+
SecretKey: secretKey,
352+
VpcID: vpcID,
353+
SubnetID: subnetID,
354+
}, nil
354355
}
355356

356357
// generateCBSSecretAndSCs generates secrets and StorageClasses needed by TencentCloud CBS storage.

0 commit comments

Comments
 (0)