diff options
| author | bndw <ben@bdw.to> | 2026-01-24 09:48:34 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-01-24 09:48:34 -0800 |
| commit | 5861e465a2ccf31d87ea25ac145770786f9cc96e (patch) | |
| tree | 4ac6b57a06b46d8492717b235909f9e0db0b4f22 /cmd/deploy/env/list.go | |
| parent | ef37850c7090493cf2b26d2e565511fe23cc9bfc (diff) | |
Rename project from deploy to ship
- Rename module to github.com/bdw/ship
- Rename cmd/deploy to cmd/ship
- Update all import paths
- Update config path from ~/.config/deploy to ~/.config/ship
- Update VPS env path from /etc/deploy to /etc/ship
- Update README, Makefile, and docs
Diffstat (limited to 'cmd/deploy/env/list.go')
| -rw-r--r-- | cmd/deploy/env/list.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/cmd/deploy/env/list.go b/cmd/deploy/env/list.go deleted file mode 100644 index af92171..0000000 --- a/cmd/deploy/env/list.go +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | package env | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "fmt" | ||
| 5 | "strings" | ||
| 6 | |||
| 7 | "github.com/bdw/deploy/internal/state" | ||
| 8 | "github.com/spf13/cobra" | ||
| 9 | ) | ||
| 10 | |||
| 11 | var listCmd = &cobra.Command{ | ||
| 12 | Use: "list <app>", | ||
| 13 | Short: "List environment variables for an app", | ||
| 14 | Args: cobra.ExactArgs(1), | ||
| 15 | RunE: runList, | ||
| 16 | } | ||
| 17 | |||
| 18 | func runList(cmd *cobra.Command, args []string) error { | ||
| 19 | name := args[0] | ||
| 20 | |||
| 21 | st, err := state.Load() | ||
| 22 | if err != nil { | ||
| 23 | return fmt.Errorf("error loading state: %w", err) | ||
| 24 | } | ||
| 25 | |||
| 26 | host, _ := cmd.Flags().GetString("host") | ||
| 27 | if host == "" { | ||
| 28 | host = st.GetDefaultHost() | ||
| 29 | } | ||
| 30 | |||
| 31 | if host == "" { | ||
| 32 | return fmt.Errorf("--host is required") | ||
| 33 | } | ||
| 34 | |||
| 35 | app, err := st.GetApp(host, name) | ||
| 36 | if err != nil { | ||
| 37 | return err | ||
| 38 | } | ||
| 39 | |||
| 40 | if app.Type != "app" { | ||
| 41 | return fmt.Errorf("env is only available for apps, not static sites") | ||
| 42 | } | ||
| 43 | |||
| 44 | fmt.Printf("Environment variables for %s:\n\n", name) | ||
| 45 | if len(app.Env) == 0 { | ||
| 46 | fmt.Println(" (none)") | ||
| 47 | } else { | ||
| 48 | for k, v := range app.Env { | ||
| 49 | display := v | ||
| 50 | if isSensitive(k) { | ||
| 51 | display = "***" | ||
| 52 | } | ||
| 53 | fmt.Printf(" %s=%s\n", k, display) | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | return nil | ||
| 58 | } | ||
| 59 | |||
| 60 | func isSensitive(key string) bool { | ||
| 61 | key = strings.ToLower(key) | ||
| 62 | sensitiveWords := []string{"key", "secret", "password", "token", "api"} | ||
| 63 | for _, word := range sensitiveWords { | ||
| 64 | if strings.Contains(key, word) { | ||
| 65 | return true | ||
| 66 | } | ||
| 67 | } | ||
| 68 | return false | ||
| 69 | } | ||
