-
Notifications
You must be signed in to change notification settings - Fork 9
chore: upgrade all dependencies to latest versions #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
4d6b32b
9b36aef
11b2a43
c705dba
306d877
905cee3
f82102c
e99f18b
088d69f
816e009
264d39f
7246c9d
5a20ab1
441c374
ac37120
28abc09
313492c
21b8dbe
9ac0e8f
a9c4ae7
367e610
df95c2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
|
|
||
|
|
@@ -12,7 +11,6 @@ import ( | |
| "github.com/raystack/compass/internal/store/postgres" | ||
| "github.com/raystack/compass/pkg/metrics" | ||
| "github.com/raystack/compass/pkg/telemetry" | ||
| "github.com/raystack/salt/cmdx" | ||
| "github.com/raystack/salt/config" | ||
| "github.com/spf13/cobra" | ||
| "gopkg.in/yaml.v2" | ||
|
|
@@ -46,13 +44,13 @@ func configInitCommand() *cobra.Command { | |
| "group": "core", | ||
| }, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| cfg := cmdx.SetConfig("compass") | ||
| loader := config.NewLoader(config.WithAppConfig("compass")) | ||
|
|
||
| if err := cfg.Init(&Config{}); err != nil { | ||
| if err := loader.Init(&Config{}); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| fmt.Printf("config created: %v\n", cfg.File()) | ||
| fmt.Println("config created") | ||
| return nil | ||
| }, | ||
| } | ||
|
|
@@ -100,35 +98,26 @@ type Config struct { | |
|
|
||
| func LoadConfig() (*Config, error) { | ||
| var cfg Config | ||
| err := LoadFromCurrentDir(&cfg) | ||
|
|
||
| if errors.As(err, &config.ConfigFileNotFoundError{}) { | ||
| err := cmdx.SetConfig("compass").Load(&cfg) | ||
| if err != nil { | ||
| if errors.As(err, &config.ConfigFileNotFoundError{}) { | ||
| return &cfg, ErrConfigNotFound | ||
| } | ||
| return &cfg, err | ||
| // Try loading from current directory first | ||
| err := LoadFromCurrentDir(&cfg) | ||
| if err != nil { | ||
| // Fall back to app config directory | ||
| loader := config.NewLoader(config.WithAppConfig("compass")) | ||
| if loadErr := loader.Load(&cfg); loadErr != nil { | ||
| return &cfg, ErrConfigNotFound | ||
|
Comment on lines
+102
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't hide invalid config files behind fallback. This now falls back on any 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| return &cfg, nil | ||
| } | ||
|
|
||
| func LoadFromCurrentDir(cfg *Config) error { | ||
| var opts []config.LoaderOption | ||
| opts = append(opts, | ||
| config.WithPath("./"), | ||
| config.WithFile("config.yaml"), | ||
| config.WithEnvKeyReplacer(".", "_"), | ||
| return config.NewLoader( | ||
| config.WithFile("./config.yaml"), | ||
| config.WithEnvPrefix("COMPASS"), | ||
| ) | ||
|
|
||
| return config.NewLoader(opts...).Load(cfg) | ||
| ).Load(cfg) | ||
|
Comment on lines
114
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the local config filename with the CLI guidance. This lookup now uses 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| func LoadConfigFromFlag(cfgFile string, cfg *Config) error { | ||
| var opts []config.LoaderOption | ||
| opts = append(opts, config.WithFile(cfgFile)) | ||
|
|
||
| return config.NewLoader(opts...).Load(cfg) | ||
| return config.NewLoader(config.WithFile(cfgFile)).Load(cfg) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: raystack/compass
Length of output: 75
🏁 Script executed:
cat -n ./cli/config.go | head -150Repository: raystack/compass
Length of output: 3794
🏁 Script executed:
cat -n ./cli/config.go | tail -50Repository: raystack/compass
Length of output: 1562
Add
config.WithEnvPrefix("COMPASS")to all config loader paths for consistency.Environment variable overrides (
COMPASS_*) are currently only applied when loading from the current directory. The app-config fallback (line 106) and the--configflag path (line 122) omit the env prefix, so these configuration values are ignored in those scenarios.Suggested change
📝 Committable suggestion
🤖 Prompt for AI Agents