diff options
author | Valery Piashchynski <[email protected]> | 2024-11-22 23:40:10 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-22 23:40:10 +0100 |
commit | dfb71afb844365a1fc0c819235f64a2417606a33 (patch) | |
tree | 9df5c495a93c60d1d0f7053e0448b7e7d7d06b64 /internal/rpc/client.go | |
parent | bd93d5c005b48a086646145827e302e2fd5d5872 (diff) | |
parent | 642e83ef2771ef6b99571626ecc188c9e41aeeb7 (diff) |
[#2063]: fix: properly parse includes outside the Configuration plugin
Diffstat (limited to 'internal/rpc/client.go')
-rw-r--r-- | internal/rpc/client.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/internal/rpc/client.go b/internal/rpc/client.go index 26d60d24..ba739d87 100644 --- a/internal/rpc/client.go +++ b/internal/rpc/client.go @@ -33,9 +33,6 @@ func NewClient(cfg string, flags []string) (*rpc.Client, error) { return nil, err } - // automatically inject ENV variables using ${ENV} pattern - expandEnvViper(v) - // override config Flags if len(flags) > 0 { for _, f := range flags { @@ -48,6 +45,20 @@ func NewClient(cfg string, flags []string) (*rpc.Client, error) { } } + ver := v.Get(versionKey) + if ver == nil { + return nil, fmt.Errorf("rr configuration file should contain a version e.g: version: 3") + } + + if _, ok := ver.(string); !ok { + return nil, fmt.Errorf("version should be a string: `version: \"3\"`, actual type is: %T", ver) + } + + err = handleInclude(ver.(string), v) + if err != nil { + return nil, fmt.Errorf("failed to handle includes: %w", err) + } + // rpc.listen might be set by the -o flags or env variable if !v.IsSet(rpcPlugin.PluginName) { return nil, errors.New("rpc service not specified in the configuration. Tip: add\n rpc:\n\r listen: rr_rpc_address") |