-
Notifications
You must be signed in to change notification settings - Fork 687
/
resource.go
47 lines (39 loc) · 1.59 KB
/
resource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package resource
import (
"github.com/golang/protobuf/ptypes"
core "github.com/datawire/ambassador/pkg/api/envoy/config/core/v3"
listener "github.com/datawire/ambassador/pkg/api/envoy/config/listener/v3"
hcm "github.com/datawire/ambassador/pkg/api/envoy/extensions/filters/network/http_connection_manager/v3"
)
// Resource types in xDS v3.
const (
apiTypePrefix = "type.googleapis.com/"
EndpointType = apiTypePrefix + "envoy.config.endpoint.v3.ClusterLoadAssignment"
ClusterType = apiTypePrefix + "envoy.config.cluster.v3.Cluster"
RouteType = apiTypePrefix + "envoy.config.route.v3.RouteConfiguration"
ListenerType = apiTypePrefix + "envoy.config.listener.v3.Listener"
SecretType = apiTypePrefix + "envoy.extensions.transport_sockets.tls.v3.Secret"
RuntimeType = apiTypePrefix + "envoy.service.runtime.v3.Runtime"
// AnyType is used only by ADS
AnyType = ""
)
// Fetch urls in xDS v3.
const (
FetchEndpoints = "/v3/discovery:endpoints"
FetchClusters = "/v3/discovery:clusters"
FetchListeners = "/v3/discovery:listeners"
FetchRoutes = "/v3/discovery:routes"
FetchSecrets = "/v3/discovery:secrets"
FetchRuntimes = "/v3/discovery:runtime"
)
// DefaultAPIVersion is the api version
const DefaultAPIVersion = core.ApiVersion_V3
// GetHTTPConnectionManager creates a HttpConnectionManager from filter
func GetHTTPConnectionManager(filter *listener.Filter) *hcm.HttpConnectionManager {
config := &hcm.HttpConnectionManager{}
// use typed config if available
if typedConfig := filter.GetTypedConfig(); typedConfig != nil {
ptypes.UnmarshalAny(typedConfig, config)
}
return config
}