From 7f6d437c179f950c3714b7295a5471cd655b636f Mon Sep 17 00:00:00 2001 From: Qi Feng Huo Date: Thu, 21 Sep 2023 13:19:15 +0800 Subject: [PATCH] peerpod-ctl: Fix problem in LoadEnv in IBMCloud Provider Fixes: #1454 Signed-off-by: Qi Feng Huo --- peerpod-ctrl/controllers/peerpod_controller.go | 1 + pkg/adaptor/cloud/ibmcloud/manager.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/peerpod-ctrl/controllers/peerpod_controller.go b/peerpod-ctrl/controllers/peerpod_controller.go index 27ecf0740..5cf034f09 100644 --- a/peerpod-ctrl/controllers/peerpod_controller.go +++ b/peerpod-ctrl/controllers/peerpod_controller.go @@ -143,6 +143,7 @@ func (r *PeerPodReconciler) cloudConfigsGetter() error { func SetProvider() (cloud.Provider, error) { cloudName := os.Getenv("CLOUD_PROVIDER") + logger.Info("CLOUD_PROVIDER: ", cloudName) if cloud := cloudmgr.Get(cloudName); cloud != nil { cloud.LoadEnv() // we assume LoadEnv knows to load all necessary configs provider, err := cloud.NewProvider() diff --git a/pkg/adaptor/cloud/ibmcloud/manager.go b/pkg/adaptor/cloud/ibmcloud/manager.go index d3e300b66..4b3874267 100644 --- a/pkg/adaptor/cloud/ibmcloud/manager.go +++ b/pkg/adaptor/cloud/ibmcloud/manager.go @@ -35,8 +35,20 @@ func (*Manager) ParseCmd(flags *flag.FlagSet) { } func (*Manager) LoadEnv() { + // overwrite config set by cmd parameters in oci image with env might come from orchastration platform cloud.DefaultToEnv(&ibmcloudVPCConfig.ApiKey, "IBMCLOUD_API_KEY", "") cloud.DefaultToEnv(&ibmcloudVPCConfig.IAMProfileID, "IBMCLOUD_IAM_PROFILE_ID", "") + + cloud.DefaultToEnv(&ibmcloudVPCConfig.IamServiceURL, "IBMCLOUD_IAM_ENDPOINT", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.VpcServiceURL, "IBMCLOUD_VPC_ENDPOINT", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.ResourceGroupID, "IBMCLOUD_RESOURCE_GROUP_ID", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.ProfileName, "IBMCLOUD_PODVM_INSTANCE_PROFILE_NAME", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.InstanceProfiles, "IBMCLOUD_PODVM_INSTANCE_PROFILE_LIST", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.ZoneName, "IBMCLOUD_ZONE", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.PrimarySubnetID, "IBMCLOUD_VPC_SUBNET_ID", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.PrimarySecurityGroupID, "IBMCLOUD_VPC_SG_ID", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.KeyID, "IBMCLOUD_SSH_KEY_ID", "") + cloud.DefaultToEnv(&ibmcloudVPCConfig.VpcID, "IBMCLOUD_VPC_ID", "") } func (*Manager) NewProvider() (cloud.Provider, error) {