forked from toolshed/abra
refactor(recipe): remove remaining usage of old recipe struct
This commit is contained in:
@ -8,7 +8,6 @@ import (
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"coopcloud.tech/abra/pkg/lint"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@ -29,8 +28,7 @@ var recipeLintCommand = cli.Command{
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
if err := r.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||
if err := recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@ -47,7 +45,7 @@ var recipeLintCommand = cli.Command{
|
||||
}
|
||||
|
||||
skipped := false
|
||||
if rule.Skip(r) {
|
||||
if rule.Skip(recipe) {
|
||||
skipped = true
|
||||
}
|
||||
|
||||
@ -58,7 +56,7 @@ var recipeLintCommand = cli.Command{
|
||||
|
||||
satisfied := false
|
||||
if !skipped {
|
||||
ok, err := rule.Function(r)
|
||||
ok, err := rule.Function(recipe)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/distribution/reference"
|
||||
@ -63,14 +62,13 @@ your SSH keys configured on your account.
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
|
||||
imagesTmp, err := getImageVersions(r)
|
||||
imagesTmp, err := getImageVersions(recipe)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mainApp, err := internal.GetMainAppImage(r)
|
||||
mainApp, err := internal.GetMainAppImage(recipe)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -92,45 +90,45 @@ your SSH keys configured on your account.
|
||||
}
|
||||
|
||||
if tagString != "" {
|
||||
if err := createReleaseFromTag(r, tagString, mainAppVersion); err != nil {
|
||||
if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
tags, err := r.Tags()
|
||||
tags, err := recipe.Tags()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
|
||||
var err error
|
||||
tagString, err = getLabelVersion(r, false)
|
||||
tagString, err = getLabelVersion(recipe, false)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
isClean, err := gitPkg.IsClean(r.Dir)
|
||||
isClean, err := gitPkg.IsClean(recipe.Dir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !isClean {
|
||||
log.Infof("%s currently has these unstaged changes 👇", recipe.Name)
|
||||
if err := gitPkg.DiffUnstaged(r.Dir); err != nil {
|
||||
if err := gitPkg.DiffUnstaged(recipe.Dir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(tags) > 0 {
|
||||
logrus.Warnf("previous git tags detected, assuming this is a new semver release")
|
||||
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, r, tags); err != nil {
|
||||
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
log.Warnf("no tag specified and no previous tag available for %s, assuming this is the initial release", recipe.Name)
|
||||
|
||||
if err := createReleaseFromTag(r, tagString, mainAppVersion); err != nil {
|
||||
if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
|
||||
if cleanUpErr := cleanUpTag(tagString, recipe.Name); err != nil {
|
||||
log.Fatal(cleanUpErr)
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/go-git/go-git/v5"
|
||||
@ -45,21 +44,20 @@ local file system.
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
|
||||
mainApp, err := internal.GetMainAppImage(r)
|
||||
mainApp, err := internal.GetMainAppImage(recipe)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
imagesTmp, err := getImageVersions(r)
|
||||
imagesTmp, err := getImageVersions(recipe)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mainAppVersion := imagesTmp[mainApp]
|
||||
|
||||
tags, err := r.Tags()
|
||||
tags, err := recipe.Tags()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -194,20 +192,20 @@ likely to change.
|
||||
mainService := "app"
|
||||
label := fmt.Sprintf("coop-cloud.${STACK_NAME}.version=%s", nextTag)
|
||||
if !internal.Dry {
|
||||
if err := r.UpdateLabel("compose.y*ml", mainService, label); err != nil {
|
||||
if err := recipe.UpdateLabel("compose.y*ml", mainService, label); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
log.Infof("dry run: not syncing label %s for recipe %s", nextTag, recipe.Name)
|
||||
}
|
||||
|
||||
isClean, err := gitPkg.IsClean(r.Dir)
|
||||
isClean, err := gitPkg.IsClean(recipe.Dir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if !isClean {
|
||||
log.Infof("%s currently has these unstaged changes 👇", recipe.Name)
|
||||
if err := gitPkg.DiffUnstaged(r.Dir); err != nil {
|
||||
if err := gitPkg.DiffUnstaged(recipe.Dir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
if err := r.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||
if err := recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@ -97,7 +96,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
versionsPresent := false
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipe.Name)
|
||||
versionsPath := path.Join(recipeDir, "versions")
|
||||
var servicePins = make(map[string]imgPin)
|
||||
servicePins := make(map[string]imgPin)
|
||||
if _, err := os.Stat(versionsPath); err == nil {
|
||||
log.Debugf("found versions file for %s", recipe.Name)
|
||||
file, err := os.Open(versionsPath)
|
||||
@ -130,7 +129,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
log.Debugf("did not find versions file for %s", recipe.Name)
|
||||
}
|
||||
|
||||
config, err := r.GetComposeConfig(nil)
|
||||
config, err := recipe.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -299,7 +298,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
}
|
||||
}
|
||||
if upgradeTag != "skip" {
|
||||
ok, err := r.UpdateTag(image, upgradeTag)
|
||||
ok, err := recipe.UpdateTag(image, upgradeTag)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user