Compare commits

..

1 Commits

Author SHA1 Message Date
bbf393dd95 fix: ensure recipe with undeploy
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
See #573
2025-08-13 11:42:52 +02:00
4 changed files with 33 additions and 16 deletions

View File

@ -38,6 +38,10 @@ Passing "--prune/-p" does not remove those volumes.`,
app := internal.ValidateApp(args)
stackName := app.StackName()
if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
log.Fatal(err)
}
cl, err := client.New(app.Server)
if err != nil {
log.Fatal(err)

View File

@ -31,23 +31,23 @@ func Run(version, commit string) {
"upgrade",
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
dirs := []map[string]os.FileMode{
{config.ABRA_DIR: 0764},
{config.SERVERS_DIR: 0600},
{config.RECIPES_DIR: 0764},
{config.LOGS_DIR: 0764},
paths := []string{
config.ABRA_DIR,
config.SERVERS_DIR,
config.RECIPES_DIR,
config.LOGS_DIR,
config.VENDOR_DIR, // TODO(d1): remove > 0.9.x
config.BACKUP_DIR, // TODO(d1): remove > 0.9.x
}
for _, dir := range dirs {
for path, perm := range dir {
if err := os.Mkdir(path, perm); err != nil {
for _, path := range paths {
if err := os.Mkdir(path, 0764); err != nil {
if !os.IsExist(err) {
log.Fatal(err)
}
continue
}
}
}
log.Logger.SetStyles(charmLog.DefaultStyles())
charmLog.SetDefault(log.Logger)

View File

@ -30,6 +30,20 @@ teardown(){
assert_failure
}
# bats test_tags=slow
@test "retrieve recipe if missing" {
_deploy_app
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
assert_success
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input
assert_success
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
}
# bats test_tags=slow
@test "ensure recipe up to date if no --offline" {
_deploy_app

View File

@ -24,7 +24,7 @@ setup(){
assert_success
}
@test "abra directories are created" {
@test "abra directory is created" {
run $ABRA app ls
# NOTE(d1): no servers yet, so will fail. however, it will run the required
@ -35,9 +35,8 @@ setup(){
assert_exists "$ABRA_DIR"
assert_exists "$ABRA_DIR/servers"
assert_exists "$ABRA_DIR/recipes"
assert_exists "$ABRA_DIR/backups"
assert_exists "$ABRA_DIR/vendor"
assert_not_exists "$ABRA_DIR/catalogue"
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers")
assert_equal $server_dir_perms "600"
}