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