Skip to content

Commit 642e83e

Browse files
committed
fix: expand envs for the root and included files
Signed-off-by: Valery Piashchynski <[email protected]>
1 parent 8c9aed5 commit 642e83e

7 files changed

+15
-0
lines changed

internal/rpc/client_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ func TestNewClient_WithIncludes(t *testing.T) {
6262

6363
assert.NotNil(t, c)
6464
assert.NoError(t, err)
65+
66+
assert.NoError(t, c.Close())
6567
}
6668

6769
func TestNewClient_SuccessfullyConnectedOverride(t *testing.T) {

internal/rpc/includes.go

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func getConfiguration(path string) (map[string]any, string, error) {
3737
}
3838

3939
func handleInclude(rootVersion string, v *viper.Viper) error {
40+
// automatically inject ENV variables using ${ENV} pattern
41+
// root config
42+
expandEnvViper(v)
43+
4044
ifiles := v.GetStringSlice(includeKey)
4145
if ifiles == nil {
4246
return nil
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
version: "3"
2+
13
rpc:
24
listen: tcp://127.0.0.1:55554
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version: "3"

internal/rpc/test/config_rpc_ok.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
version: "3"
2+
13
rpc:
24
listen: tcp://127.0.0.1:55554
+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
version: "3"
2+
13
rpc:
24
listen: ${RPC}
+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
version: "3"
2+
13
rpc:
24
$foo bar

0 commit comments

Comments
 (0)