Proper variable naming
@@ -14,7 +14,7 @@ import (
)
type containerService struct {
- cgc containerinstance.ContainerGroupsClient
+ containerGroupsClient containerinstance.ContainerGroupsClient
ctx store.AciContext
}
@@ -29,56 +29,56 @@ func getter() interface{} {
}
func New(ctx context.Context) (containers.ContainerService, error) {
- cc := apicontext.CurrentContext(ctx)
+ currentContext := apicontext.CurrentContext(ctx)
contextStore, err := store.New()
if err != nil {
return nil, err
}
- metadata, err := contextStore.Get(cc, getter)
+ metadata, err := contextStore.Get(currentContext, getter)
if err != nil {
return nil, errors.Wrap(err, "wrong context type")
}
- tc, _ := metadata.Metadata.Data.(store.AciContext)
+ aciContext, _ := metadata.Metadata.Data.(store.AciContext)
auth, _ := auth.NewAuthorizerFromCLI()
- containerGroupsClient := containerinstance.NewContainerGroupsClient(tc.SubscriptionID)
+ containerGroupsClient := containerinstance.NewContainerGroupsClient(aciContext.SubscriptionID)
containerGroupsClient.Authorizer = auth
return &containerService{
- cgc: containerGroupsClient,
- ctx: tc,
+ containerGroupsClient: containerGroupsClient,
+ ctx: aciContext,
}, nil
}
func (cs *containerService) List(ctx context.Context) ([]containers.Container, error) {
- var cg []containerinstance.ContainerGroup
- result, err := cs.cgc.ListByResourceGroup(ctx, cs.ctx.ResourceGroup)
+ var containerGroups []containerinstance.ContainerGroup
+ result, err := cs.containerGroupsClient.ListByResourceGroup(ctx, cs.ctx.ResourceGroup)
if err != nil {
return []containers.Container{}, err
}
for result.NotDone() {
- cg = append(cg, result.Values()...)
+ containerGroups = append(containerGroups, result.Values()...)
if err := result.NextWithContext(ctx); err != nil {
return []containers.Container{}, err
}
}
res := []containers.Container{}
- for _, c := range cg {
- group, err := cs.cgc.Get(ctx, cs.ctx.ResourceGroup, *c.Name)
+ for _, containerGroup := range containerGroups {
+ group, err := cs.containerGroupsClient.Get(ctx, cs.ctx.ResourceGroup, *containerGroup.Name)
if err != nil {
return []containers.Container{}, err
}
- for _, d := range *group.Containers {
+ for _, container := range *group.Containers {
status := "Unknown"
- if d.InstanceView != nil && d.InstanceView.CurrentState != nil {
- status = *d.InstanceView.CurrentState.State
+ if container.InstanceView != nil && container.InstanceView.CurrentState != nil {
+ status = *container.InstanceView.CurrentState.State
}
res = append(res, containers.Container{
- ID: *d.Name,
- Image: *d.Image,
+ ID: *container.Name,
+ Image: *container.Image,
Status: status,
})
}
