summaryrefslogtreecommitdiffstats
path: root/cmd/ship/host/set_domain.go
diff options
context:
space:
mode:
authorClawd <ai@clawd.bot>2026-02-17 07:54:26 -0800
committerClawd <ai@clawd.bot>2026-02-17 07:54:26 -0800
commit6b2c04728cd914f27ae62c1df0bf5df24ac9a628 (patch)
tree8a103ac79194a05fae438b0da105589aaa6b78d9 /cmd/ship/host/set_domain.go
parent5e5de4ea1aa98f75d470e4a61644d4b9f100c4b0 (diff)
Remove v1 code, simplify state to just base_domain
- Delete all v1 commands (deploy, init, list, status, remove, etc.) - Delete v1 env/ and host/ subcommand directories - Simplify state.go: remove NextPort, Apps, AllocatePort, etc. - Local state now only tracks default_host + base_domain per host - Ports and deploys are tracked on the server (/etc/ship/ports/) - host init now creates minimal state.json
Diffstat (limited to 'cmd/ship/host/set_domain.go')
-rw-r--r--cmd/ship/host/set_domain.go76
1 files changed, 0 insertions, 76 deletions
diff --git a/cmd/ship/host/set_domain.go b/cmd/ship/host/set_domain.go
deleted file mode 100644
index fed3b31..0000000
--- a/cmd/ship/host/set_domain.go
+++ /dev/null
@@ -1,76 +0,0 @@
1package host
2
3import (
4 "fmt"
5
6 "github.com/bdw/ship/internal/state"
7 "github.com/spf13/cobra"
8)
9
10var setDomainCmd = &cobra.Command{
11 Use: "set-domain [domain]",
12 Short: "Set base domain for auto-generated subdomains",
13 Long: `Set the base domain used to auto-generate subdomains for deployments.
14
15When a base domain is configured (e.g., apps.example.com), every deployment
16will automatically get a subdomain ({name}.apps.example.com).
17
18Examples:
19 ship host set-domain apps.example.com # Set base domain
20 ship host set-domain --clear # Remove base domain`,
21 RunE: runSetDomain,
22}
23
24func init() {
25 setDomainCmd.Flags().Bool("clear", false, "Clear the base domain")
26}
27
28func runSetDomain(cmd *cobra.Command, args []string) error {
29 st, err := state.Load()
30 if err != nil {
31 return fmt.Errorf("error loading state: %w", err)
32 }
33
34 host, _ := cmd.Flags().GetString("host")
35 if host == "" {
36 host = st.GetDefaultHost()
37 }
38
39 if host == "" {
40 return fmt.Errorf("--host is required")
41 }
42
43 clear, _ := cmd.Flags().GetBool("clear")
44
45 if !clear && len(args) == 0 {
46 // Show current base domain
47 hostState := st.GetHost(host)
48 if hostState.BaseDomain == "" {
49 fmt.Printf("No base domain configured for %s\n", host)
50 } else {
51 fmt.Printf("Base domain for %s: %s\n", host, hostState.BaseDomain)
52 }
53 return nil
54 }
55
56 hostState := st.GetHost(host)
57
58 if clear {
59 hostState.BaseDomain = ""
60 if err := st.Save(); err != nil {
61 return fmt.Errorf("error saving state: %w", err)
62 }
63 fmt.Printf("Cleared base domain for %s\n", host)
64 return nil
65 }
66
67 hostState.BaseDomain = args[0]
68 if err := st.Save(); err != nil {
69 return fmt.Errorf("error saving state: %w", err)
70 }
71
72 fmt.Printf("Set base domain for %s: %s\n", host, args[0])
73 fmt.Println("\nNew deployments will automatically use subdomains like:")
74 fmt.Printf(" myapp.%s\n", args[0])
75 return nil
76}