Add appProtocol to EndpointSlice.Port

This commit is contained in:
John Howard
2019-10-16 14:48:12 -07:00
parent 077f825c58
commit d00794ca60
12 changed files with 185 additions and 49 deletions

View File

@@ -88,6 +88,34 @@ func TestValidateEndpointSlice(t *testing.T) {
}},
},
},
"app-protocols": {
expectedErrors: 0,
endpointSlice: &discovery.EndpointSlice{
ObjectMeta: standardMeta,
AddressType: addressTypePtr(discovery.AddressTypeIP),
Ports: []discovery.EndpointPort{{
Name: utilpointer.StringPtr("one"),
Protocol: protocolPtr(api.ProtocolTCP),
AppProtocol: utilpointer.StringPtr("HTTP"),
}, {
Name: utilpointer.StringPtr("two"),
Protocol: protocolPtr(api.ProtocolTCP),
AppProtocol: utilpointer.StringPtr("https"),
}, {
Name: utilpointer.StringPtr("three"),
Protocol: protocolPtr(api.ProtocolTCP),
AppProtocol: utilpointer.StringPtr("my-protocol"),
}, {
Name: utilpointer.StringPtr("four"),
Protocol: protocolPtr(api.ProtocolTCP),
AppProtocol: utilpointer.StringPtr("example.com/custom-protocol"),
}},
Endpoints: []discovery.Endpoint{{
Addresses: generateIPAddresses(1),
Hostname: utilpointer.StringPtr("valid-123"),
}},
},
},
"empty-port-name": {
expectedErrors: 0,
endpointSlice: &discovery.EndpointSlice{
@@ -390,6 +418,22 @@ func TestValidateEndpointSlice(t *testing.T) {
}},
},
},
"bad-app-protocol": {
expectedErrors: 1,
endpointSlice: &discovery.EndpointSlice{
ObjectMeta: standardMeta,
AddressType: addressTypePtr(discovery.AddressTypeIP),
Ports: []discovery.EndpointPort{{
Name: utilpointer.StringPtr("http"),
Protocol: protocolPtr(api.ProtocolTCP),
AppProtocol: utilpointer.StringPtr("--"),
}},
Endpoints: []discovery.Endpoint{{
Addresses: generateIPAddresses(1),
Hostname: utilpointer.StringPtr("valid-123"),
}},
},
},
"empty-everything": {
expectedErrors: 3,
endpointSlice: &discovery.EndpointSlice{