diff --git a/cli/run.go b/cli/run.go index 66b97659..7fc190f1 100644 --- a/cli/run.go +++ b/cli/run.go @@ -31,21 +31,21 @@ func Run(version, commit string) { "upgrade", }, PersistentPreRun: func(cmd *cobra.Command, args []string) { - 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 + dirs := []map[string]os.FileMode{ + {config.ABRA_DIR: 0764}, + {config.SERVERS_DIR: 0600}, + {config.RECIPES_DIR: 0764}, + {config.LOGS_DIR: 0764}, } - for _, path := range paths { - if err := os.Mkdir(path, 0764); err != nil { - if !os.IsExist(err) { - log.Fatal(err) + for _, dir := range dirs { + for path, perm := range dir { + if err := os.Mkdir(path, perm); err != nil { + if !os.IsExist(err) { + log.Fatal(err) + } + continue } - continue } } diff --git a/tests/integration/dirs.bats b/tests/integration/dirs.bats index 79a1df27..c391e0dc 100644 --- a/tests/integration/dirs.bats +++ b/tests/integration/dirs.bats @@ -24,7 +24,7 @@ setup(){ assert_success } -@test "abra directory is created" { +@test "abra directories are created" { run $ABRA app ls # NOTE(d1): no servers yet, so will fail. however, it will run the required @@ -35,8 +35,9 @@ 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" }