in grpc-xds/control-plane-go/pkg/xds/tls/transport_socket.go [35:52]
func CreateTransportSocket(upstreamOrDownstreamTLSContext proto.Message) (*corev3.TransportSocket, error) {
switch msg := upstreamOrDownstreamTLSContext.(type) {
case *tlsv3.UpstreamTlsContext:
case *tlsv3.DownstreamTlsContext:
default:
return nil, fmt.Errorf("expected either tlsv3.UpstreamTlsContext or tlsv3.DownstreamTlsContext, got %T", msg)
}
anyWrappedUpstreamTLSContext, err := anypb.New(upstreamOrDownstreamTLSContext)
if err != nil {
return nil, fmt.Errorf("could not marshall TLS Context +%v into Any instance: %w", upstreamOrDownstreamTLSContext, err)
}
return &corev3.TransportSocket{
Name: envoyTransportSocketsTLSName,
ConfigType: &corev3.TransportSocket_TypedConfig{
TypedConfig: anyWrappedUpstreamTLSContext,
},
}, nil
}