feat: abra app env
This commit is contained in:
parent
48198d55bd
commit
dd03c40e10
40
cli/app/env.go
Normal file
40
cli/app/env.go
Normal 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)
|
||||||
|
},
|
||||||
|
}
|
@ -205,6 +205,7 @@ func Run(version, commit string) {
|
|||||||
app.AppUpgradeCommand,
|
app.AppUpgradeCommand,
|
||||||
app.AppVolumeCommand,
|
app.AppVolumeCommand,
|
||||||
app.AppLabelsCommand,
|
app.AppLabelsCommand,
|
||||||
|
app.AppEnvCommand,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
|
42
tests/integration/app_env.bats
Normal file
42
tests/integration/app_env.bats
Normal 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"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user