diff --git a/apis/v1alpha2/httproute_types.go b/apis/v1alpha2/httproute_types.go index b0b49f15bc..45cdf9ff49 100644 --- a/apis/v1alpha2/httproute_types.go +++ b/apis/v1alpha2/httproute_types.go @@ -530,6 +530,23 @@ const ( HTTPRouteFilterExtensionRef HTTPRouteFilterType = "ExtensionRef" ) +// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. +type HTTPHeader struct { + // Name is the name of the HTTP query param to be matched. This must be an + // exact string match. (See + // https://tools.ietf.org/html/rfc7230#section-2.7.3). + // + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=256 + Name string `json:"name"` + + // Value is the value of HTTP query param to be matched. + // + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=1024 + Value string `json:"value"` +} + // HTTPRequestHeaderFilter defines configuration for the RequestHeaderModifier // filter. type HTTPRequestHeaderFilter struct { @@ -550,7 +567,7 @@ type HTTPRequestHeaderFilter struct { // Support: Extended // // +optional - Set map[string]string `json:"set,omitempty"` + Set []HTTPHeader `json:"set,omitempty"` // Add adds the given header (name, value) to the request // before the action. It appends to any existing values associated @@ -571,7 +588,7 @@ type HTTPRequestHeaderFilter struct { // Support: Extended // // +optional - Add map[string]string `json:"add,omitempty"` + Add []HTTPHeader `json:"add,omitempty"` // Remove the given header(s) from the HTTP request before the // action. The value of RemoveHeader is a list of HTTP header diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go index 4363d4527e..d0c34e637a 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1alpha2/zz_generated.deepcopy.go @@ -482,6 +482,21 @@ func (in *GatewayTLSConfig) DeepCopy() *GatewayTLSConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPHeader) DeepCopyInto(out *HTTPHeader) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPHeader. +func (in *HTTPHeader) DeepCopy() *HTTPHeader { + if in == nil { + return nil + } + out := new(HTTPHeader) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPHeaderMatch) DeepCopyInto(out *HTTPHeaderMatch) { *out = *in @@ -552,17 +567,13 @@ func (in *HTTPRequestHeaderFilter) DeepCopyInto(out *HTTPRequestHeaderFilter) { *out = *in if in.Set != nil { in, out := &in.Set, &out.Set - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = make([]HTTPHeader, len(*in)) + copy(*out, *in) } if in.Add != nil { in, out := &in.Add, &out.Add - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = make([]HTTPHeader, len(*in)) + copy(*out, *in) } if in.Remove != nil { in, out := &in.Remove, &out.Remove diff --git a/config/crd/bases/networking.x-k8s.io_httproutes.yaml b/config/crd/bases/networking.x-k8s.io_httproutes.yaml index fc6c45f27c..b2ea03fc94 100644 --- a/config/crd/bases/networking.x-k8s.io_httproutes.yaml +++ b/config/crd/bases/networking.x-k8s.io_httproutes.yaml @@ -1130,8 +1130,6 @@ spec: Core" properties: add: - additionalProperties: - type: string description: "Add adds the given header (name, value) to the request before the action. It appends to any existing values associated with the header name. @@ -1139,7 +1137,28 @@ spec: Config: add: {\"my-header\": \"bar\"} \n Output: \ GET /foo HTTP/1.1 my-header: foo my-header: bar \n Support: Extended" - type: object + items: + description: HTTPHeader represents an HTTP Header + name and value as defined by RFC 7230. + properties: + name: + description: Name is the name of the HTTP query + param to be matched. This must be an exact + string match. (See https://tools.ietf.org/html/rfc7230#section-2.7.3). + maxLength: 256 + minLength: 1 + type: string + value: + description: Value is the value of HTTP query + param to be matched. + maxLength: 1024 + minLength: 1 + type: string + required: + - name + - value + type: object + type: array remove: description: "Remove the given header(s) from the HTTP request before the action. The value of RemoveHeader @@ -1155,14 +1174,33 @@ spec: maxItems: 16 type: array set: - additionalProperties: - type: string description: "Set overwrites the request with the given header (name, value) before the action. \n Input: GET /foo HTTP/1.1 my-header: foo \n Config: \ set: {\"my-header\": \"bar\"} \n Output: GET /foo HTTP/1.1 my-header: bar \n Support: Extended" - type: object + items: + description: HTTPHeader represents an HTTP Header + name and value as defined by RFC 7230. + properties: + name: + description: Name is the name of the HTTP query + param to be matched. This must be an exact + string match. (See https://tools.ietf.org/html/rfc7230#section-2.7.3). + maxLength: 256 + minLength: 1 + type: string + value: + description: Value is the value of HTTP query + param to be matched. + maxLength: 1024 + minLength: 1 + type: string + required: + - name + - value + type: object + type: array type: object requestMirror: description: "RequestMirror defines a schema for a filter @@ -1350,8 +1388,6 @@ spec: Support: Core" properties: add: - additionalProperties: - type: string description: "Add adds the given header (name, value) to the request before the action. It appends to any existing values associated @@ -1360,7 +1396,29 @@ spec: {\"my-header\": \"bar\"} \n Output: GET /foo HTTP/1.1 my-header: foo my-header: bar \n Support: Extended" - type: object + items: + description: HTTPHeader represents an HTTP + Header name and value as defined by RFC + 7230. + properties: + name: + description: Name is the name of the HTTP + query param to be matched. This must + be an exact string match. (See https://tools.ietf.org/html/rfc7230#section-2.7.3). + maxLength: 256 + minLength: 1 + type: string + value: + description: Value is the value of HTTP + query param to be matched. + maxLength: 1024 + minLength: 1 + type: string + required: + - name + - value + type: object + type: array remove: description: "Remove the given header(s) from the HTTP request before the action. The value @@ -1377,15 +1435,35 @@ spec: maxItems: 16 type: array set: - additionalProperties: - type: string description: "Set overwrites the request with the given header (name, value) before the action. \n Input: GET /foo HTTP/1.1 my-header: foo \n Config: set: {\"my-header\": \"bar\"} \n Output: GET /foo HTTP/1.1 my-header: bar \n Support: Extended" - type: object + items: + description: HTTPHeader represents an HTTP + Header name and value as defined by RFC + 7230. + properties: + name: + description: Name is the name of the HTTP + query param to be matched. This must + be an exact string match. (See https://tools.ietf.org/html/rfc7230#section-2.7.3). + maxLength: 256 + minLength: 1 + type: string + value: + description: Value is the value of HTTP + query param to be matched. + maxLength: 1024 + minLength: 1 + type: string + required: + - name + - value + type: object + type: array type: object requestMirror: description: "RequestMirror defines a schema for