MCPcopy
hub / github.com/grpc/grpc-go / convert

Method convert

internal/xds/xdsclient/xdsresource/metadata.go:90–107  ·  view source on GitHub ↗
(anyProto *anypb.Any)

Source from the content-addressed store, hash-verified

88type proxyAddressConvertor struct{}
89
90func (proxyAddressConvertor) convert(anyProto *anypb.Any) (any, error) {
91 addressProto := &v3corepb.Address{}
92 if err := anyProto.UnmarshalTo(addressProto); err != nil {
93 return nil, fmt.Errorf("failed to unmarshal resource from Any proto: %v", err)
94 }
95 socketaddress := addressProto.GetSocketAddress()
96 if socketaddress == nil {
97 return nil, fmt.Errorf("no socket_address field in metadata")
98 }
99 if _, err := netip.ParseAddr(socketaddress.GetAddress()); err != nil {
100 return nil, fmt.Errorf("address field is not a valid IPv4 or IPv6 address: %q", socketaddress.GetAddress())
101 }
102 portvalue := socketaddress.GetPortValue()
103 if portvalue == 0 {
104 return nil, fmt.Errorf("port value not set in socket_address")
105 }
106 return ProxyAddressMetadataValue{Address: parseAddress(socketaddress)}, nil
107}
108
109// AudienceMetadataValue holds the audience parsed from the
110// envoy.extensions.filters.http.gcp_authn.v3.Audience proto message, as

Callers

nothing calls this directly

Calls 3

parseAddressFunction · 0.85
ErrorfMethod · 0.65
GetAddressMethod · 0.45

Tested by

no test coverage detected