forked from toolshed/abra
WIP abra app version <app> implementation
This commit is contained in:
@ -47,6 +47,28 @@ func getStackServices(ctx context.Context, apiclient client.APIClient, namespace
|
||||
return apiclient.ServiceList(ctx, types.ServiceListOptions{Filters: getStackServiceFilter(namespace)})
|
||||
}
|
||||
|
||||
// GetDeployedServicesByLabel filters services by label
|
||||
func GetDeployedServicesByLabel(contextName string, label string) StackStatus {
|
||||
cl, err := abraClient.NewClientWithContext(contextName)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "does not exist") {
|
||||
// No local context found, bail out gracefully
|
||||
return StackStatus{[]swarm.Service{}, nil}
|
||||
}
|
||||
return StackStatus{[]swarm.Service{}, err}
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
filters := filters.NewArgs()
|
||||
filters.Add("label", label)
|
||||
services, err := cl.ServiceList(ctx, types.ServiceListOptions{Filters: filters})
|
||||
if err != nil {
|
||||
return StackStatus{[]swarm.Service{}, err}
|
||||
}
|
||||
|
||||
return StackStatus{services, nil}
|
||||
}
|
||||
|
||||
func GetAllDeployedServices(contextName string) StackStatus {
|
||||
cl, err := abraClient.NewClientWithContext(contextName)
|
||||
if err != nil {
|
||||
@ -56,11 +78,13 @@ func GetAllDeployedServices(contextName string) StackStatus {
|
||||
}
|
||||
return StackStatus{[]swarm.Service{}, err}
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
services, err := cl.ServiceList(ctx, types.ServiceListOptions{Filters: getAllStacksFilter()})
|
||||
if err != nil {
|
||||
return StackStatus{[]swarm.Service{}, err}
|
||||
}
|
||||
|
||||
return StackStatus{services, nil}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user