Aias00 commented on code in PR #995:
URL: https://github.com/apache/dubbo-go-pixiu/pull/995#discussion_r3565778773
##########
admin/core/server.go:
##########
@@ -48,9 +48,13 @@ type server interface {
}
// RunServer start server
-func RunServer() {
+func RunServer() error {
// load config
- global.VP = Viper()
+ vp, err := Viper()
Review Comment:
Fixed in `e6a14199`.
`configPath` is now threaded explicitly through the whole chain:
`Start(configPath)` → `RunServer(configPath)` → `Viper(configPath)`. The CLI's
`--config/-c` value (already held in `cmd/admin.configPath` and defaulted in
`initDefaultValue()`) is passed into `Start(configPath)` in `RunE`, so a
user-specified admin config file is loaded instead of being silently ignored.
In `Viper` I also removed the stdlib `flag.StringVar`/`flag.Parse()`
fallback (it conflicted with cobra's flag ownership and was the root cause of
the path being ignored). `Viper(configPath)` now resolves the path purely from
the argument, falling back to the `GVA_CONFIG` env var and then the default
`config.yaml` only when `configPath` is empty.
Tests added in `admin/core/server_test.go`:
- `TestViper_NonDefaultPathHonored` — writes a temp `config.yaml` with
`system.addr: 9999`, calls `Viper(tmpPath)`, asserts `global.CONFIG.System.Addr
== 9999` and that `vp.ConfigFileUsed()` is the explicit path (not the default).
- `TestViper_MissingFileReturnsError` — a non-existent explicit path returns
a non-nil error (not silently defaulted).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]