Skip to content

Commit 1825cf3

Browse files
committed
add api spec for snippets filter
1 parent a5e38b9 commit 1825cf3

File tree

4 files changed

+645
-0
lines changed

4 files changed

+645
-0
lines changed

apis/v1alpha1/snippetsfilter_types.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// +genclient
8+
// +kubebuilder:object:root=true
9+
// +kubebuilder:storageversion
10+
// +kubebuilder:subresource:status
11+
// +kubebuilder:resource:categories=nginx-gateway-fabric,shortName=snippetsfilter
12+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
13+
// +kubebuilder:metadata:labels="gateway.networking.k8s.io/policy=direct"
14+
15+
// SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the
16+
// generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources.
17+
type SnippetsFilter struct {
18+
metav1.TypeMeta `json:",inline"`
19+
metav1.ObjectMeta `json:"metadata,omitempty"`
20+
21+
// Spec defines the desired state of the SnippetsFilter.
22+
Spec SnippetsFilterSpec `json:"spec"`
23+
24+
// Status defines the state of the SnippetsFilter.
25+
Status SnippetsFilterStatus `json:"status,omitempty"`
26+
}
27+
28+
// SnippetsFilterSpec defines the desired state of the SnippetsFilter.
29+
type SnippetsFilterSpec struct {
30+
// Snippets is a list of NGINX configuration snippets.
31+
// There can only be one snippet per context.
32+
// Allowed contexts: http, http.server, http.server.location, stream, stream.server.
33+
Snippets []Snippet `json:"snippets"`
34+
}
35+
36+
// Snippet represents an NGINX configuration snippet.
37+
type Snippet struct {
38+
// Context is the NGINX context to insert the snippet into.
39+
Context NginxContext `json:"context"`
40+
41+
// Value is the NGINX configuration snippet.
42+
Value string `json:"value"`
43+
}
44+
45+
// SnippetsFilterStatus defines the state of SnippetsFilter.
46+
type SnippetsFilterStatus struct {
47+
// Conditions describes the state of the SnippetsFilter.
48+
// +optional
49+
// +listType=map
50+
// +listMapKey=type
51+
// +kubebuilder:validation:MaxItems=8
52+
Conditions []metav1.Condition `json:"conditions,omitempty"`
53+
}
54+
55+
// SnippetsFilterConditionType is a type of condition associated with SnippetsFilter.
56+
type SnippetsFilterConditionType string
57+
58+
// SnippetsFilterConditionReason is a reason for a SnippetsFilter condition type.
59+
type SnippetsFilterConditionReason string
60+
61+
const (
62+
// SnippetsFilterConditionTypeAccepted indicates that the SnippetsFilter is accepted.
63+
//
64+
// Possible reasons for this condition to be True:
65+
//
66+
// * Accepted
67+
//
68+
// Possible reasons for this condition to be False:
69+
//
70+
// * Invalid.
71+
SnippetsFilterConditionTypeAccepted SnippetsFilterConditionType = "Accepted"
72+
73+
// SnippetsFilterConditionReasonAccepted is used with the Accepted condition type when
74+
// the condition is true.
75+
SnippetsFilterConditionReasonAccepted SnippetsFilterConditionReason = "Accepted"
76+
77+
// SnippetsFilterConditionTypeInvalid is used with the Accepted condition type when
78+
// SnippetsFilter is invalid.
79+
SnippetsFilterConditionTypeInvalid SnippetsFilterConditionType = "Invalid"
80+
)
81+
82+
// NginxContext represents the NGINX configuration context.
83+
//
84+
// +kubebuilder:validation:Enum=main;http;http;server;http.server;location;stream;stream.server
85+
type NginxContext string
86+
87+
const (
88+
// NginxContextMain is the main context of the NGINX configuration.
89+
NginxContextMain NginxContext = "main"
90+
91+
// NginxContextHTTP is the http context of the NGINX configuration.
92+
NginxContextHTTP NginxContext = "http"
93+
94+
// NginxContextHTTPServer is the server context of the NGINX configuration.
95+
NginxContextHTTPServer NginxContext = "http.server"
96+
97+
// NginxContextHTTPServerLocation is the location context of the NGINX configuration.
98+
NginxContextHTTPServerLocation NginxContext = "http.server.location"
99+
100+
// NginxContextStream is the stream context of the NGINX configuration.
101+
NginxContextStream NginxContext = "stream"
102+
103+
// NginxContextStreamServer is the server context of the NGINX configuration.
104+
NginxContextStreamServer NginxContext = "stream.server"
105+
)

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.1
7+
labels:
8+
gateway.networking.k8s.io/policy: direct
9+
name: snippetsfilters.gateway.nginx.org
10+
spec:
11+
group: gateway.nginx.org
12+
names:
13+
categories:
14+
- nginx-gateway-fabric
15+
kind: SnippetsFilter
16+
listKind: SnippetsFilterList
17+
plural: snippetsfilters
18+
shortNames:
19+
- snippetsfilter
20+
singular: snippetsfilter
21+
scope: Namespaced
22+
versions:
23+
- additionalPrinterColumns:
24+
- jsonPath: .metadata.creationTimestamp
25+
name: Age
26+
type: date
27+
name: v1alpha1
28+
schema:
29+
openAPIV3Schema:
30+
description: |-
31+
SnippetsFilter is an Direct Attached Policy. It allows inserting NGINX configuration into the
32+
generated NGINX config for HTTPRoute, GRPCRoute and TLSRoute resources.
33+
properties:
34+
apiVersion:
35+
description: |-
36+
APIVersion defines the versioned schema of this representation of an object.
37+
Servers should convert recognized schemas to the latest internal value, and
38+
may reject unrecognized values.
39+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
40+
type: string
41+
kind:
42+
description: |-
43+
Kind is a string value representing the REST resource this object represents.
44+
Servers may infer this from the endpoint the client submits requests to.
45+
Cannot be updated.
46+
In CamelCase.
47+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
48+
type: string
49+
metadata:
50+
type: object
51+
spec:
52+
description: Spec defines the desired state of the SnippetsFilter.
53+
properties:
54+
snippets:
55+
description: |-
56+
Snippets is a list of NGINX configuration snippets.
57+
There can only be one snippet per context.
58+
Allowed contexts: http, http.server, http.server.location, stream, stream.server.
59+
items:
60+
description: Snippet represents an NGINX configuration snippet.
61+
properties:
62+
context:
63+
description:
64+
Context is the NGINX context to insert the snippet
65+
into.
66+
enum:
67+
- main
68+
- http
69+
- http
70+
- server
71+
- http.server
72+
- location
73+
- stream
74+
- stream.server
75+
type: string
76+
value:
77+
description: Value is the NGINX configuration snippet.
78+
type: string
79+
required:
80+
- context
81+
- value
82+
type: object
83+
type: array
84+
required:
85+
- snippets
86+
type: object
87+
status:
88+
description: Status defines the state of the SnippetsFilter.
89+
properties:
90+
conditions:
91+
description: Conditions describes the state of the SnippetsFilter.
92+
items:
93+
description:
94+
Condition contains details for one aspect of the current
95+
state of this API Resource.
96+
properties:
97+
lastTransitionTime:
98+
description: |-
99+
lastTransitionTime is the last time the condition transitioned from one status to another.
100+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
101+
format: date-time
102+
type: string
103+
message:
104+
description: |-
105+
message is a human readable message indicating details about the transition.
106+
This may be an empty string.
107+
maxLength: 32768
108+
type: string
109+
observedGeneration:
110+
description: |-
111+
observedGeneration represents the .metadata.generation that the condition was set based upon.
112+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
113+
with respect to the current state of the instance.
114+
format: int64
115+
minimum: 0
116+
type: integer
117+
reason:
118+
description: |-
119+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
120+
Producers of specific condition types may define expected values and meanings for this field,
121+
and whether the values are considered a guaranteed API.
122+
The value should be a CamelCase string.
123+
This field may not be empty.
124+
maxLength: 1024
125+
minLength: 1
126+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
127+
type: string
128+
status:
129+
description: status of the condition, one of True, False, Unknown.
130+
enum:
131+
- "True"
132+
- "False"
133+
- Unknown
134+
type: string
135+
type:
136+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
137+
maxLength: 316
138+
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])$
139+
type: string
140+
required:
141+
- lastTransitionTime
142+
- message
143+
- reason
144+
- status
145+
- type
146+
type: object
147+
maxItems: 8
148+
type: array
149+
x-kubernetes-list-map-keys:
150+
- type
151+
x-kubernetes-list-type: map
152+
type: object
153+
required:
154+
- spec
155+
type: object
156+
served: true
157+
storage: true
158+
subresources:
159+
status: {}

0 commit comments

Comments
 (0)