refactor: consolidate recipe in-place editing functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -5,8 +5,6 @@ import (
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/compose"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -31,13 +29,13 @@ the versioning metadata of up-and-running containers are.
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := internal.ValidateRecipe(c)
|
||||
|
||||
composeConfig, err := recipe.GetComposeConfig(recipeName)
|
||||
recipe, err := recipe.Get(recipeName)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
hasAppService := false
|
||||
for _, service := range composeConfig.Services {
|
||||
for _, service := range recipe.Config.Services {
|
||||
if service.Name == "app" {
|
||||
hasAppService = true
|
||||
}
|
||||
@ -47,7 +45,7 @@ the versioning metadata of up-and-running containers are.
|
||||
logrus.Fatal(fmt.Sprintf("No 'app' service defined in '%s', cannot proceed", recipeName))
|
||||
}
|
||||
|
||||
for _, service := range composeConfig.Services {
|
||||
for _, service := range recipe.Config.Services {
|
||||
img, err := reference.ParseNormalizedNamed(service.Image)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
@ -60,8 +58,7 @@ the versioning metadata of up-and-running containers are.
|
||||
|
||||
tag := img.(reference.NamedTagged).Tag()
|
||||
label := fmt.Sprintf("coop-cloud.${STACK_NAME}.%s.version=%s-%s", service.Name, tag, digest)
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipeName)
|
||||
if err := compose.UpdateLabel(pattern, service.Name, label); err != nil {
|
||||
if err := recipe.UpdateLabel(service.Name, label); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/catalogue"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/compose"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
@ -38,12 +36,12 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := internal.ValidateRecipe(c)
|
||||
|
||||
composeConfig, err := recipe.GetComposeConfig(recipeName)
|
||||
recipe, err := recipe.Get(recipeName)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
for _, service := range composeConfig.Services {
|
||||
for _, service := range recipe.Config.Services {
|
||||
catlVersions, err := catalogue.VersionsOfService(recipeName, service.Name)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
@ -129,8 +127,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
pattern := fmt.Sprintf("%s/%s/compose**yml", config.APPS_DIR, recipeName)
|
||||
if err := compose.UpdateTag(pattern, image, upgradeTag); err != nil {
|
||||
if err := recipe.UpdateTag(image, upgradeTag); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user