github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/pkg/resource/v3/resource.go (about) 1 package resource 2 3 import ( 4 "github.com/golang/protobuf/ptypes" 5 6 core "github.com/hxx258456/ccgo/go-control-plane/envoy/config/core/v3" 7 listener "github.com/hxx258456/ccgo/go-control-plane/envoy/config/listener/v3" 8 hcm "github.com/hxx258456/ccgo/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" 9 ) 10 11 // Type is an alias to string which we expose to users of the snapshot API which accepts `resource.Type` resource URLs. 12 type Type = string 13 14 // Resource types in xDS v3. 15 const ( 16 apiTypePrefix = "type.googleapis.com/" 17 EndpointType = apiTypePrefix + "envoy.config.endpoint.v3.ClusterLoadAssignment" 18 ClusterType = apiTypePrefix + "envoy.config.cluster.v3.Cluster" 19 RouteType = apiTypePrefix + "envoy.config.route.v3.RouteConfiguration" 20 ListenerType = apiTypePrefix + "envoy.config.listener.v3.Listener" 21 SecretType = apiTypePrefix + "envoy.extensions.transport_sockets.tls.v3.Secret" 22 ExtensionConfigType = apiTypePrefix + "envoy.config.core.v3.TypedExtensionConfig" 23 RuntimeType = apiTypePrefix + "envoy.service.runtime.v3.Runtime" 24 25 // AnyType is used only by ADS 26 AnyType = "" 27 ) 28 29 // Fetch urls in xDS v3. 30 const ( 31 FetchEndpoints = "/v3/discovery:endpoints" 32 FetchClusters = "/v3/discovery:clusters" 33 FetchListeners = "/v3/discovery:listeners" 34 FetchRoutes = "/v3/discovery:routes" 35 FetchSecrets = "/v3/discovery:secrets" //nolint:gosec 36 FetchRuntimes = "/v3/discovery:runtime" 37 FetchExtensionConfigs = "/v3/discovery:extension_configs" 38 ) 39 40 // DefaultAPIVersion is the api version 41 const DefaultAPIVersion = core.ApiVersion_V3 42 43 // GetHTTPConnectionManager creates a HttpConnectionManager 44 // from filter. Returns nil if the filter doesn't have a valid 45 // HttpConnectionManager configuration. 46 func GetHTTPConnectionManager(filter *listener.Filter) *hcm.HttpConnectionManager { 47 if typedConfig := filter.GetTypedConfig(); typedConfig != nil { 48 config := &hcm.HttpConnectionManager{} 49 if err := ptypes.UnmarshalAny(typedConfig, config); err == nil { 50 return config 51 } 52 } 53 54 return nil 55 }