From abfa0a5b67c194ad1d745e85ca3de98012eb980a Mon Sep 17 00:00:00 2001 From: Siye Wang Date: Wed, 9 Oct 2024 16:46:31 +0800 Subject: [PATCH] PANDARIA: Add aliyun credential --- extensions/cloudcredentials/cloudcredentials.go | 10 +++++++++- extensions/clusters/ack/ack_cluster_config.go | 5 +---- extensions/clusters/ack/create.go | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/cloudcredentials/cloudcredentials.go b/extensions/cloudcredentials/cloudcredentials.go index 772f37f8..7061311d 100644 --- a/extensions/cloudcredentials/cloudcredentials.go +++ b/extensions/cloudcredentials/cloudcredentials.go @@ -103,7 +103,7 @@ func LoadCloudCredential(provider string) CloudCredential { cloudCredential.HuaweiCredentialConfig = &huaweiCredentialConfig return cloudCredential - + case provider == providers.Tencent: var tkeCredentialConfig TencentCredentialConfig @@ -112,6 +112,14 @@ func LoadCloudCredential(provider string) CloudCredential { return cloudCredential + case provider == providers.Aliyun: + var aliyunECSCredentialConfig AliyunECSCredentialConfig + + config.LoadConfig(AliyunECSCredentialConfigurationFileKey, &aliyunECSCredentialConfig) + cloudCredential.AliyunECSCredentialConfig = &aliyunECSCredentialConfig + + return cloudCredential + default: panic(fmt.Sprintf("Provider:%v not found", provider)) } diff --git a/extensions/clusters/ack/ack_cluster_config.go b/extensions/clusters/ack/ack_cluster_config.go index 6c53ba89..e3543f15 100644 --- a/extensions/clusters/ack/ack_cluster_config.go +++ b/extensions/clusters/ack/ack_cluster_config.go @@ -2,7 +2,6 @@ package ack import ( management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" - "github.com/rancher/shepherd/pkg/config" ) const ( @@ -118,9 +117,7 @@ func ackNodePoolConstructor(ackNodePoolConfigs *[]NodePoolInfo) []management.Nod return ackNodePools } -func HostClusterConfig(displayName, cloudCredentialID string) *management.ACKClusterConfigSpec { - var ackClusterConfig ClusterConfig - config.LoadConfig(ACKClusterConfigConfigurationFileKey, &ackClusterConfig) +func HostClusterConfig(displayName, cloudCredentialID string, ackClusterConfig ClusterConfig) *management.ACKClusterConfigSpec { return &management.ACKClusterConfigSpec{ Name: displayName, diff --git a/extensions/clusters/ack/create.go b/extensions/clusters/ack/create.go index 4f5dcde4..5f721757 100644 --- a/extensions/clusters/ack/create.go +++ b/extensions/clusters/ack/create.go @@ -6,8 +6,8 @@ import ( ) // CreateACKHostedCluster is a helper function that creates an ACK hosted cluster. -func CreateACKHostedCluster(client *rancher.Client, displayName, cloudCredentialID string, enableClusterAlerting, enableClusterMonitoring, enableNetworkPolicy, windowsPreferedCluster bool, labels map[string]string) (*management.Cluster, error) { - ackHostCluster := HostClusterConfig(displayName, cloudCredentialID) +func CreateACKHostedCluster(client *rancher.Client, displayName, cloudCredentialID string, ackClusterConfig ClusterConfig, enableClusterAlerting, enableClusterMonitoring, enableNetworkPolicy, windowsPreferedCluster bool, labels map[string]string) (*management.Cluster, error) { + ackHostCluster := HostClusterConfig(displayName, cloudCredentialID, ackClusterConfig) cluster := &management.Cluster{ ACKConfig: ackHostCluster, DockerRootDir: "/var/lib/docker",