-
Notifications
You must be signed in to change notification settings - Fork 218
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
Introduce environment variable for custom config dir #291
Conversation
For me this looks good! |
pkg/config/config.go
Outdated
if util.FileExists(filePath) { | ||
return filePath, nil | ||
return cfgFile, nil |
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.
This is always an empty string here, right? I'm sure I'm reading it wrong, but where is cfgFile
set?
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.
Thanks for pointing that out. I improved that and also added a test.
pkg/config/config.go
Outdated
@@ -17,7 +17,7 @@ package config | |||
import ( | |||
"fmt" | |||
"os" | |||
"path" | |||
"path/filepath" |
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.
Just being clear, we're changing this why? looking it up, is the purpose for platform compatibility in general? Does this belong in the same PR?
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.
Good point and I probably was just to lazy to factor that out. I notice that usage of path
vs. filepath
is inconsistent and just fixed it along the way. And yes, the reason is platform compatibility. I'm gonna create a separate PR for this.
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.
I created #292
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.
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.
I rebased now after the merge.
@@ -88,8 +88,12 @@ func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*C | |||
v.SetConfigFile(cfgFile) | |||
} else { | |||
v.SetConfigName("ct") | |||
for _, searchLocation := range configSearchLocations { | |||
v.AddConfigPath(searchLocation) | |||
if cfgFile, ok := os.LookupEnv("CT_CONFIG_DIR"); ok { |
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.
I get the use case here, but just checking on implementation. We have --config
flag now, not --config-dir
. Why not keep it consistent with CT_CONFIG
path to file rather than dir?
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.
I probalby should have explained that better. CT_CONFIG_DIR
overrides the default locations where config files are searched. This is not only about the config file for ct but also those for Yamale and yamllint. This will be required when we install ct into a cache location in #58, so config files are still found.
a21424a
to
cf21518
Compare
Signed-off-by: Reinhard Nägele <[email protected]>
Signed-off-by: Reinhard Nägele <[email protected]>
cf21518
to
eb437a1
Compare
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.
💯
Signed-off-by: Reinhard Nägele [email protected]