-
Notifications
You must be signed in to change notification settings - Fork 137
Add SnippetFilter CRD #2472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
salonichf5
merged 11 commits into
nginx:feature/snippets-filter
from
salonichf5:feat/snippetsFilter
Sep 3, 2024
+670
−0
Merged
Add SnippetFilter CRD #2472
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
12f50b5
add api spec for snippets filter
salonichf5 67125be
address comments
salonichf5 1ca96ef
update based on reviews
salonichf5 10d9a86
Update apis/v1alpha1/snippetsfilter_types.go
salonichf5 548d354
Update apis/v1alpha1/snippetsfilter_types.go
salonichf5 f24a544
Update apis/v1alpha1/snippetsfilter_types.go
salonichf5 505f5d6
Update apis/v1alpha1/snippetsfilter_types.go
salonichf5 13b5373
address review comments
salonichf5 8d2ccf9
fix SnippetFilterList
salonichf5 cdf3cd8
updates based on reviews
salonichf5 dccff20
updates based on reviews
salonichf5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
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` | ||
|
||
// 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"` | ||
|
||
// Spec defines the desired state of the SnippetsFilter. | ||
Spec SnippetsFilterSpec `json:"spec"` | ||
|
||
// Status defines the state of the SnippetsFilter. | ||
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. | ||
// There can only be one snippet per context. | ||
// Allowed contexts: http, http.server, http.server.location. | ||
kate-osborn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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. | ||
salonichf5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
type NginxContext string | ||
|
||
const ( | ||
// NginxContextMain is the main context of the NGINX configuration. | ||
NginxContextMain NginxContext = "main" | ||
kate-osborn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
// NginxContextHTTP is the http context of the NGINX configuration. | ||
salonichf5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// https://nginx.org/en/docs/http/ngx_http_core_module.html#http | ||
NginxContextHTTP NginxContext = "http" | ||
|
||
// NginxContextHTTPServer is the server context of the NGINX configuration. | ||
salonichf5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// 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. | ||
salonichf5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// https://nginx.org/en/docs/http/ngx_http_core_module.html#location | ||
NginxContextHTTPServerLocation NginxContext = "http.server.location" | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
151 changes: 151 additions & 0 deletions
151
config/crd/bases/gateway.nginx.org_snippetsfilters.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.16.2 | ||
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 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: | ||
- main | ||
- 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: {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.