mirror of https://github.com/docker/compose.git
Merge pull request #158 from docker/azure_backend_dependency
Remove azure resourceGroupClient from backend initialisation.
This commit is contained in:
commit
c8acbc33fd
|
@ -46,21 +46,16 @@ func New(ctx context.Context) (backend.Service, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
auth, _ := login.NewAuthorizerFromLogin()
|
return getAciAPIService(aciContext)
|
||||||
containerGroupsClient := containerinstance.NewContainerGroupsClient(aciContext.SubscriptionID)
|
|
||||||
containerGroupsClient.Authorizer = auth
|
|
||||||
|
|
||||||
return getAciAPIService(containerGroupsClient, aciContext)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAciAPIService(cgc containerinstance.ContainerGroupsClient, aciCtx store.AciContext) (*aciAPIService, error) {
|
func getAciAPIService(aciCtx store.AciContext) (*aciAPIService, error) {
|
||||||
service, err := login.NewAzureLoginService()
|
service, err := login.NewAzureLoginService()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &aciAPIService{
|
return &aciAPIService{
|
||||||
aciContainerService: aciContainerService{
|
aciContainerService: aciContainerService{
|
||||||
containerGroupsClient: cgc,
|
|
||||||
ctx: aciCtx,
|
ctx: aciCtx,
|
||||||
},
|
},
|
||||||
aciComposeService: aciComposeService{
|
aciComposeService: aciComposeService{
|
||||||
|
@ -91,13 +86,16 @@ func (a *aciAPIService) CloudService() cloud.Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
type aciContainerService struct {
|
type aciContainerService struct {
|
||||||
containerGroupsClient containerinstance.ContainerGroupsClient
|
|
||||||
ctx store.AciContext
|
ctx store.AciContext
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.Container, error) {
|
func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.Container, error) {
|
||||||
|
groupsClient, err := getContainerGroupsClient(cs.ctx.SubscriptionID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
var containerGroups []containerinstance.ContainerGroup
|
var containerGroups []containerinstance.ContainerGroup
|
||||||
result, err := cs.containerGroupsClient.ListByResourceGroup(ctx, cs.ctx.ResourceGroup)
|
result, err := groupsClient.ListByResourceGroup(ctx, cs.ctx.ResourceGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []containers.Container{}, err
|
return []containers.Container{}, err
|
||||||
}
|
}
|
||||||
|
@ -111,7 +109,7 @@ func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.C
|
||||||
|
|
||||||
var res []containers.Container
|
var res []containers.Container
|
||||||
for _, containerGroup := range containerGroups {
|
for _, containerGroup := range containerGroups {
|
||||||
group, err := cs.containerGroupsClient.Get(ctx, cs.ctx.ResourceGroup, *containerGroup.Name)
|
group, err := groupsClient.Get(ctx, cs.ctx.ResourceGroup, *containerGroup.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []containers.Container{}, err
|
return []containers.Container{}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue