Skip to content

Commit

Permalink
peerpod-ctl: Fix problem in LoadEnv in IBMCloud Provider
Browse files Browse the repository at this point in the history
Fixes: confidential-containers#1454

Signed-off-by: Qi Feng Huo <[email protected]>
  • Loading branch information
Qi Feng Huo committed Sep 21, 2023
1 parent 113bc7f commit 7f6d437
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions peerpod-ctrl/controllers/peerpod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions pkg/adaptor/cloud/ibmcloud/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7f6d437

Please sign in to comment.