Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jasonmccallister/envoy-xds-types
Go types useful when creating Envoy XDS API responses
https://github.com/jasonmccallister/envoy-xds-types
envoy envoyproxy rest xds-api
Last synced: about 2 months ago
JSON representation
Go types useful when creating Envoy XDS API responses
- Host: GitHub
- URL: https://github.com/jasonmccallister/envoy-xds-types
- Owner: jasonmccallister
- License: mit
- Created: 2022-05-25T21:22:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-26T04:21:47.000Z (over 2 years ago)
- Last Synced: 2024-10-13T03:47:34.400Z (3 months ago)
- Topics: envoy, envoyproxy, rest, xds-api
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Envoy XDS Types
This package provides the Go types for the Envoy XDS APIs.
## Creating an XDS API Cluster REST Discovery Response
To create a CDS response, use the `cluster.NewResponse` func.
```go
package mainimport (
"encoding/json"
"log""github.com/jasonmccallister/envoy-xds-types/cluster"
)func main() {
// create the cluster resources
resources := []cluster.Resource{
{
ResourceType: "type.googleapis.com/envoy.config.cluster.v3.Cluster",
Type: "LOGICAL_DNS",
Name: "cluster_name",
DNSLookupFamily: "V4_ONLY",
LoadAssignment: cluster.LoadAssignment{
ClusterName: "cluster_name",
Endpoints: []cluster.Endpoints{
{
LbEndpoints: cluster.LBEndpoints{
Endpoint: cluster.LBEndpoint{
HealthCheckConfig: &cluster.HealthCheckConfig{
Hostname: "example.com",
PortValue: 443,
},
Address: cluster.Address{
SocketAddress: cluster.SocketAddress{
Address: "example.com",
PortValue: 443,
},
},
},
},
},
},
},
TransportSocket: &cluster.TransportSocket{
Name: "envoy.transport_sockets.tls",
TypedConfig: cluster.TransportSocketTypedConfig{
Type: "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext",
SNI: "example.com",
},
},
},
}// generate the cluster response with those resources
response := cluster.NewResponse("V3", cluster.ControlPlane{Identifier: "control-plane-id"}, resources)// marshal the response to JSON
data, err := json.Marshal(response)
if err != nil {
log.Fatal("Error marshalling response: ", err)
}// return the response
}
```