fix: abra app new checks out latest version #412
@ -10,7 +10,6 @@ import (
|
|||||||
"coopcloud.tech/abra/pkg/config"
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
"coopcloud.tech/abra/pkg/jsontable"
|
"coopcloud.tech/abra/pkg/jsontable"
|
||||||
"coopcloud.tech/abra/pkg/recipe"
|
|
||||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||||
"coopcloud.tech/abra/pkg/secret"
|
"coopcloud.tech/abra/pkg/secret"
|
||||||
"github.com/AlecAivazis/survey/v2"
|
"github.com/AlecAivazis/survey/v2"
|
||||||
@ -78,9 +77,29 @@ var appNewCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.Args().Get(1) == "" {
|
if c.Args().Get(1) == "" {
|
||||||
if err := recipePkg.EnsureLatest(recipe.Name); err != nil {
|
var version string
|
||||||
|
|
||||||
|
recipeVersions, err := recipePkg.GetRecipeVersions(recipe.Name, internal.Offline)
|
||||||
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(d1): determine whether recipe versions exist or not and check
|
||||||
decentral1se marked this conversation as resolved
Outdated
|
|||||||
|
// out the latest version or current HEAD
|
||||||
|
if len(recipeVersions) > 0 {
|
||||||
|
latest := recipeVersions[len(recipeVersions)-1]
|
||||||
|
for tag := range latest {
|
||||||
|
version = tag
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := recipePkg.EnsureVersion(recipe.Name, version); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := recipePkg.EnsureLatest(recipe.Name); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := recipePkg.EnsureVersion(recipe.Name, c.Args().Get(1)); err != nil {
|
if err := recipePkg.EnsureVersion(recipe.Name, c.Args().Get(1)); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
@ -212,7 +231,7 @@ func createSecrets(cl *dockerClient.Client, secretsConfig map[string]secret.Secr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensureDomainFlag checks if the domain flag was used. if not, asks the user for it/
|
// ensureDomainFlag checks if the domain flag was used. if not, asks the user for it/
|
||||||
func ensureDomainFlag(recipe recipe.Recipe, server string) error {
|
func ensureDomainFlag(recipe recipePkg.Recipe, server string) error {
|
||||||
if internal.Domain == "" && !internal.NoInput {
|
if internal.Domain == "" && !internal.NoInput {
|
||||||
prompt := &survey.Input{
|
prompt := &survey.Input{
|
||||||
Message: "Specify app domain",
|
Message: "Specify app domain",
|
||||||
|
@ -945,6 +945,7 @@ func GetRecipeVersions(recipeName string, offline bool) (RecipeVersions, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return versions, err
|
return versions, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sortRecipeVersions(versions)
|
sortRecipeVersions(versions)
|
||||||
|
|
||||||
logrus.Debugf("collected %s for %s", versions, recipeName)
|
logrus.Debugf("collected %s for %s", versions, recipeName)
|
||||||
|
@ -37,6 +37,15 @@ teardown(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "create new app" {
|
@test "create new app" {
|
||||||
|
_fetch_recipe
|
||||||
decentral1se marked this conversation as resolved
Outdated
decentral1se
commented
Better approach in coop-cloud/abra#414! Will merge this as-is and rebase this new PR on top of the changes in that PR. Looks like things are coming together for not having constantly broken integration tests... Better approach in https://git.coopcloud.tech/coop-cloud/abra/pulls/414! Will merge this as-is and rebase this new PR on top of the changes in that PR. Looks like things are coming together for not having constantly broken integration tests...
|
|||||||
|
_latest_tag
|
||||||
|
|
||||||
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout $LATEST_TAG
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
_latest_hash
|
||||||
|
_reset_recipe
|
||||||
|
|
||||||
run $ABRA app new "$TEST_RECIPE" \
|
run $ABRA app new "$TEST_RECIPE" \
|
||||||
--no-input \
|
--no-input \
|
||||||
--server "$TEST_SERVER" \
|
--server "$TEST_SERVER" \
|
||||||
@ -44,8 +53,8 @@ teardown(){
|
|||||||
assert_success
|
assert_success
|
||||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1
|
||||||
assert_output --partial "up to date"
|
assert_output --partial "$LATEST_HASH"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "create new app with version" {
|
@test "create new app with version" {
|
||||||
|
@ -35,3 +35,11 @@ _set_git_author() {
|
|||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" config --local user.name test
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" config --local user.name test
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_latest_tag() {
|
||||||
|
export LATEST_TAG=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" describe --abbrev=0)
|
||||||
|
}
|
||||||
|
|
||||||
|
_latest_hash() {
|
||||||
|
export LATEST_HASH=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1 --pretty=format:%h)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user
Can you add a comment (above) this if statement explaing this case and the block inside? It not quite clear to me by just reading the code