@@ -18,6 +18,7 @@ import (
1818 projects "github.com/IBM/project-go-sdk/projectv1"
1919
2020 "github.com/IBM-Cloud/bluemix-go"
21+ "github.com/IBM-Cloud/bluemix-go/api/container/containerv1"
2122 "github.com/IBM-Cloud/bluemix-go/api/container/containerv2"
2223 "github.com/IBM-Cloud/bluemix-go/session"
2324 ibmpimodels "github.com/IBM-Cloud/power-go-client/power/models"
@@ -152,6 +153,7 @@ type CloudInfoService struct {
152153 resourceManagerService resourceManagerService
153154 cbrService cbrService
154155 containerClient containerClient
156+ containerV1Client containerV1Client
155157 catalogService catalogService
156158 // stackDefinitionCreator is used to create stack definitions and only added to support testing/mocking
157159 stackDefinitionCreator StackDefinitionCreator
@@ -282,6 +284,7 @@ type CloudInfoServiceOptions struct {
282284 IamPolicyService iamPolicyService
283285 CbrService cbrService
284286 ContainerClient containerClient
287+ ContainerV1Client containerV1Client
285288 RegionPrefs []RegionData
286289 IcdService icdService
287290 IcdRegion string
@@ -359,6 +362,11 @@ type containerClient interface {
359362 Albs () containerv2.Alb
360363}
361364
365+ // containerV1Client interface for external Kubernetes Versions Service API. Used for mocking.
366+ type containerV1Client interface {
367+ KubeVersions () containerv1.KubeVersions
368+ }
369+
362370// cbrService interface for external Context Based Restrictions Service API. Used for mocking.
363371type cbrService interface {
364372 GetRule (* contextbasedrestrictionsv1.GetRuleOptions ) (* contextbasedrestrictionsv1.Rule , * core.DetailedResponse , error )
@@ -598,6 +606,29 @@ func NewCloudInfoServiceWithKey(options CloudInfoServiceOptions) (*CloudInfoServ
598606 }
599607 infoSvc .containerClient = containerClient
600608 }
609+
610+ // if containerV1Client is not supplied, use default external service
611+ if options .ContainerV1Client != nil {
612+ infoSvc .containerV1Client = options .ContainerV1Client
613+ } else {
614+ // Create a new Bluemix session
615+ sess , sessErr := session .New (& bluemix.Config {
616+ BluemixAPIKey : infoSvc .ApiKey , // pragma: allowlist secret
617+ })
618+ if sessErr != nil {
619+ log .Println ("ERROR: Could not create Bluemix session:" , sessErr )
620+ return nil , sessErr
621+ }
622+
623+ // Initialize the containerv1 service client with the session
624+ containerV1Client , containerErr := containerv1 .New (sess )
625+ if containerErr != nil {
626+ log .Println ("ERROR: Could not create containerv1 service client:" , containerErr )
627+ return nil , containerErr
628+ }
629+ infoSvc .containerV1Client = containerV1Client
630+ }
631+
601632 // if resourceControllerService is not supplied use new external
602633 if options .ResourceControllerService != nil {
603634 infoSvc .resourceControllerService = options .ResourceControllerService
0 commit comments