1package v2alpha1
2
3import (
4 "time"
5 "strings"
6)
7
8// GlobalContextEntry declares resources to be cached.
9#GlobalContextEntry: {
10 _embeddedResource
11
12 // APIVersion defines the versioned schema of this representation of an object.
13 // Servers should convert recognized schemas to the latest internal value, and
14 // may reject unrecognized values.
15 // More info:
16 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
17 apiVersion?: string
18
19 // Kind is a string value representing the REST resource this object represents.
20 // Servers may infer this from the endpoint the client submits requests to.
21 // Cannot be updated.
22 // In CamelCase.
23 // More info:
24 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
25 kind?: string
26 metadata?: {}
27
28 // Spec declares policy exception behaviors.
29 spec!: matchN(1, [{kubernetesResource!: _}, {apiCall!: _}]) & {
30 // Stores results from an API call which will be cached.
31 // Mutually exclusive with KubernetesResource.
32 // This can be used to make calls to external (non-Kubernetes API server) services.
33 // It can also be used to make calls to the Kubernetes API server in such cases:
34 // 1. A POST is needed to create a resource.
35 // 2. Finer-grained control is needed. Example: To restrict the number of resources cached.
36 apiCall?: {
37 // The data object specifies the POST data sent to the server.
38 // Only applicable when the method field is set to POST.
39 data?: [...{
40 // Key is a unique identifier for the data value
41 key!: string
42
43 // Value is the data value
44 value!: null | bool | number | string | [...] | {...}
45 }]
46
47 // Method is the HTTP request type (GET or POST). Defaults to GET.
48 method?: "GET" | "POST"
49
50 // RefreshInterval defines the interval in duration at which to poll the APICall.
51 // The duration is a sequence of decimal numbers, each with optional fraction and a unit suffix,
52 // such as "300ms", "1.5h" or "2h45m". Valid time units are "ns", "us" (or
53 // "µs"), "ms", "s", "m", "h".
54 refreshInterval?: string
55
56 // RetryLimit defines the number of times the APICall should be retried in case of failure.
57 retryLimit?: int & >=1
58
59 // Service is an API call to a JSON web service.
60 // This is used for non-Kubernetes API server calls.
61 // It's mutually exclusive with the URLPath field.
62 service?: {
63 // CABundle is a PEM encoded CA bundle which will be used to validate
64 // the server certificate.
65 caBundle?: string
66
67 // Headers is a list of optional HTTP headers to be included in the request.
68 headers?: [...{
69 // Key is the header key
70 key!: string
71
72 // Value is the header value
73 value!: string
74 }]
75
76 // URL is the JSON web service URL. A typical form is
77 // `https://{service}.{namespace}:{port}/{path}`.
78 url!: string
79 }
80
81 // URLPath is the URL path to be used in the HTTP GET or POST request to the
82 // Kubernetes API server (e.g. "/api/v1/namespaces" or "/apis/apps/v1/deployments").
83 // The format required is the same format used by the `kubectl get --raw` command.
84 // See
85 // https://kyverno.io/docs/writing-policies/external-data-sources/#variables-from-kubernetes-api-server-calls
86 // for details.
87 // It's mutually exclusive with the Service field.
88 urlPath?: string
89 }
90
91 // Stores a list of Kubernetes resources which will be cached.
92 // Mutually exclusive with APICall.
93 kubernetesResource?: {
94 // Group defines the group of the resource.
95 group?: string
96
97 // Namespace defines the namespace of the resource. Leave empty for cluster scoped resources.
98 // If left empty for namespaced resources, all resources from all namespaces will be cached.
99 namespace?: string
100
101 // Resource defines the type of the resource.
102 // Requires the pluralized form of the resource kind in lowercase. (Ex., "deployments")
103 resource!: string
104
105 // Version defines the version of the resource.
106 version!: string
107 }
108
109 // Projections defines the list of JMESPath expressions to extract values from the cached resource.
110 projections?: [...{
111 // JMESPath is the JMESPath expression to extract the value from the cached resource.
112 jmesPath!: string
113
114 // Name is the name to use for the extracted value in the context.
115 name!: string
116 }]
117 }
118
119 // Status contains globalcontextentry runtime data.
120 status?: {
121 conditions?: [...{
122 // lastTransitionTime is the last time the condition transitioned from one status to another.
123 // This should be when the underlying condition changed. If that is not known,
124 // then using the time when the API field changed is acceptable.
125 lastTransitionTime!: time.Time
126
127 // message is a human readable message indicating details about the transition.
128 // This may be an empty string.
129 message!: strings.MaxRunes(
130 32768,
131 )
132
133 // observedGeneration represents the .metadata.generation that the condition was set based upon.
134 // For instance, if .metadata.generation is currently 12, but the
135 // .status.conditions[x].observedGeneration is 9, the condition is out of date
136 // with respect to the current state of the instance.
137 observedGeneration?: int64 & int & >=0
138
139 // reason contains a programmatic identifier indicating the reason for the
140 // condition's last transition.
141 // Producers of specific condition types may define expected values and meanings for this field,
142 // and whether the values are considered a guaranteed API.
143 // The value should be a CamelCase string.
144 // This field may not be empty.
145 reason!: strings.MaxRunes(
146 1024,
147 ) &
148 strings.MinRunes(
149 1,
150 ) &
151 =~"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$"
152
153 // status of the condition, one of True, False, Unknown.
154 status!: "True" | "False" | "Unknown"
155
156 // type of condition in CamelCase or in foo.example.com/CamelCase.
157 type!: strings.MaxRunes(
158 316,
159 ) &
160 =~"^([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])$"
161 }]
162
163 // Indicates the time when the globalcontextentry was last refreshed successfully for the API Call
164 lastRefreshTime?: time.Time
165
166 // Deprecated in favor of Conditions
167 ready?: bool
168 }
169
170 _embeddedResource: {
171 apiVersion!: string
172 kind!: string
173 metadata?: {...}
174 }
175 apiVersion: "kyverno.io/v2alpha1"
176 kind: "GlobalContextEntry"
177 metadata!: {
178 name!: string
179 namespace?: string
180 labels?: [string]: string
181 annotations?: [string]: string
182 ...
183 }
184}