From 2d54a8b3ccd2e9105e7dad4f95f5103515a93e15 Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Thu, 10 Dec 2020 23:36:47 +0530 Subject: [PATCH] Select the default resource group for the account while creating the IBM COS --- cmd/image/upload/upload.go | 2 +- pkg/client/resource.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/image/upload/upload.go b/cmd/image/upload/upload.go index 1f8cb6a3..99c24ef8 100644 --- a/cmd/image/upload/upload.go +++ b/cmd/image/upload/upload.go @@ -155,7 +155,7 @@ pvsadm image upload --bucket basheerbucket1320 -o centos-8-latest.ova.gz --regio } func init() { - Cmd.Flags().StringVar(&pkg.ImageCMDOptions.ResourceGrp, "resource-group", "default", "Provide Resource-Group") + Cmd.Flags().StringVar(&pkg.ImageCMDOptions.ResourceGrp, "resource-group", "", "Provide Resource-Group(default: default resource group set for the account") Cmd.Flags().StringVar(&pkg.ImageCMDOptions.ServicePlan, "service-plan", "standard", "Provide serviceplan type") Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.InstanceName, "instance-name", "n", "", "Instance Name of the COS to be used") Cmd.Flags().StringVarP(&pkg.ImageCMDOptions.BucketName, "bucket", "b", "", "Region of the COS instance") diff --git a/pkg/client/resource.go b/pkg/client/resource.go index 02a5c276..d99d0967 100644 --- a/pkg/client/resource.go +++ b/pkg/client/resource.go @@ -72,7 +72,7 @@ func CreateServiceInstance(sess *session.Session, instanceName, serviceName, ser return "", err } - var resourceGroupID string + var resourceGroup models.ResourceGroup resGrpAPI := managementClient.ResourceGroup() if resourceGrp == "" { @@ -84,15 +84,16 @@ func CreateServiceInstance(sess *session.Session, instanceName, serviceName, ser if err != nil { return "", err } - resourceGroupID = grpList[0].ID + resourceGroup = grpList[0] } else { grp, err := resGrpAPI.FindByName(nil, resourceGrp) if err != nil { return "", err } - resourceGroupID = grp[0].ID + resourceGroup = grp[0] } + klog.Infof("Resource group: %s and ID: %s", resourceGroup.Name, resourceGroup.ID) controllerClient, err := controller.New(sess) if err != nil { @@ -104,7 +105,7 @@ func CreateServiceInstance(sess *session.Session, instanceName, serviceName, ser var serviceInstancePayload = controller.CreateServiceInstanceRequest{ Name: instanceName, ServicePlanID: servicePlanID, - ResourceGroupID: resourceGroupID, + ResourceGroupID: resourceGroup.ID, TargetCrn: supportedDeployments[0].CatalogCRN, }