diff options
author | Valery Piashchynski <[email protected]> | 2024-11-21 16:05:43 +0100 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2024-11-21 16:05:43 +0100 |
commit | 642e83ef2771ef6b99571626ecc188c9e41aeeb7 (patch) | |
tree | 9df5c495a93c60d1d0f7053e0448b7e7d7d06b64 | |
parent | 8c9aed54caa5efd8e2e292086302e1db14d11213 (diff) |
fix: expand envs for the root and included files
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r-- | internal/rpc/client_test.go | 2 | ||||
-rw-r--r-- | internal/rpc/includes.go | 4 | ||||
-rw-r--r-- | internal/rpc/test/config_rpc_conn_err.yaml | 2 | ||||
-rw-r--r-- | internal/rpc/test/config_rpc_empty.yaml | 1 | ||||
-rw-r--r-- | internal/rpc/test/config_rpc_ok.yaml | 2 | ||||
-rw-r--r-- | internal/rpc/test/config_rpc_ok_env.yaml | 2 | ||||
-rw-r--r-- | internal/rpc/test/config_rpc_wrong.yaml | 2 |
7 files changed, 15 insertions, 0 deletions
diff --git a/internal/rpc/client_test.go b/internal/rpc/client_test.go index 79335c0c..4a060f33 100644 --- a/internal/rpc/client_test.go +++ b/internal/rpc/client_test.go @@ -62,6 +62,8 @@ func TestNewClient_WithIncludes(t *testing.T) { assert.NotNil(t, c) assert.NoError(t, err) + + assert.NoError(t, c.Close()) } func TestNewClient_SuccessfullyConnectedOverride(t *testing.T) { diff --git a/internal/rpc/includes.go b/internal/rpc/includes.go index 834cf034..87b00001 100644 --- a/internal/rpc/includes.go +++ b/internal/rpc/includes.go @@ -37,6 +37,10 @@ func getConfiguration(path string) (map[string]any, string, error) { } func handleInclude(rootVersion string, v *viper.Viper) error { + // automatically inject ENV variables using ${ENV} pattern + // root config + expandEnvViper(v) + ifiles := v.GetStringSlice(includeKey) if ifiles == nil { return nil diff --git a/internal/rpc/test/config_rpc_conn_err.yaml b/internal/rpc/test/config_rpc_conn_err.yaml index c7d31056..5438198f 100644 --- a/internal/rpc/test/config_rpc_conn_err.yaml +++ b/internal/rpc/test/config_rpc_conn_err.yaml @@ -1,2 +1,4 @@ +version: "3" + rpc: listen: tcp://127.0.0.1:55554 diff --git a/internal/rpc/test/config_rpc_empty.yaml b/internal/rpc/test/config_rpc_empty.yaml index e69de29b..5db6fe96 100644 --- a/internal/rpc/test/config_rpc_empty.yaml +++ b/internal/rpc/test/config_rpc_empty.yaml @@ -0,0 +1 @@ +version: "3" diff --git a/internal/rpc/test/config_rpc_ok.yaml b/internal/rpc/test/config_rpc_ok.yaml index c7d31056..5438198f 100644 --- a/internal/rpc/test/config_rpc_ok.yaml +++ b/internal/rpc/test/config_rpc_ok.yaml @@ -1,2 +1,4 @@ +version: "3" + rpc: listen: tcp://127.0.0.1:55554 diff --git a/internal/rpc/test/config_rpc_ok_env.yaml b/internal/rpc/test/config_rpc_ok_env.yaml index fd0d3f11..f5ae461e 100644 --- a/internal/rpc/test/config_rpc_ok_env.yaml +++ b/internal/rpc/test/config_rpc_ok_env.yaml @@ -1,2 +1,4 @@ +version: "3" + rpc: listen: ${RPC} diff --git a/internal/rpc/test/config_rpc_wrong.yaml b/internal/rpc/test/config_rpc_wrong.yaml index 8282ee1f..c4ff9c46 100644 --- a/internal/rpc/test/config_rpc_wrong.yaml +++ b/internal/rpc/test/config_rpc_wrong.yaml @@ -1,2 +1,4 @@ +version: "3" + rpc: $foo bar |