forked from toolshed/abra
fix: teach app version command to read new versions
This commit is contained in:
@ -54,15 +54,15 @@ type tag = string
|
||||
// service represents a service within a recipe.
|
||||
type service = string
|
||||
|
||||
// serviceMeta represents meta info associated with a service.
|
||||
type serviceMeta struct {
|
||||
// ServiceMeta represents meta info associated with a service.
|
||||
type ServiceMeta struct {
|
||||
Digest string `json:"digest"`
|
||||
Image string `json:"image"`
|
||||
Tag string `json:"tag"`
|
||||
}
|
||||
|
||||
// RecipeVersions are the versions associated with a recipe.
|
||||
type RecipeVersions []map[tag]map[service]serviceMeta
|
||||
type RecipeVersions []map[tag]map[service]ServiceMeta
|
||||
|
||||
// RecipeMeta represents metadata for a recipe in the abra catalogue.
|
||||
type RecipeMeta struct {
|
||||
@ -420,7 +420,7 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
versionMeta := make(map[string]serviceMeta)
|
||||
versionMeta := make(map[string]ServiceMeta)
|
||||
for _, service := range recipe.Config.Services {
|
||||
|
||||
img, err := reference.ParseNormalizedNamed(service.Image)
|
||||
@ -438,7 +438,7 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
versionMeta[service.Name] = serviceMeta{
|
||||
versionMeta[service.Name] = ServiceMeta{
|
||||
Digest: digest,
|
||||
Image: path,
|
||||
Tag: img.(reference.NamedTagged).Tag(),
|
||||
@ -447,7 +447,7 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
logrus.Debugf("collecting digest: '%s', image: '%s', tag: '%s'", digest, path, tag)
|
||||
}
|
||||
|
||||
versions = append(versions, map[string]map[string]serviceMeta{tag: versionMeta})
|
||||
versions = append(versions, map[string]map[string]ServiceMeta{tag: versionMeta})
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
@ -93,6 +93,19 @@ func GetAllDeployedServices(contextName string) StackStatus {
|
||||
return StackStatus{services, nil}
|
||||
}
|
||||
|
||||
// GetDeployedServicesByName filters services by name
|
||||
func GetDeployedServicesByName(ctx context.Context, cl *dockerclient.Client, stackName, serviceName string) StackStatus {
|
||||
filters := filters.NewArgs()
|
||||
filters.Add("name", fmt.Sprintf("%s_%s", stackName, serviceName))
|
||||
|
||||
services, err := cl.ServiceList(ctx, types.ServiceListOptions{Filters: filters})
|
||||
if err != nil {
|
||||
return StackStatus{[]swarm.Service{}, err}
|
||||
}
|
||||
|
||||
return StackStatus{services, nil}
|
||||
}
|
||||
|
||||
// IsDeployed chekcks whether an appp is deployed or not.
|
||||
func IsDeployed(ctx context.Context, cl *dockerclient.Client, stackName string) (bool, string, error) {
|
||||
version := ""
|
||||
|
Reference in New Issue
Block a user