Skip to content

Commit

Permalink
CRD fields with defaults must be optional
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Young <ynick@vmware.com>
  • Loading branch information
Nick Young committed Mar 22, 2022
1 parent 2dba758 commit fa2a997
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 406 deletions.
18 changes: 12 additions & 6 deletions apis/projectcontour/v1alpha1/contourconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type ContourConfigurationSpec struct {
// Envoy contains parameters for Envoy as well
// as how to optionally configure a managed Envoy fleet.
// +optional
// +kubebuilder:default={listener: {useProxyProtocol: false, disableAllowChunkedLength: false, connectionBalancer: "", tls: { minimumProtocolVersion: "1.2", cipherSuites: "[ECDHE-ECDSA-AES128-GCM-SHA256|ECDHE-ECDSA-CHACHA20-POLY1305]";"[ECDHE-RSA-AES128-GCM-SHA256|ECDHE-RSA-CHACHA20-POLY1305]";"ECDHE-ECDSA-AES256-GCM-SHA384";"ECDHE-RSA-AES256-GCM-SHA384" }}, service: {name: "envoy", namespace: "projectcontour"}, http: {address: "0.0.0.0", port: 8080, accessLog: "/dev/stdout"}, https: {address: "0.0.0.0", port: 8443, accessLog: "/dev/stdout"}, health: {address: "0.0.0.0", port: 8002}, metrics: {address: "0.0.0.0", port: 8002}, logging: { accessLogFormat: "envoy"}, defaultHTTPVersions: "HTTP/1.1";"HTTP/2", cluster: {dnsLookupFamily: "auto"}, network: { adminPort: 9001}}
// +kubebuilder:default={listener: {useProxyProtocol: false}}
Envoy *EnvoyConfig `json:"envoy"`

// Gateway contains parameters for the gateway-api Gateway that Contour
Expand Down Expand Up @@ -177,7 +177,8 @@ type HealthConfig struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:default="0.0.0.0"
Address string `json:"address"`
// +optional
Address string `json:"address,omitempty"`

// Defines the health port.
//
Expand All @@ -195,7 +196,8 @@ type MetricsConfig struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:default="0.0.0.0"
Address string `json:"address"`
//+ +optional
Address string `json:"address,omitempty"`

// Defines the metrics port.
//
Expand Down Expand Up @@ -273,7 +275,8 @@ type EnvoyConfig struct {

// Logging defines how Envoy's logs can be configured.
// +kubebuilder:default={ accessLogFormat: "envoy"}
Logging *EnvoyLogging `json:"logging"`
// +optional
Logging *EnvoyLogging `json:"logging,omitempty"`

// DefaultHTTPVersions defines the default set of HTTPS
// versions the proxy should accept. HTTP versions are
Expand All @@ -285,7 +288,8 @@ type EnvoyConfig struct {
// Other values will produce an error.
// The default includes both values.
// +kubebuilder:default="HTTP/1.1";"HTTP/2"
DefaultHTTPVersions []HTTPVersionType `json:"defaultHTTPVersions"`
// +optional
DefaultHTTPVersions []HTTPVersionType `json:"defaultHTTPVersions,omitempty"`

// Timeouts holds various configurable timeouts that can
// be set in the config file.
Expand Down Expand Up @@ -440,14 +444,16 @@ type EnvoyListener struct {
// Defaults to `0.0.0.0`.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:default="0.0.0.0"
// +optional
Address string `json:"address"`

// Defines an Envoy listener Port.
Port int `json:"port"`

// AccessLog defines where Envoy logs are outputted for this listener.
// +kubebuilder:default="/dev/stdout"
AccessLog string `json:"accessLog"`
// +optional
AccessLog string `json:"accessLog,omitempty"`
}

// EnvoyLogging defines how Envoy's logs can be configured.
Expand Down
100 changes: 0 additions & 100 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,43 +76,8 @@ spec:
type: boolean
envoy:
default:
cluster:
dnsLookupFamily: auto
defaultHTTPVersions:
- HTTP/1.1
- HTTP/2
health:
address: 0.0.0.0
port: 8002
http:
accessLog: /dev/stdout
address: 0.0.0.0
port: 8080
https:
accessLog: /dev/stdout
address: 0.0.0.0
port: 8443
listener:
connectionBalancer: ""
disableAllowChunkedLength: false
tls:
cipherSuites:
- '[ECDHE-ECDSA-AES128-GCM-SHA256|ECDHE-ECDSA-CHACHA20-POLY1305]'
- '[ECDHE-RSA-AES128-GCM-SHA256|ECDHE-RSA-CHACHA20-POLY1305]'
- ECDHE-ECDSA-AES256-GCM-SHA384
- ECDHE-RSA-AES256-GCM-SHA384
minimumProtocolVersion: "1.2"
useProxyProtocol: false
logging:
accessLogFormat: envoy
metrics:
address: 0.0.0.0
port: 8002
network:
adminPort: 9001
service:
name: envoy
namespace: projectcontour
description: Envoy contains parameters for Envoy as well as how to
optionally configure a managed Envoy fleet.
properties:
Expand Down Expand Up @@ -184,8 +149,6 @@ spec:
default: 8002
description: "Defines the health port. \n Defaults to `8002`."
type: integer
required:
- address
type: object
http:
default:
Expand All @@ -207,8 +170,6 @@ spec:
description: Defines an Envoy listener Port.
type: integer
required:
- accessLog
- address
- port
type: object
https:
Expand All @@ -231,8 +192,6 @@ spec:
description: Defines an Envoy listener Port.
type: integer
required:
- accessLog
- address
- port
type: object
listener:
Expand Down Expand Up @@ -372,8 +331,6 @@ spec:
description: Client key filename.
type: string
type: object
required:
- address
type: object
network:
default:
Expand Down Expand Up @@ -476,9 +433,6 @@ spec:
for more information."
type: string
type: object
required:
- defaultHTTPVersions
- logging
type: object
gateway:
description: Gateway contains parameters for the gateway-api Gateway
Expand Down Expand Up @@ -509,8 +463,6 @@ spec:
default: 8002
description: "Defines the health port. \n Defaults to `8002`."
type: integer
required:
- address
type: object
httpproxy:
default:
Expand Down Expand Up @@ -584,8 +536,6 @@ spec:
description: Client key filename.
type: string
type: object
required:
- address
type: object
policy:
description: Policy specifies default policy applied if not overridden
Expand Down Expand Up @@ -882,43 +832,8 @@ spec:
type: boolean
envoy:
default:
cluster:
dnsLookupFamily: auto
defaultHTTPVersions:
- HTTP/1.1
- HTTP/2
health:
address: 0.0.0.0
port: 8002
http:
accessLog: /dev/stdout
address: 0.0.0.0
port: 8080
https:
accessLog: /dev/stdout
address: 0.0.0.0
port: 8443
listener:
connectionBalancer: ""
disableAllowChunkedLength: false
tls:
cipherSuites:
- '[ECDHE-ECDSA-AES128-GCM-SHA256|ECDHE-ECDSA-CHACHA20-POLY1305]'
- '[ECDHE-RSA-AES128-GCM-SHA256|ECDHE-RSA-CHACHA20-POLY1305]'
- ECDHE-ECDSA-AES256-GCM-SHA384
- ECDHE-RSA-AES256-GCM-SHA384
minimumProtocolVersion: "1.2"
useProxyProtocol: false
logging:
accessLogFormat: envoy
metrics:
address: 0.0.0.0
port: 8002
network:
adminPort: 9001
service:
name: envoy
namespace: projectcontour
description: Envoy contains parameters for Envoy as well as how
to optionally configure a managed Envoy fleet.
properties:
Expand Down Expand Up @@ -991,8 +906,6 @@ spec:
description: "Defines the health port. \n Defaults to
`8002`."
type: integer
required:
- address
type: object
http:
default:
Expand All @@ -1014,8 +927,6 @@ spec:
description: Defines an Envoy listener Port.
type: integer
required:
- accessLog
- address
- port
type: object
https:
Expand All @@ -1038,8 +949,6 @@ spec:
description: Defines an Envoy listener Port.
type: integer
required:
- accessLog
- address
- port
type: object
listener:
Expand Down Expand Up @@ -1186,8 +1095,6 @@ spec:
description: Client key filename.
type: string
type: object
required:
- address
type: object
network:
default:
Expand Down Expand Up @@ -1293,9 +1200,6 @@ spec:
for more information."
type: string
type: object
required:
- defaultHTTPVersions
- logging
type: object
gateway:
description: Gateway contains parameters for the gateway-api Gateway
Expand Down Expand Up @@ -1327,8 +1231,6 @@ spec:
default: 8002
description: "Defines the health port. \n Defaults to `8002`."
type: integer
required:
- address
type: object
httpproxy:
default:
Expand Down Expand Up @@ -1403,8 +1305,6 @@ spec:
description: Client key filename.
type: string
type: object
required:
- address
type: object
policy:
description: Policy specifies default policy applied if not overridden
Expand Down
Loading

0 comments on commit fa2a997

Please sign in to comment.