From 12f50b570706c6e34ad434fc5d4c8c814ef2288b Mon Sep 17 00:00:00 2001 From: Saloni Date: Tue, 27 Aug 2024 16:24:39 -0600 Subject: [PATCH 01/11] add api spec for snippets filter --- apis/v1alpha1/snippetsfilter_types.go | 105 +++++++ apis/v1alpha1/zz_generated.deepcopy.go | 84 +++++ .../gateway.nginx.org_snippetsfilters.yaml | 159 ++++++++++ site/content/reference/api.md | 297 ++++++++++++++++++ 4 files changed, 645 insertions(+) create mode 100644 apis/v1alpha1/snippetsfilter_types.go create mode 100644 config/crd/bases/gateway.nginx.org_snippetsfilters.yaml diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go new file mode 100644 index 0000000000..24e38100da --- /dev/null +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -0,0 +1,105 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:resource:categories=nginx-gateway-fabric,shortName=snippetsfilter +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` +// +kubebuilder:metadata:labels="gateway.networking.k8s.io/policy=direct" + +// SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the +// generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources. +type SnippetsFilter struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the SnippetsFilter. + Spec SnippetsFilterSpec `json:"spec"` + + // Status defines the state of the SnippetsFilter. + Status SnippetsFilterStatus `json:"status,omitempty"` +} + +// SnippetsFilterSpec defines the desired state of the SnippetsFilter. +type SnippetsFilterSpec struct { + // Snippets is a list of NGINX configuration snippets. + // There can only be one snippet per context. + // Allowed contexts: http, http.server, http.server.location, stream, stream.server. + Snippets []Snippet `json:"snippets"` +} + +// Snippet represents an NGINX configuration snippet. +type Snippet struct { + // Context is the NGINX context to insert the snippet into. + Context NginxContext `json:"context"` + + // Value is the NGINX configuration snippet. + Value string `json:"value"` +} + +// SnippetsFilterStatus defines the state of SnippetsFilter. +type SnippetsFilterStatus struct { + // Conditions describes the state of the SnippetsFilter. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=8 + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// SnippetsFilterConditionType is a type of condition associated with SnippetsFilter. +type SnippetsFilterConditionType string + +// SnippetsFilterConditionReason is a reason for a SnippetsFilter condition type. +type SnippetsFilterConditionReason string + +const ( + // SnippetsFilterConditionTypeAccepted indicates that the SnippetsFilter is accepted. + // + // Possible reasons for this condition to be True: + // + // * Accepted + // + // Possible reasons for this condition to be False: + // + // * Invalid. + SnippetsFilterConditionTypeAccepted SnippetsFilterConditionType = "Accepted" + + // SnippetsFilterConditionReasonAccepted is used with the Accepted condition type when + // the condition is true. + SnippetsFilterConditionReasonAccepted SnippetsFilterConditionReason = "Accepted" + + // SnippetsFilterConditionTypeInvalid is used with the Accepted condition type when + // SnippetsFilter is invalid. + SnippetsFilterConditionTypeInvalid SnippetsFilterConditionType = "Invalid" +) + +// NginxContext represents the NGINX configuration context. +// +// +kubebuilder:validation:Enum=main;http;http;server;http.server;location;stream;stream.server +type NginxContext string + +const ( + // NginxContextMain is the main context of the NGINX configuration. + NginxContextMain NginxContext = "main" + + // NginxContextHTTP is the http context of the NGINX configuration. + NginxContextHTTP NginxContext = "http" + + // NginxContextHTTPServer is the server context of the NGINX configuration. + NginxContextHTTPServer NginxContext = "http.server" + + // NginxContextHTTPServerLocation is the location context of the NGINX configuration. + NginxContextHTTPServerLocation NginxContext = "http.server.location" + + // NginxContextStream is the stream context of the NGINX configuration. + NginxContextStream NginxContext = "stream" + + // NginxContextStreamServer is the server context of the NGINX configuration. + NginxContextStreamServer NginxContext = "stream.server" +) diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 90cdca7a41..4f00e41ca1 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -463,6 +463,90 @@ func (in *ObservabilityPolicySpec) DeepCopy() *ObservabilityPolicySpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Snippet) DeepCopyInto(out *Snippet) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Snippet. +func (in *Snippet) DeepCopy() *Snippet { + if in == nil { + return nil + } + out := new(Snippet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SnippetsFilter) DeepCopyInto(out *SnippetsFilter) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SnippetsFilter. +func (in *SnippetsFilter) DeepCopy() *SnippetsFilter { + if in == nil { + return nil + } + out := new(SnippetsFilter) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SnippetsFilter) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SnippetsFilterSpec) DeepCopyInto(out *SnippetsFilterSpec) { + *out = *in + if in.Snippets != nil { + in, out := &in.Snippets, &out.Snippets + *out = make([]Snippet, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SnippetsFilterSpec. +func (in *SnippetsFilterSpec) DeepCopy() *SnippetsFilterSpec { + if in == nil { + return nil + } + out := new(SnippetsFilterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SnippetsFilterStatus) DeepCopyInto(out *SnippetsFilterStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SnippetsFilterStatus. +func (in *SnippetsFilterStatus) DeepCopy() *SnippetsFilterStatus { + if in == nil { + return nil + } + out := new(SnippetsFilterStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SpanAttribute) DeepCopyInto(out *SpanAttribute) { *out = *in diff --git a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml new file mode 100644 index 0000000000..51150ef8bf --- /dev/null +++ b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml @@ -0,0 +1,159 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + labels: + gateway.networking.k8s.io/policy: direct + name: snippetsfilters.gateway.nginx.org +spec: + group: gateway.nginx.org + names: + categories: + - nginx-gateway-fabric + kind: SnippetsFilter + listKind: SnippetsFilterList + plural: snippetsfilters + shortNames: + - snippetsfilter + singular: snippetsfilter + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the + generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: Spec defines the desired state of the SnippetsFilter. + properties: + snippets: + description: |- + Snippets is a list of NGINX configuration snippets. + There can only be one snippet per context. + Allowed contexts: http, http.server, http.server.location, stream, stream.server. + items: + description: Snippet represents an NGINX configuration snippet. + properties: + context: + description: + Context is the NGINX context to insert the snippet + into. + enum: + - main + - http + - http + - server + - http.server + - location + - stream + - stream.server + type: string + value: + description: Value is the NGINX configuration snippet. + type: string + required: + - context + - value + type: object + type: array + required: + - snippets + type: object + status: + description: Status defines the state of the SnippetsFilter. + properties: + conditions: + description: Conditions describes the state of the SnippetsFilter. + items: + description: + Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + maxItems: 8 + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/site/content/reference/api.md b/site/content/reference/api.md index d9dd3d2de2..72e1c92e82 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -3,8 +3,11 @@ title: "API reference" weight: 100 toc: false --- + ## Overview + NGINX Gateway API Reference +

Packages:

ClientSettingsPolicy @@ -453,6 +458,99 @@ sigs.k8s.io/gateway-api/apis/v1alpha2.PolicyStatus +

SnippetsFilter + +

+

+

SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the +generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+ +gateway.nginx.org/v1alpha1 + +
+kind
+string +
SnippetsFilter
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+spec
+ + +SnippetsFilterSpec + + +
+

Spec defines the desired state of the SnippetsFilter.

+
+
+ + + + + +
+snippets
+ + +[]Snippet + + +
+

Snippets is a list of NGINX configuration snippets. +There can only be one snippet per context. +Allowed contexts: http, http.server, http.server.location, stream, stream.server.

+
+
+status
+ + +SnippetsFilterStatus + + +
+

Status defines the state of the SnippetsFilter.

+

ClientBody

@@ -793,6 +891,43 @@ ControllerLogLevel +

NginxContext +(string alias)

+

+

+(Appears on: +Snippet) +

+

+

NginxContext represents the NGINX configuration context.

+

+ + + + + + + + + + + + + + + + + + + + +
ValueDescription

"http"

NginxContextHTTP is the http context of the NGINX configuration.

+

"http.server"

NginxContextHTTPServer is the server context of the NGINX configuration.

+

"http.server.location"

NginxContextHTTPServerLocation is the location context of the NGINX configuration.

+

"main"

NginxContextMain is the main context of the NGINX configuration.

+

"stream"

NginxContextStream is the stream context of the NGINX configuration.

+

"stream.server"

NginxContextStreamServer is the server context of the NGINX configuration.

+

NginxGatewayConditionReason (string alias)

@@ -1025,6 +1160,168 @@ Support: HTTPRoute, GRPCRoute.

or gigabytes (g). Examples: 1024, 8k, 1m.

+

Snippet + +

+

+(Appears on: +SnippetsFilterSpec) +

+

+

Snippet represents an NGINX configuration snippet.

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+context
+ + +NginxContext + + +
+

Context is the NGINX context to insert the snippet into.

+
+value
+ +string + +
+

Value is the NGINX configuration snippet.

+
+

SnippetsFilterConditionReason +(string alias)

+

+

+

SnippetsFilterConditionReason is a reason for a SnippetsFilter condition type.

+

+ + + + + + + + + + +
ValueDescription

"Accepted"

SnippetsFilterConditionReasonAccepted is used with the Accepted condition type when +the condition is true.

+
+

SnippetsFilterConditionType +(string alias)

+

+

+

SnippetsFilterConditionType is a type of condition associated with SnippetsFilter.

+

+ + + + + + + + + + + + +
ValueDescription

"Accepted"

SnippetsFilterConditionTypeAccepted indicates that the SnippetsFilter is accepted.

+

Possible reasons for this condition to be True:

+
    +
  • Accepted
  • +
+

Possible reasons for this condition to be False:

+
    +
  • Invalid.
  • +
+

"Invalid"

SnippetsFilterConditionTypeInvalid is used with the Accepted condition type when +SnippetsFilter is invalid.

+
+

SnippetsFilterSpec + +

+

+(Appears on: +SnippetsFilter) +

+

+

SnippetsFilterSpec defines the desired state of the SnippetsFilter.

+

+ + + + + + + + + + + + + +
FieldDescription
+snippets
+ + +[]Snippet + + +
+

Snippets is a list of NGINX configuration snippets. +There can only be one snippet per context. +Allowed contexts: http, http.server, http.server.location, stream, stream.server.

+
+

SnippetsFilterStatus + +

+

+(Appears on: +SnippetsFilter) +

+

+

SnippetsFilterStatus defines the state of SnippetsFilter.

+

+ + + + + + + + + + + + + +
FieldDescription
+conditions
+ + +[]Kubernetes meta/v1.Condition + + +
+(Optional) +

Conditions describes the state of the SnippetsFilter.

+

SpanAttribute

From 67125be7e0c301876396f94a881ba0f9f3ff2f99 Mon Sep 17 00:00:00 2001 From: Saloni Date: Thu, 29 Aug 2024 10:39:03 -0600 Subject: [PATCH 02/11] address comments --- apis/v1alpha1/snippetsfilter_types.go | 18 ++++-------------- .../gateway.nginx.org_snippetsfilters.yaml | 11 +++-------- site/content/reference/api.md | 17 ++++------------- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 24e38100da..50202a638b 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -10,10 +10,9 @@ import ( // +kubebuilder:subresource:status // +kubebuilder:resource:categories=nginx-gateway-fabric,shortName=snippetsfilter // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` -// +kubebuilder:metadata:labels="gateway.networking.k8s.io/policy=direct" -// SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the -// generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources. +// SnippetsFilter is a filter that allows inserting NGINX configuration into the +// generated NGINX config for HTTPRoute and GRPCRoute resources. type SnippetsFilter struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -29,7 +28,7 @@ type SnippetsFilter struct { type SnippetsFilterSpec struct { // Snippets is a list of NGINX configuration snippets. // There can only be one snippet per context. - // Allowed contexts: http, http.server, http.server.location, stream, stream.server. + // Allowed contexts: http, http.server, http.server.location. Snippets []Snippet `json:"snippets"` } @@ -81,13 +80,10 @@ const ( // NginxContext represents the NGINX configuration context. // -// +kubebuilder:validation:Enum=main;http;http;server;http.server;location;stream;stream.server +// +kubebuilder:validation:Enum=http;http;server;http.server;location; type NginxContext string const ( - // NginxContextMain is the main context of the NGINX configuration. - NginxContextMain NginxContext = "main" - // NginxContextHTTP is the http context of the NGINX configuration. NginxContextHTTP NginxContext = "http" @@ -96,10 +92,4 @@ const ( // NginxContextHTTPServerLocation is the location context of the NGINX configuration. NginxContextHTTPServerLocation NginxContext = "http.server.location" - - // NginxContextStream is the stream context of the NGINX configuration. - NginxContextStream NginxContext = "stream" - - // NginxContextStreamServer is the server context of the NGINX configuration. - NginxContextStreamServer NginxContext = "stream.server" ) diff --git a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml index 51150ef8bf..004999cb60 100644 --- a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml +++ b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml @@ -4,8 +4,6 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.16.1 - labels: - gateway.networking.k8s.io/policy: direct name: snippetsfilters.gateway.nginx.org spec: group: gateway.nginx.org @@ -28,8 +26,8 @@ spec: schema: openAPIV3Schema: description: |- - SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the - generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources. + SnippetsFilter is a filter that allows inserting NGINX configuration into the + generated NGINX config for HTTPRoute and GRPCRoute resources. properties: apiVersion: description: |- @@ -55,7 +53,7 @@ spec: description: |- Snippets is a list of NGINX configuration snippets. There can only be one snippet per context. - Allowed contexts: http, http.server, http.server.location, stream, stream.server. + Allowed contexts: http, http.server, http.server.location. items: description: Snippet represents an NGINX configuration snippet. properties: @@ -64,14 +62,11 @@ spec: Context is the NGINX context to insert the snippet into. enum: - - main - http - http - server - http.server - location - - stream - - stream.server type: string value: description: Value is the NGINX configuration snippet. diff --git a/site/content/reference/api.md b/site/content/reference/api.md index 72e1c92e82..5fa8f81f5b 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -462,8 +462,8 @@ sigs.k8s.io/gateway-api/apis/v1alpha2.PolicyStatus

-

SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the -generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources.

+

SnippetsFilter is a filter that allows inserting NGINX configuration into the +generated NGINX config for HTTPRoute and GRPCRoute resources.

@@ -530,7 +530,7 @@ SnippetsFilterSpec

Snippets is a list of NGINX configuration snippets. There can only be one snippet per context. -Allowed contexts: http, http.server, http.server.location, stream, stream.server.

+Allowed contexts: http, http.server, http.server.location.

@@ -917,15 +917,6 @@ ControllerLogLevel

"http.server.location"

NginxContextHTTPServerLocation is the location context of the NGINX configuration.

-

"main"

-

NginxContextMain is the main context of the NGINX configuration.

- -

"stream"

-

NginxContextStream is the stream context of the NGINX configuration.

- -

"stream.server"

-

NginxContextStreamServer is the server context of the NGINX configuration.

-

NginxGatewayConditionReason @@ -1283,7 +1274,7 @@ SnippetsFilter is invalid.

Snippets is a list of NGINX configuration snippets. There can only be one snippet per context. -Allowed contexts: http, http.server, http.server.location, stream, stream.server.

+Allowed contexts: http, http.server, http.server.location.

From 1ca96ef2daff481bf5181a8b3d0ea534281a0d86 Mon Sep 17 00:00:00 2001 From: Saloni Date: Fri, 30 Aug 2024 07:56:16 -0600 Subject: [PATCH 03/11] update based on reviews --- apis/v1alpha1/snippetsfilter_types.go | 9 +- apis/v1alpha1/zz_generated.deepcopy.go | 22 ++ .../gateway.nginx.org_snippetsfilters.yaml | 270 +++++++++--------- site/content/reference/api.md | 3 - 4 files changed, 163 insertions(+), 141 deletions(-) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 50202a638b..5e4d36f113 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -41,6 +41,13 @@ type Snippet struct { Value string `json:"value"` } +// SnippetsFilterList contains a list of Snippets. +type SnippetsFilterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Snippet `json:"items"` +} + // SnippetsFilterStatus defines the state of SnippetsFilter. type SnippetsFilterStatus struct { // Conditions describes the state of the SnippetsFilter. @@ -80,7 +87,7 @@ const ( // NginxContext represents the NGINX configuration context. // -// +kubebuilder:validation:Enum=http;http;server;http.server;location; +// +kubebuilder:validation:Enum=http;http.server;http.server.location; type NginxContext string const ( diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 4f00e41ca1..cf4aa1ff17 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -505,6 +505,28 @@ func (in *SnippetsFilter) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SnippetsFilterList) DeepCopyInto(out *SnippetsFilterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Snippet, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SnippetsFilterList. +func (in *SnippetsFilterList) DeepCopy() *SnippetsFilterList { + if in == nil { + return nil + } + out := new(SnippetsFilterList) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SnippetsFilterSpec) DeepCopyInto(out *SnippetsFilterSpec) { *out = *in diff --git a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml index 004999cb60..285eab6954 100644 --- a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml +++ b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml @@ -3,152 +3,148 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.16.2 name: snippetsfilters.gateway.nginx.org spec: group: gateway.nginx.org names: categories: - - nginx-gateway-fabric + - nginx-gateway-fabric kind: SnippetsFilter listKind: SnippetsFilterList plural: snippetsfilters shortNames: - - snippetsfilter + - snippetsfilter singular: snippetsfilter scope: Namespaced versions: - - additionalPrinterColumns: - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: |- - SnippetsFilter is a filter that allows inserting NGINX configuration into the - generated NGINX config for HTTPRoute and GRPCRoute resources. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: Spec defines the desired state of the SnippetsFilter. - properties: - snippets: - description: |- - Snippets is a list of NGINX configuration snippets. - There can only be one snippet per context. - Allowed contexts: http, http.server, http.server.location. - items: - description: Snippet represents an NGINX configuration snippet. - properties: - context: - description: - Context is the NGINX context to insert the snippet - into. - enum: - - http - - http - - server - - http.server - - location - type: string - value: - description: Value is the NGINX configuration snippet. - type: string - required: - - context - - value - type: object - type: array - required: - - snippets - type: object - status: - description: Status defines the state of the SnippetsFilter. - properties: - conditions: - description: Conditions describes the state of the SnippetsFilter. - items: - description: - Condition contains details for one aspect of the current - state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 8 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object - required: - - spec - type: object - served: true - storage: true - subresources: - status: {} + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + SnippetsFilter is a filter that allows inserting NGINX configuration into the + generated NGINX config for HTTPRoute and GRPCRoute resources. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: Spec defines the desired state of the SnippetsFilter. + properties: + snippets: + description: |- + Snippets is a list of NGINX configuration snippets. + There can only be one snippet per context. + Allowed contexts: http, http.server, http.server.location. + items: + description: Snippet represents an NGINX configuration snippet. + properties: + context: + description: Context is the NGINX context to insert the snippet + into. + enum: + - http + - http.server + - http.server.location + type: string + value: + description: Value is the NGINX configuration snippet. + type: string + required: + - context + - value + type: object + type: array + required: + - snippets + type: object + status: + description: Status defines the state of the SnippetsFilter. + properties: + conditions: + description: Conditions describes the state of the SnippetsFilter. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + maxItems: 8 + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/site/content/reference/api.md b/site/content/reference/api.md index 5fa8f81f5b..c7fdb7ff11 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -3,11 +3,8 @@ title: "API reference" weight: 100 toc: false --- - ## Overview - NGINX Gateway API Reference -

Packages:

  • From 10d9a86ccf953677aa63361a60c5d8a547c74cf1 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:00:16 -0600 Subject: [PATCH 04/11] Update apis/v1alpha1/snippetsfilter_types.go Co-authored-by: Kate Osborn <50597707+kate-osborn@users.noreply.github.com> --- apis/v1alpha1/snippetsfilter_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 5e4d36f113..9c836af935 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -41,7 +41,7 @@ type Snippet struct { Value string `json:"value"` } -// SnippetsFilterList contains a list of Snippets. +// SnippetsFilterList contains a list of SnippetFilters. type SnippetsFilterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` From 548d35424add5f574688bc88c0ad6f49eee70b48 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:00:25 -0600 Subject: [PATCH 05/11] Update apis/v1alpha1/snippetsfilter_types.go Co-authored-by: Kate Osborn <50597707+kate-osborn@users.noreply.github.com> --- apis/v1alpha1/snippetsfilter_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 9c836af935..5343d4fb08 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -95,6 +95,7 @@ const ( NginxContextHTTP NginxContext = "http" // NginxContextHTTPServer is the server context of the NGINX configuration. + // https://nginx.org/en/docs/http/ngx_http_core_module.html#server NginxContextHTTPServer NginxContext = "http.server" // NginxContextHTTPServerLocation is the location context of the NGINX configuration. From f24a544485e3865f293a2dfa1403c06585759f1c Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:00:33 -0600 Subject: [PATCH 06/11] Update apis/v1alpha1/snippetsfilter_types.go Co-authored-by: Kate Osborn <50597707+kate-osborn@users.noreply.github.com> --- apis/v1alpha1/snippetsfilter_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 5343d4fb08..2a7737dd4e 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -99,5 +99,6 @@ const ( NginxContextHTTPServer NginxContext = "http.server" // NginxContextHTTPServerLocation is the location context of the NGINX configuration. + // https://nginx.org/en/docs/http/ngx_http_core_module.html#location NginxContextHTTPServerLocation NginxContext = "http.server.location" ) From 505f5d6ede80cb215ae35950f29fbea8bac2e6cc Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:00:40 -0600 Subject: [PATCH 07/11] Update apis/v1alpha1/snippetsfilter_types.go Co-authored-by: Kate Osborn <50597707+kate-osborn@users.noreply.github.com> --- apis/v1alpha1/snippetsfilter_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 2a7737dd4e..57307c2ce1 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -92,6 +92,7 @@ type NginxContext string const ( // NginxContextHTTP is the http context of the NGINX configuration. + // https://nginx.org/en/docs/http/ngx_http_core_module.html#http NginxContextHTTP NginxContext = "http" // NginxContextHTTPServer is the server context of the NGINX configuration. From 13b5373763608adef8fa1d64d65a100c332a6222 Mon Sep 17 00:00:00 2001 From: Saloni Date: Tue, 3 Sep 2024 10:03:06 -0600 Subject: [PATCH 08/11] address review comments --- apis/v1alpha1/snippetsfilter_types.go | 2 +- site/content/reference/api.md | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 57307c2ce1..cbaafaa3f8 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -87,7 +87,7 @@ const ( // NginxContext represents the NGINX configuration context. // -// +kubebuilder:validation:Enum=http;http.server;http.server.location; +// +kubebuilder:validation:Enum=http;http.server;http.server.location type NginxContext string const ( diff --git a/site/content/reference/api.md b/site/content/reference/api.md index c7fdb7ff11..e2a7d7b1d6 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -906,13 +906,16 @@ ControllerLogLevel

    "http"

    -

    NginxContextHTTP is the http context of the NGINX configuration.

    +

    NginxContextHTTP is the http context of the NGINX configuration. +https://nginx.org/en/docs/http/ngx_http_core_module.html#http

    "http.server"

    -

    NginxContextHTTPServer is the server context of the NGINX configuration.

    +

    NginxContextHTTPServer is the server context of the NGINX configuration. +https://nginx.org/en/docs/http/ngx_http_core_module.html#server

    "http.server.location"

    -

    NginxContextHTTPServerLocation is the location context of the NGINX configuration.

    +

    NginxContextHTTPServerLocation is the location context of the NGINX configuration. +https://nginx.org/en/docs/http/ngx_http_core_module.html#location

    From 8d2ccf9db18b563aa69b789adab094c26f0b7479 Mon Sep 17 00:00:00 2001 From: Saloni Date: Tue, 3 Sep 2024 13:34:16 -0600 Subject: [PATCH 09/11] fix SnippetFilterList --- apis/v1alpha1/register.go | 2 ++ apis/v1alpha1/snippetsfilter_types.go | 16 +++++++++------- apis/v1alpha1/zz_generated.deepcopy.go | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/apis/v1alpha1/register.go b/apis/v1alpha1/register.go index bacf47d737..f9970f4b4c 100644 --- a/apis/v1alpha1/register.go +++ b/apis/v1alpha1/register.go @@ -40,6 +40,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ObservabilityPolicyList{}, &ClientSettingsPolicy{}, &ClientSettingsPolicyList{}, + &SnippetsFilter{}, + &SnippetsFilterList{}, ) // AddToGroupVersion allows the serialization of client types like ListOptions. metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index cbaafaa3f8..8c0a1a63c2 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -24,6 +24,15 @@ type SnippetsFilter struct { Status SnippetsFilterStatus `json:"status,omitempty"` } +// +kubebuilder:object:root=true +// +// SnippetsFilterList contains a list of SnippetFilters. +type SnippetsFilterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SnippetsFilter `json:"items"` +} + // SnippetsFilterSpec defines the desired state of the SnippetsFilter. type SnippetsFilterSpec struct { // Snippets is a list of NGINX configuration snippets. @@ -41,13 +50,6 @@ type Snippet struct { Value string `json:"value"` } -// SnippetsFilterList contains a list of SnippetFilters. -type SnippetsFilterList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Snippet `json:"items"` -} - // SnippetsFilterStatus defines the state of SnippetsFilter. type SnippetsFilterStatus struct { // Conditions describes the state of the SnippetsFilter. diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index cf4aa1ff17..d64caaa8c8 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -512,8 +512,10 @@ func (in *SnippetsFilterList) DeepCopyInto(out *SnippetsFilterList) { in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Snippet, len(*in)) - copy(*out, *in) + *out = make([]SnippetsFilter, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } } @@ -527,6 +529,14 @@ func (in *SnippetsFilterList) DeepCopy() *SnippetsFilterList { return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SnippetsFilterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SnippetsFilterSpec) DeepCopyInto(out *SnippetsFilterSpec) { *out = *in From cdf3cd8193b565c5044f5f53bbe62133d6c21717 Mon Sep 17 00:00:00 2001 From: Saloni Date: Tue, 3 Sep 2024 14:33:54 -0600 Subject: [PATCH 10/11] updates based on reviews --- apis/v1alpha1/snippetsfilter_types.go | 7 +++++-- config/crd/bases/gateway.nginx.org_snippetsfilters.yaml | 1 + site/content/reference/api.md | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index 8c0a1a63c2..a494e2b3a6 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -25,7 +25,7 @@ type SnippetsFilter struct { } // +kubebuilder:object:root=true -// + // SnippetsFilterList contains a list of SnippetFilters. type SnippetsFilterList struct { metav1.TypeMeta `json:",inline"` @@ -89,10 +89,13 @@ const ( // NginxContext represents the NGINX configuration context. // -// +kubebuilder:validation:Enum=http;http.server;http.server.location +// +kubebuilder:validation:Enum=main;http;http.server;http.server.location type NginxContext string const ( + // NginxContextMain is the main context of the NGINX configuration. + NginxContextMain NginxContext = "main" + // NginxContextHTTP is the http context of the NGINX configuration. // https://nginx.org/en/docs/http/ngx_http_core_module.html#http NginxContextHTTP NginxContext = "http" diff --git a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml index 285eab6954..989d523fb6 100644 --- a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml +++ b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml @@ -61,6 +61,7 @@ spec: description: Context is the NGINX context to insert the snippet into. enum: + - main - http - http.server - http.server.location diff --git a/site/content/reference/api.md b/site/content/reference/api.md index e2a7d7b1d6..7aa55c8d0a 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -917,6 +917,9 @@ ControllerLogLevel

    NginxContextHTTPServerLocation is the location context of the NGINX configuration. https://nginx.org/en/docs/http/ngx_http_core_module.html#location

    +

    "main"

    +

    NginxContextMain is the main context of the NGINX configuration.

    +

    NginxGatewayConditionReason From dccff20b75bf33273def4d1167321c80bb4d51a3 Mon Sep 17 00:00:00 2001 From: Saloni Date: Tue, 3 Sep 2024 16:18:33 -0600 Subject: [PATCH 11/11] updates based on reviews --- apis/v1alpha1/snippetsfilter_types.go | 46 +++++++++---------- .../gateway.nginx.org_snippetsfilters.yaml | 2 +- site/content/reference/api.md | 4 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apis/v1alpha1/snippetsfilter_types.go b/apis/v1alpha1/snippetsfilter_types.go index a494e2b3a6..c8941fb2f4 100644 --- a/apis/v1alpha1/snippetsfilter_types.go +++ b/apis/v1alpha1/snippetsfilter_types.go @@ -37,7 +37,7 @@ type SnippetsFilterList struct { type SnippetsFilterSpec struct { // Snippets is a list of NGINX configuration snippets. // There can only be one snippet per context. - // Allowed contexts: http, http.server, http.server.location. + // Allowed contexts: main, http, http.server, http.server.location. Snippets []Snippet `json:"snippets"` } @@ -50,6 +50,28 @@ type Snippet struct { Value string `json:"value"` } +// NginxContext represents the NGINX configuration context. +// +// +kubebuilder:validation:Enum=main;http;http.server;http.server.location +type NginxContext string + +const ( + // NginxContextMain is the main context of the NGINX configuration. + NginxContextMain NginxContext = "main" + + // NginxContextHTTP is the http context of the NGINX configuration. + // https://nginx.org/en/docs/http/ngx_http_core_module.html#http + NginxContextHTTP NginxContext = "http" + + // NginxContextHTTPServer is the server context of the NGINX configuration. + // https://nginx.org/en/docs/http/ngx_http_core_module.html#server + NginxContextHTTPServer NginxContext = "http.server" + + // NginxContextHTTPServerLocation is the location context of the NGINX configuration. + // https://nginx.org/en/docs/http/ngx_http_core_module.html#location + NginxContextHTTPServerLocation NginxContext = "http.server.location" +) + // SnippetsFilterStatus defines the state of SnippetsFilter. type SnippetsFilterStatus struct { // Conditions describes the state of the SnippetsFilter. @@ -86,25 +108,3 @@ const ( // SnippetsFilter is invalid. SnippetsFilterConditionTypeInvalid SnippetsFilterConditionType = "Invalid" ) - -// NginxContext represents the NGINX configuration context. -// -// +kubebuilder:validation:Enum=main;http;http.server;http.server.location -type NginxContext string - -const ( - // NginxContextMain is the main context of the NGINX configuration. - NginxContextMain NginxContext = "main" - - // NginxContextHTTP is the http context of the NGINX configuration. - // https://nginx.org/en/docs/http/ngx_http_core_module.html#http - NginxContextHTTP NginxContext = "http" - - // NginxContextHTTPServer is the server context of the NGINX configuration. - // https://nginx.org/en/docs/http/ngx_http_core_module.html#server - NginxContextHTTPServer NginxContext = "http.server" - - // NginxContextHTTPServerLocation is the location context of the NGINX configuration. - // https://nginx.org/en/docs/http/ngx_http_core_module.html#location - NginxContextHTTPServerLocation NginxContext = "http.server.location" -) diff --git a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml index 989d523fb6..364989ec7f 100644 --- a/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml +++ b/config/crd/bases/gateway.nginx.org_snippetsfilters.yaml @@ -53,7 +53,7 @@ spec: description: |- Snippets is a list of NGINX configuration snippets. There can only be one snippet per context. - Allowed contexts: http, http.server, http.server.location. + Allowed contexts: main, http, http.server, http.server.location. items: description: Snippet represents an NGINX configuration snippet. properties: diff --git a/site/content/reference/api.md b/site/content/reference/api.md index 7aa55c8d0a..ad4c7c3c67 100644 --- a/site/content/reference/api.md +++ b/site/content/reference/api.md @@ -527,7 +527,7 @@ SnippetsFilterSpec

    Snippets is a list of NGINX configuration snippets. There can only be one snippet per context. -Allowed contexts: http, http.server, http.server.location.

    +Allowed contexts: main, http, http.server, http.server.location.

    @@ -1277,7 +1277,7 @@ SnippetsFilter is invalid.

    Snippets is a list of NGINX configuration snippets. There can only be one snippet per context. -Allowed contexts: http, http.server, http.server.location.

    +Allowed contexts: main, http, http.server, http.server.location.