feat: abra app env

This commit is contained in:
decentral1se 2025-01-02 16:32:32 +01:00
parent 48198d55bd
commit dd03c40e10
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 83 additions and 0 deletions

40
cli/app/env.go Normal file
View File

@ -0,0 +1,40 @@
package app
import (
"fmt"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/formatter"
"coopcloud.tech/abra/pkg/log"
"github.com/spf13/cobra"
)
var AppEnvCommand = &cobra.Command{
Use: "env <app> [flags]",
Aliases: []string{"e"},
Short: "Show app .env values",
Example: " abra app env 1312.net",
Args: cobra.ExactArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
toComplete string) ([]string, cobra.ShellCompDirective) {
return autocomplete.AppNameComplete()
},
Run: func(cmd *cobra.Command, args []string) {
app := internal.ValidateApp(args)
if err := app.Recipe.Ensure(internal.GetEnsureContext()); err != nil {
log.Fatal(err)
}
var rows [][]string
for k, v := range app.Env {
rows = append(rows, []string{k, v})
}
overview := formatter.CreateOverview("ENV OVERVIEW", rows)
fmt.Println(overview)
},
}

View File

@ -205,6 +205,7 @@ func Run(version, commit string) {
app.AppUpgradeCommand,
app.AppVolumeCommand,
app.AppLabelsCommand,
app.AppEnvCommand,
)
if err := rootCmd.Execute(); err != nil {

View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
_add_server
_new_app
}
teardown_file(){
_rm_app
_rm_server
_reset_recipe
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
teardown(){
_reset_recipe
_reset_app
_undeploy_app
}
@test "validate app argument" {
run $ABRA app env
assert_failure
run $ABRA app env DOESNTEXIST
assert_failure
}
# bats test_tags=slow
@test "show env version" {
latestRelease=$(_latest_release)
run $ABRA app env "$TEST_APP_DOMAIN"
assert_success
assert_output --partial "$latestRelease"
}