feat: abra app env

This commit is contained in:
2025-01-02 16:32:32 +01:00
parent 48198d55bd
commit dd03c40e10
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 {