Skip to content

Commit

Permalink
Export the unwrapResource method, to allow callers outside of the pac…
Browse files Browse the repository at this point in the history
…kage (#6181)
  • Loading branch information
anicr7 committed Apr 11, 2023
1 parent efb2f45 commit 8374ff8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions xds/internal/xdsclient/xdsresource/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func IsEndpointsResource(url string) bool {
return url == version.V3EndpointsURL
}

// unwrapResource unwraps and returns the inner resource if it's in a resource
// UnwrapResource unwraps and returns the inner resource if it's in a resource
// wrapper. The original resource is returned if it's not wrapped.
func unwrapResource(r *anypb.Any) (*anypb.Any, error) {
func UnwrapResource(r *anypb.Any) (*anypb.Any, error) {
url := r.GetTypeUrl()
if url != version.V3ResourceWrapperURL {
// Not wrapped.
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/xdsclient/xdsresource/unmarshal_cds.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
const transportSocketName = "envoy.transport_sockets.tls"

func unmarshalClusterResource(r *anypb.Any) (string, ClusterUpdate, error) {
r, err := unwrapResource(r)
r, err := UnwrapResource(r)
if err != nil {
return "", ClusterUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/xdsclient/xdsresource/unmarshal_eds.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

func unmarshalEndpointsResource(r *anypb.Any) (string, EndpointsUpdate, error) {
r, err := unwrapResource(r)
r, err := UnwrapResource(r)
if err != nil {
return "", EndpointsUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/xdsclient/xdsresource/unmarshal_lds.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

func unmarshalListenerResource(r *anypb.Any) (string, ListenerUpdate, error) {
r, err := unwrapResource(r)
r, err := UnwrapResource(r)
if err != nil {
return "", ListenerUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/xdsclient/xdsresource/unmarshal_rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

func unmarshalRouteConfigResource(r *anypb.Any) (string, RouteConfigUpdate, error) {
r, err := unwrapResource(r)
r, err := UnwrapResource(r)
if err != nil {
return "", RouteConfigUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err)
}
Expand Down

0 comments on commit 8374ff8

Please sign in to comment.