@@ -2,6 +2,7 @@ package cli
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
67 "log"
78 "log/slog"
@@ -30,7 +31,7 @@ type Config struct {
3031 LogDir serpent.String `yaml:"log_dir"`
3132 ProxyPort serpent.Int64 `yaml:"proxy_port"`
3233 Pprof struct {
33- Enabled serpent.Bool `yaml:"enabled"`
34+ Enabled serpent.Bool `yaml:"enabled"`
3435 Port serpent.Int64 `yaml:"port"`
3536 } `yaml:"pprof"`
3637}
@@ -61,6 +62,18 @@ func NewCommand() *serpent.Command {
6162func BaseCommand () * serpent.Command {
6263 config := Config {}
6364
65+ // Resolve default config path - use same logic as util.GetUserInfo() (handles sudo scenarios)
66+ _ , _ , _ , _ , configDir := util .GetUserInfo ()
67+ defaultConfigPath := ""
68+ if configDir != "" {
69+ defaultConfigPath = filepath .Join (configDir , "config.yaml" )
70+ } else {
71+ // Fallback if we can't determine config dir
72+ if home , err := os .UserHomeDir (); err == nil {
73+ defaultConfigPath = filepath .Join (home , ".config" , "coder_boundary" , "config.yaml" )
74+ }
75+ }
76+
6477 return & serpent.Command {
6578 Use : "boundary" ,
6679 Short : "Network isolation tool for monitoring and restricting HTTP/HTTPS requests" ,
@@ -70,7 +83,7 @@ func BaseCommand() *serpent.Command {
7083 Flag : "config" ,
7184 Env : "BOUNDARY_CONFIG" ,
7285 Description : "Path to YAML config file." ,
73- Default : "~/.config/coder_boundary/config.yaml" ,
86+ Default : defaultConfigPath ,
7487 Value : & config .Config ,
7588 YAML : "" ,
7689 },
@@ -109,15 +122,15 @@ func BaseCommand() *serpent.Command {
109122 Env : "BOUNDARY_PPROF" ,
110123 Description : "Enable pprof profiling server." ,
111124 Value : & config .Pprof .Enabled ,
112- YAML : "pprof.enabled " ,
125+ YAML : "pprof_enabled " ,
113126 },
114127 {
115128 Flag : "pprof-port" ,
116129 Env : "BOUNDARY_PPROF_PORT" ,
117130 Description : "Set port for pprof profiling server." ,
118131 Default : "6060" ,
119132 Value : & config .Pprof .Port ,
120- YAML : "pprof.port " ,
133+ YAML : "pprof_port " ,
121134 },
122135 },
123136 Handler : func (inv * serpent.Invocation ) error {
@@ -133,6 +146,23 @@ func isChild() bool {
133146
134147// Run executes the boundary command with the given configuration and arguments
135148func 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+
160+ configInJSON , err := json .Marshal (config )
161+ if err != nil {
162+ panic (err )
163+ }
164+ fmt .Printf ("%s\n " , configInJSON )
165+
136166 logger , err := setupLogging (config )
137167 if err != nil {
138168 return fmt .Errorf ("could not set up logging: %v" , err )
0 commit comments