mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 10:48:15 +00:00
support ipv6 in bind address
use split host port func instead trim specific character add unit test for metrics and healthz bind address recover import package refactor set default kube proxy configuration fix ipv4 condition fix set default port condition rewrite call function occasion to reduce error set ipv6 default value move get GetBindAddressHostPort to util use one func to handle deprecated series update bazel define address type return earlier in the error case refactor set default kube proxy configuration logic recover import package preserve some of the original comments add get default address func add append port if needed unit test rewrite unit test for deprecated flags remove unused codes
This commit is contained in:
@@ -396,3 +396,50 @@ func TestGetNodeAddressses(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppendPortIfNeeded(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
addr string
|
||||
port int32
|
||||
expect string
|
||||
}{
|
||||
{
|
||||
name: "IPv4 all-zeros bind address has port",
|
||||
addr: "0.0.0.0:12345",
|
||||
port: 23456,
|
||||
expect: "0.0.0.0:12345",
|
||||
},
|
||||
{
|
||||
name: "non-zeros IPv4 config",
|
||||
addr: "9.8.7.6",
|
||||
port: 12345,
|
||||
expect: "9.8.7.6:12345",
|
||||
},
|
||||
{
|
||||
name: "IPv6 \"[::]\" bind address has port",
|
||||
addr: "[::]:12345",
|
||||
port: 23456,
|
||||
expect: "[::]:12345",
|
||||
},
|
||||
{
|
||||
name: "IPv6 config",
|
||||
addr: "fd00:1::5",
|
||||
port: 23456,
|
||||
expect: "[fd00:1::5]:23456",
|
||||
},
|
||||
{
|
||||
name: "Invalid IPv6 Config",
|
||||
addr: "[fd00:1::5]",
|
||||
port: 12345,
|
||||
expect: "[fd00:1::5]",
|
||||
},
|
||||
}
|
||||
|
||||
for i := range testCases {
|
||||
got := AppendPortIfNeeded(testCases[i].addr, testCases[i].port)
|
||||
if testCases[i].expect != got {
|
||||
t.Errorf("case %s: expected %v, got %v", testCases[i].name, testCases[i].expect, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user