Skip to content

Commit a9518d6

Browse files
fix: seems eventually works
1 parent 6c9beaf commit a9518d6

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

cli/cli.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,21 @@ func BaseCommand() *serpent.Command {
6363
config := Config{}
6464

6565
// Resolve default config path - use same logic as util.GetUserInfo() (handles sudo scenarios)
66+
// Set it directly on the config so serpent sees it as the default value
6667
_, _, _, _, configDir := util.GetUserInfo()
67-
defaultConfigPath := ""
6868
if configDir != "" {
69-
defaultConfigPath = filepath.Join(configDir, "config.yaml")
69+
defaultPath := filepath.Join(configDir, "config.yaml")
70+
// Only set if file exists - serpent will load it automatically
71+
if _, err := os.Stat(defaultPath); err == nil {
72+
config.Config = serpent.YAMLConfigPath(defaultPath)
73+
}
7074
} else {
7175
// Fallback if we can't determine config dir
7276
if home, err := os.UserHomeDir(); err == nil {
73-
defaultConfigPath = filepath.Join(home, ".config", "coder_boundary", "config.yaml")
77+
defaultPath := filepath.Join(home, ".config", "coder_boundary", "config.yaml")
78+
if _, err := os.Stat(defaultPath); err == nil {
79+
config.Config = serpent.YAMLConfigPath(defaultPath)
80+
}
7481
}
7582
}
7683

@@ -83,7 +90,6 @@ func BaseCommand() *serpent.Command {
8390
Flag: "config",
8491
Env: "BOUNDARY_CONFIG",
8592
Description: "Path to YAML config file.",
86-
Default: defaultConfigPath,
8793
Value: &config.Config,
8894
YAML: "",
8995
},
@@ -146,17 +152,6 @@ func isChild() bool {
146152

147153
// Run executes the boundary command with the given configuration and arguments
148154
func Run(ctx context.Context, config Config, args []string) error {
149-
// Debug: show config path and if file exists
150-
configPath := config.Config.String()
151-
fmt.Fprintf(os.Stderr, "Config path: %s\n", configPath)
152-
if configPath != "" {
153-
if _, err := os.Stat(configPath); err == nil {
154-
fmt.Fprintf(os.Stderr, "Config file exists and will be loaded by serpent\n")
155-
} else {
156-
fmt.Fprintf(os.Stderr, "Config file does not exist: %v\n", err)
157-
}
158-
}
159-
160155
configInJSON, err := json.Marshal(config)
161156
if err != nil {
162157
panic(err)

0 commit comments

Comments
 (0)