-
Notifications
You must be signed in to change notification settings - Fork 687
/
resource.go
51 lines (43 loc) · 1.69 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
48
49
50
51
package resource
import (
"github.com/golang/protobuf/ptypes"
core "github.com/datawire/ambassador/pkg/api/envoy/api/v2/core"
listener "github.com/datawire/ambassador/pkg/api/envoy/api/v2/listener"
hcm "github.com/datawire/ambassador/pkg/api/envoy/config/filter/network/http_connection_manager/v2"
"github.com/datawire/ambassador/pkg/envoy-control-plane/conversion"
)
// Resource types in xDS v2.
const (
apiTypePrefix = "type.googleapis.com/envoy.api.v2."
discoveryTypePrefix = "type.googleapis.com/envoy.service.discovery.v2."
EndpointType = apiTypePrefix + "ClusterLoadAssignment"
ClusterType = apiTypePrefix + "Cluster"
RouteType = apiTypePrefix + "RouteConfiguration"
ListenerType = apiTypePrefix + "Listener"
SecretType = apiTypePrefix + "auth.Secret"
RuntimeType = discoveryTypePrefix + "Runtime"
// AnyType is used only by ADS
AnyType = ""
)
// Fetch urls in xDS v2.
const (
FetchEndpoints = "/v2/discovery:endpoints"
FetchClusters = "/v2/discovery:clusters"
FetchListeners = "/v2/discovery:listeners"
FetchRoutes = "/v2/discovery:routes"
FetchSecrets = "/v2/discovery:secrets"
FetchRuntimes = "/v2/discovery:runtime"
)
// DefaultAPIVersion is the api version
const DefaultAPIVersion = core.ApiVersion_V2
// 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)
} else {
conversion.StructToMessage(filter.GetConfig(), config)
}
return config
}