Conversation
|
Provide only the file name instead of the file path. This is more convenient because |
starport/services/chain/chain.go
Outdated
| // ConfigName specifies a custom config file to use | ||
| func ConfigName(configName string) Option { | ||
| return func(c *Chain) { | ||
| c.options.ConfigName = configName |
There was a problem hiding this comment.
Maybe we can refactor LocateDefault func to Locate(root string, []string) where []string is usually set as conf.FileNames but when ConfigName option is used it is set as []string{configName}. This might simplify some parts in the code.
There was a problem hiding this comment.
LocateDefault has a different purpose, it has a list of file that can be considered as the default configuration then if we find nothing we can properly handle the error to say that we use a default hard coded configuration.
Custom option responds to a different logic, you always have a single file and if you don't find it you always return an error.
I think it's more maintainable to separate the two if we want to change the logic to search for the default configuration in the future
I think it is kind of expected to be able to provide a relative/abs path when setting a config path flag in a CLI. I beleive it is better to stick with this convention. |
I try with |
|
We can first run |
|
Nevermind I didn't notice this logic is from our side. It's easy to fix then |
ilgooz
left a comment
There was a problem hiding this comment.
Btw, can we avoid updating starport/ui/dist-go/statik/statik.go in case it contains an older version of the ui?
|
[EDIT] added ui to skipped dir for golint so no more problem |
fadeev
left a comment
There was a problem hiding this comment.
Works with a custom foo.yml config file.
| // make sure that config.yml exists. | ||
| if _, err := conf.Locate(c.app.Path); err != nil { | ||
| if c.options.ConfigFile != "" { | ||
| if _, err := os.Stat(c.options.ConfigFile); err != nil { |
There was a problem hiding this comment.
With #761 (review) we don't need a change in this code block as well. It can just call conf.Locate(root, c.options.ConfigFiles).
starport/services/chain/chain.go
Outdated
| } | ||
|
|
||
| // AppBackendConfigWatchPaths returns the files to watch for config changes | ||
| func (c *Chain) AppBackendConfigWatchPaths() []string { |
starport/services/chain/chain.go
Outdated
| func (c *Chain) Config() (conf.Config, error) { | ||
| path, err := conf.Locate(c.app.Path) | ||
| if c.options.ConfigFile != "" { | ||
| return conf.ParseFile(c.options.ConfigFile) |
There was a problem hiding this comment.
#761 (review) can eliminate this change as well.
| // ConfigFile specifies a custom config file to use | ||
| func ConfigFile(configFile string) Option { | ||
| return func(c *Chain) { | ||
| c.options.ConfigFile = configFile |
There was a problem hiding this comment.
Regarding to #761 (review), c.options.ConfigFile can be conf.FileNames by default and call to ConfigFile with a non-empty string will change it to []string{configFile}.
There was a problem hiding this comment.
I think it's a bit ambiguous. The option should be a single string, conf.FileNames is an array because you want to have several possibilities of the file name for the default config
| return err | ||
| } | ||
| if config != "" { | ||
| chainOption = append(chainOption, chain.ConfigFile(os.ExpandEnv(config))) |
There was a problem hiding this comment.
We can I think, pass this option anyway even if config path is an empty string but check for an empty string inside chain.ConfigFile to fallback to conf.FileNames.
There was a problem hiding this comment.
Mmmh then we don't use the benefit of this pattern which is to have optional parameters?
Or else we use a positional argument
|
Thank for the review I check this. |
* Custom config * Custom config option * Lint * Add test for custom config file * Change option name * SOme naming * Fix test * refacto: specify file name * Lint * Suport absolute paths * Revert statik.go * Lint * Add directory skip for lint * Ilker suggestions * Verifyu config exists * COnfigPath * No config check
-c/--configspecifies a custom starport config file for theservecommand