Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
handle embedded struct more generally
Browse files Browse the repository at this point in the history
  • Loading branch information
serbrech committed Mar 6, 2018
1 parent f9b3fec commit 6e12bb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion envsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (e *envSource) analyzeStruct(configType reflect.Type, currentPath path) ([]
}
// If we're facing an embedded struct
if field.Anonymous {
values, err := e.analyzeStruct(field.Type, currentPath)
values, err := e.analyzeValue(field.Type, currentPath)

if err != nil {
return []*envValue{}, err
Expand Down
17 changes: 17 additions & 0 deletions envsource_analyzestruct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,23 @@ func TestAnalyzeStruct(t *testing.T) {
},
testAnalyzeStructShouldSucceed,
},
{
"WithAWebBasicAuth",
&struct {
Basic *Basic
UsersFile string
}{}, []*envValue{
&envValue{"UserZero", path{"Basic", "0"}},
&envValue{"UserOne", path{"Basic", "1"}},
&envValue{"path/to/file", path{"UsersFile"}},
},
map[string]string{
"BASIC_0": "UserZero",
"BASIC_1": "UserOne",
"USERS_FILE": "path/to/file",
},
testAnalyzeStructShouldSucceed,
},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit 6e12bb4

Please sign in to comment.