fix: moar integration test patches

See toolshed/organising#650
This commit is contained in:
2024-12-27 21:55:01 +01:00
parent efb3fd8759
commit 4e8995cc0e
3 changed files with 17 additions and 11 deletions

View File

@ -64,7 +64,7 @@ var AppNewCommand = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
recipe := internal.ValidateRecipe(args, cmd.Name())
var version string
var recipeVersion string
if !internal.Chaos {
if err := recipe.EnsureIsClean(); err != nil {
log.Fatal(err)
@ -75,7 +75,6 @@ var AppNewCommand = &cobra.Command{
}
}
var recipeVersion string
if len(args) == 2 {
recipeVersion = args[1]
}
@ -89,10 +88,10 @@ var AppNewCommand = &cobra.Command{
if len(recipeVersions) > 0 {
latest := recipeVersions[len(recipeVersions)-1]
for tag := range latest {
version = tag
recipeVersion = tag
}
if _, err := recipe.EnsureVersion(version); err != nil {
if _, err := recipe.EnsureVersion(recipeVersion); err != nil {
log.Fatal(err)
}
} else {
@ -107,6 +106,14 @@ var AppNewCommand = &cobra.Command{
}
}
if internal.Chaos && recipeVersion == "" {
var err error
recipeVersion, err = recipe.ChaosVersion()
if err != nil {
log.Fatal(err)
}
}
if err := ensureServerFlag(); err != nil {
log.Fatal(err)
}
@ -188,7 +195,7 @@ var AppNewCommand = &cobra.Command{
headers := []string{"SERVER", "DOMAIN", "RECIPE", "VERSION"}
table.Headers(headers...)
table.Row(newAppServer, appDomain, recipe.Name, version)
table.Row(newAppServer, appDomain, recipe.Name, recipeVersion)
log.Infof("new app '%s' created 🌞", recipe.Name)
@ -221,8 +228,8 @@ var AppNewCommand = &cobra.Command{
log.Fatal(err)
}
log.Debugf("choosing %s as version to save to env file", version)
if err := app.WriteRecipeVersion(version, false); err != nil {
log.Debugf("choosing %s as version to save to env file", recipeVersion)
if err := app.WriteRecipeVersion(recipeVersion, false); err != nil {
log.Fatalf("writing new recipe version in env file: %s", err)
}
},