@@ -46,22 +46,17 @@ func New(ctx context.Context) (backend.Service, error) {
4646 return nil , err
4747 }
4848
49- auth , _ := login .NewAuthorizerFromLogin ()
50- containerGroupsClient := containerinstance .NewContainerGroupsClient (aciContext .SubscriptionID )
51- containerGroupsClient .Authorizer = auth
52-
53- return getAciAPIService (containerGroupsClient , aciContext )
49+ return getAciAPIService (aciContext )
5450}
5551
56- func getAciAPIService (cgc containerinstance. ContainerGroupsClient , aciCtx store.AciContext ) (* aciAPIService , error ) {
52+ func getAciAPIService (aciCtx store.AciContext ) (* aciAPIService , error ) {
5753 service , err := login .NewAzureLoginService ()
5854 if err != nil {
5955 return nil , err
6056 }
6157 return & aciAPIService {
6258 aciContainerService : aciContainerService {
63- containerGroupsClient : cgc ,
64- ctx : aciCtx ,
59+ ctx : aciCtx ,
6560 },
6661 aciComposeService : aciComposeService {
6762 ctx : aciCtx ,
@@ -91,13 +86,16 @@ func (a *aciAPIService) CloudService() cloud.Service {
9186}
9287
9388type aciContainerService struct {
94- containerGroupsClient containerinstance.ContainerGroupsClient
95- ctx store.AciContext
89+ ctx store.AciContext
9690}
9791
9892func (cs * aciContainerService ) List (ctx context.Context , _ bool ) ([]containers.Container , error ) {
93+ groupsClient , err := getContainerGroupsClient (cs .ctx .SubscriptionID )
94+ if err != nil {
95+ return nil , err
96+ }
9997 var containerGroups []containerinstance.ContainerGroup
100- result , err := cs . containerGroupsClient .ListByResourceGroup (ctx , cs .ctx .ResourceGroup )
98+ result , err := groupsClient .ListByResourceGroup (ctx , cs .ctx .ResourceGroup )
10199 if err != nil {
102100 return []containers.Container {}, err
103101 }
@@ -111,7 +109,7 @@ func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.C
111109
112110 var res []containers.Container
113111 for _ , containerGroup := range containerGroups {
114- group , err := cs . containerGroupsClient .Get (ctx , cs .ctx .ResourceGroup , * containerGroup .Name )
112+ group , err := groupsClient .Get (ctx , cs .ctx .ResourceGroup , * containerGroup .Name )
115113 if err != nil {
116114 return []containers.Container {}, err
117115 }
0 commit comments