@@ -46,22 +46,17 @@ func New(ctx context.Context) (backend.Service, error) {
46
46
return nil , err
47
47
}
48
48
49
- auth , _ := login .NewAuthorizerFromLogin ()
50
- containerGroupsClient := containerinstance .NewContainerGroupsClient (aciContext .SubscriptionID )
51
- containerGroupsClient .Authorizer = auth
52
-
53
- return getAciAPIService (containerGroupsClient , aciContext )
49
+ return getAciAPIService (aciContext )
54
50
}
55
51
56
- func getAciAPIService (cgc containerinstance. ContainerGroupsClient , aciCtx store.AciContext ) (* aciAPIService , error ) {
52
+ func getAciAPIService (aciCtx store.AciContext ) (* aciAPIService , error ) {
57
53
service , err := login .NewAzureLoginService ()
58
54
if err != nil {
59
55
return nil , err
60
56
}
61
57
return & aciAPIService {
62
58
aciContainerService : aciContainerService {
63
- containerGroupsClient : cgc ,
64
- ctx : aciCtx ,
59
+ ctx : aciCtx ,
65
60
},
66
61
aciComposeService : aciComposeService {
67
62
ctx : aciCtx ,
@@ -91,13 +86,16 @@ func (a *aciAPIService) CloudService() cloud.Service {
91
86
}
92
87
93
88
type aciContainerService struct {
94
- containerGroupsClient containerinstance.ContainerGroupsClient
95
- ctx store.AciContext
89
+ ctx store.AciContext
96
90
}
97
91
98
92
func (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
+ }
99
97
var containerGroups []containerinstance.ContainerGroup
100
- result , err := cs . containerGroupsClient .ListByResourceGroup (ctx , cs .ctx .ResourceGroup )
98
+ result , err := groupsClient .ListByResourceGroup (ctx , cs .ctx .ResourceGroup )
101
99
if err != nil {
102
100
return []containers.Container {}, err
103
101
}
@@ -111,7 +109,7 @@ func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.C
111
109
112
110
var res []containers.Container
113
111
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 )
115
113
if err != nil {
116
114
return []containers.Container {}, err
117
115
}
0 commit comments