Skip to content
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

env var for config file added #135

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import (
func main() {
ctx := context.Background()

c, err := config.LoadConfig("/etc/config")
configPath := os.Getenv("CONFIG")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthyx what do you think is the proper solution here? Because we are thinking of having multiple configuration files...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, the goal is to split the config between component and cluster like in node-agent.

if configPath == "" {
configPath = "/etc/config"
}
Comment on lines +29 to +32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: It's a good practice to define default values as constants at the beginning of the file or package. This makes it easier to manage and change these values in the future.

Suggested change
configPath := os.Getenv("CONFIG")
if configPath == "" {
configPath = "/etc/config"
}
const defaultConfigPath = "/etc/config"
...
configPath := os.Getenv("CONFIG")
if configPath == "" {
configPath = defaultConfigPath
}


c, err := config.LoadConfig(configPath)
if err != nil {
logger.L().Ctx(ctx).Fatal("load config error", helpers.Error(err))
}
Comment on lines 35 to 37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Error messages should be descriptive and provide context for easier debugging. Consider adding more information to the error message when the configuration file fails to load.

Suggested change
if err != nil {
logger.L().Ctx(ctx).Fatal("load config error", helpers.Error(err))
}
if err != nil {
logger.L().Ctx(ctx).Fatal("Failed to load config from path: "+configPath, helpers.Error(err))
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Expand Down
Loading