forked from coop-cloud/abra
WIP: abra recipe upgrade on the way
This commit is contained in:
parent
c75c2254e4
commit
11ef64ead3
|
@ -219,3 +219,27 @@ func readAppsCatalogueWeb(target interface{}) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func VersionsOfService(recipe, serviceName string) ([]string, error) {
|
||||
catl, err := ReadAppsCatalogue()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
app, ok := catl[recipe]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("recipe '%s' does not exist?", recipe)
|
||||
}
|
||||
|
||||
versions := []string{}
|
||||
alreadySeen := make(map[string]bool)
|
||||
for version := range app.Versions {
|
||||
appVersion := app.Versions[version][serviceName].Tag
|
||||
if _, ok := alreadySeen[appVersion]; !ok {
|
||||
alreadySeen[appVersion] = true
|
||||
versions = append(versions, appVersion)
|
||||
}
|
||||
}
|
||||
|
||||
return versions, nil
|
||||
}
|
||||
|
|
|
@ -158,7 +158,32 @@ var recipeUpgradeCommand = &cli.Command{
|
|||
if recipe == "" {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||
}
|
||||
// TODO: part 1 of https://git.coopcloud.tech/coop-cloud/go-abra/issues/39#issuecomment-8066
|
||||
|
||||
type existingTags struct {
|
||||
AppCatalogueTags map[string]string
|
||||
RegistryTags map[string]string
|
||||
RecipeSkipTags map[string]string
|
||||
}
|
||||
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipe)
|
||||
composeFiles, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
opts := options.Deploy{Composefiles: composeFiles}
|
||||
compose, err := loader.LoadComposefile(opts)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
for _, service := range compose.Services {
|
||||
_, err := catalogue.VersionsOfService(recipe, service.Name)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"github.com/docker/distribution/reference"
|
||||
)
|
||||
|
||||
type Tag struct {
|
||||
Layer string
|
||||
Name string
|
||||
}
|
||||
|
||||
type Tags []Tag
|
||||
|
||||
var registryURL = "https://registry.hub.docker.com/v1/repositories/%s/tags"
|
||||
|
||||
func ReadRegistryTags(image reference.Named, target interface{}) ([]string, error) {
|
||||
// tagsUrl := fmt.Sprintf(registryURL, image.Name())
|
||||
return nil, nil
|
||||
}
|
Loading…
Reference in New Issue