chore: use keyed fields with struct literals

This commit is contained in:
Wiktor W. 2023-11-04 18:08:56 +01:00
parent ca91abbed9
commit 108456585d
4 changed files with 9 additions and 9 deletions

View File

@ -110,7 +110,7 @@ flag.
logrus.Fatal(err) logrus.Fatal(err)
} }
volumeListOptions := volume.ListOptions{fs} volumeListOptions := volume.ListOptions{Filters: fs}
volumeListOKBody, err := cl.VolumeList(context.Background(), volumeListOptions) volumeListOKBody, err := cl.VolumeList(context.Background(), volumeListOptions)
volumeList := volumeListOKBody.Volumes volumeList := volumeListOKBody.Volumes
if err != nil { if err != nil {

View File

@ -9,7 +9,7 @@ import (
) )
func GetVolumes(cl *client.Client, ctx context.Context, server string, fs filters.Args) ([]*volume.Volume, error) { func GetVolumes(cl *client.Client, ctx context.Context, server string, fs filters.Args) ([]*volume.Volume, error) {
volumeListOptions := volume.ListOptions{fs} volumeListOptions := volume.ListOptions{Filters: fs}
volumeListOKBody, err := cl.VolumeList(ctx, volumeListOptions) volumeListOKBody, err := cl.VolumeList(ctx, volumeListOptions)
volumeList := volumeListOKBody.Volumes volumeList := volumeListOKBody.Volumes
if err != nil { if err != nil {

View File

@ -6,7 +6,7 @@ type Limiter struct{ sem chan struct{} }
// New returns a new Limiter. The limit param is the maximum number of // New returns a new Limiter. The limit param is the maximum number of
// concurrent operations. // concurrent operations.
func New(limit int) *Limiter { func New(limit int) *Limiter {
return &Limiter{make(chan struct{}, limit)} return &Limiter{sem: make(chan struct{}, limit)}
} }
// Begin an operation. // Begin an operation.

View File

@ -66,19 +66,19 @@ func GetDeployedServicesByLabel(cl *dockerClient.Client, contextName string, lab
filters.Add("label", label) filters.Add("label", label)
services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: filters}) services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: filters})
if err != nil { if err != nil {
return StackStatus{[]swarm.Service{}, err} return StackStatus{Services: []swarm.Service{}, Err: err}
} }
return StackStatus{services, nil} return StackStatus{Services: services, Err: nil}
} }
func GetAllDeployedServices(cl *dockerClient.Client, contextName string) StackStatus { func GetAllDeployedServices(cl *dockerClient.Client, contextName string) StackStatus {
services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: getAllStacksFilter()}) services, err := cl.ServiceList(context.Background(), types.ServiceListOptions{Filters: getAllStacksFilter()})
if err != nil { if err != nil {
return StackStatus{[]swarm.Service{}, err} return StackStatus{Services: []swarm.Service{}, Err: err}
} }
return StackStatus{services, nil} return StackStatus{Services: services, Err: nil}
} }
// GetDeployedServicesByName filters services by name // GetDeployedServicesByName filters services by name
@ -88,10 +88,10 @@ func GetDeployedServicesByName(ctx context.Context, cl *dockerClient.Client, sta
services, err := cl.ServiceList(ctx, types.ServiceListOptions{Filters: filters}) services, err := cl.ServiceList(ctx, types.ServiceListOptions{Filters: filters})
if err != nil { if err != nil {
return StackStatus{[]swarm.Service{}, err} return StackStatus{Services: []swarm.Service{}, Err: err}
} }
return StackStatus{services, nil} return StackStatus{Services: services, Err: nil}
} }
// IsDeployed chekcks whether an appp is deployed or not. // IsDeployed chekcks whether an appp is deployed or not.