-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do sockaddr template parsing only when needed (#15224)
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
core/config: Only ask the system about network interfaces when address configs contain a template having the format: {{ ... }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package configutil | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseSingleIPTemplate(t *testing.T) { | ||
type args struct { | ||
ipTmpl string | ||
} | ||
tests := []struct { | ||
name string | ||
arg string | ||
want string | ||
wantErr assert.ErrorAssertionFunc | ||
}{ | ||
{ | ||
name: "test https addr", | ||
arg: "https://vaultproject.io:8200", | ||
want: "https://vaultproject.io:8200", | ||
wantErr: assert.NoError, | ||
}, | ||
{ | ||
name: "test invalid template func", | ||
arg: "{{FooBar}}", | ||
want: "", | ||
wantErr: assert.Error, | ||
}, | ||
{ | ||
name: "test partial template", | ||
arg: "{{FooBar", | ||
want: "{{FooBar", | ||
wantErr: assert.NoError, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ParseSingleIPTemplate(tt.arg) | ||
if !tt.wantErr(t, err, fmt.Sprintf("ParseSingleIPTemplate(%v)", tt.arg)) { | ||
return | ||
} | ||
|
||
assert.Equalf(t, tt.want, got, "ParseSingleIPTemplate(%v)", tt.arg) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters