in internal/manifests/collector/parser/receiver/receiver_jaeger.go [51:118]
func (j *JaegerReceiverParser) Ports() ([]corev1.ServicePort, error) {
ports := []corev1.ServicePort{}
for _, protocol := range []struct {
name string
transportProtocol corev1.Protocol
appProtocol string
defaultPort int32
}{
{
name: "grpc",
defaultPort: defaultGRPCPort,
transportProtocol: corev1.ProtocolTCP,
appProtocol: "grpc",
},
{
name: "thrift_http",
defaultPort: defaultThriftHTTPPort,
transportProtocol: corev1.ProtocolTCP,
appProtocol: "http",
},
{
name: "thrift_compact",
defaultPort: defaultThriftCompactPort,
transportProtocol: corev1.ProtocolUDP,
},
{
name: "thrift_binary",
defaultPort: defaultThriftBinaryPort,
transportProtocol: corev1.ProtocolUDP,
},
} {
// do we have the protocol specified at all?
if receiverProtocol, ok := j.config[protocol.name]; ok {
// we have the specified protocol, we definitely need a service port
nameWithProtocol := fmt.Sprintf("%s-%s", j.name, protocol.name)
var protocolPort *corev1.ServicePort
// do we have a configuration block for the protocol?
settings, ok := receiverProtocol.(map[interface{}]interface{})
if ok {
protocolPort = singlePortFromConfigEndpoint(j.logger, nameWithProtocol, settings)
}
// have we parsed a port based on the configuration block?
// if not, we use the default port
if protocolPort == nil {
protocolPort = &corev1.ServicePort{
Name: naming.PortName(nameWithProtocol, protocol.defaultPort),
Port: protocol.defaultPort,
}
}
// set the appropriate transport protocol (i.e. TCP/UDP) for this kind of receiver protocol
protocolPort.Protocol = protocol.transportProtocol
if protocol.appProtocol != "" {
c := protocol.appProtocol
protocolPort.AppProtocol = &c
}
// at this point, we *have* a port specified, add it to the list of ports
ports = append(ports, *protocolPort)
}
}
return ports, nil
}