Skip to content

Commit

Permalink
Remove special cases from GetResourceName. (#762)
Browse files Browse the repository at this point in the history
Remove the unnecessary type checks from GetResourceName. Modern resource
types should always have a `GetName` accessor, so the only real special
case is for clusters.

Signed-off-by: James Peach <jpeach@apache.org>
  • Loading branch information
jpeach authored Aug 29, 2023
1 parent 0e7b0ab commit ff42c54
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions pkg/cache/v3/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ import (
"google.golang.org/protobuf/proto"

cluster "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
endpoint "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
listener "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
route "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
auth "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
runtime "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3"
"github.com/envoyproxy/go-control-plane/pkg/cache/types"
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
ratelimit "github.com/envoyproxy/go-control-plane/ratelimit/config/ratelimit/v3"
)

// GetResponseType returns the enumeration for a valid xDS type URL.
Expand Down Expand Up @@ -93,24 +90,6 @@ func GetResourceName(res types.Resource) string {
switch v := res.(type) {
case *endpoint.ClusterLoadAssignment:
return v.GetClusterName()
case *cluster.Cluster:
return v.GetName()
case *route.RouteConfiguration:
return v.GetName()
case *route.ScopedRouteConfiguration:
return v.GetName()
case *route.VirtualHost:
return v.GetName()
case *listener.Listener:
return v.GetName()
case *auth.Secret:
return v.GetName()
case *runtime.Runtime:
return v.GetName()
case *core.TypedExtensionConfig:
return v.GetName()
case *ratelimit.RateLimitConfig:
return v.GetName()
case types.ResourceWithName:
return v.GetName()
default:
Expand Down

0 comments on commit ff42c54

Please sign in to comment.