generated.proto 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. Copyright The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // This file was autogenerated by go-to-protobuf. Do not edit it manually!
  14. syntax = "proto2";
  15. package k8s.io.api.admissionregistration.v1alpha1;
  16. import "k8s.io/api/admissionregistration/v1/generated.proto";
  17. import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
  18. import "k8s.io/apimachinery/pkg/runtime/generated.proto";
  19. import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
  20. // Package-wide variables from generator "generated".
  21. option go_package = "k8s.io/api/admissionregistration/v1alpha1";
  22. // AuditAnnotation describes how to produce an audit annotation for an API request.
  23. message AuditAnnotation {
  24. // key specifies the audit annotation key. The audit annotation keys of
  25. // a ValidatingAdmissionPolicy must be unique. The key must be a qualified
  26. // name ([A-Za-z0-9][-A-Za-z0-9_.]*) no more than 63 bytes in length.
  27. //
  28. // The key is combined with the resource name of the
  29. // ValidatingAdmissionPolicy to construct an audit annotation key:
  30. // "{ValidatingAdmissionPolicy name}/{key}".
  31. //
  32. // If an admission webhook uses the same resource name as this ValidatingAdmissionPolicy
  33. // and the same audit annotation key, the annotation key will be identical.
  34. // In this case, the first annotation written with the key will be included
  35. // in the audit event and all subsequent annotations with the same key
  36. // will be discarded.
  37. //
  38. // Required.
  39. optional string key = 1;
  40. // valueExpression represents the expression which is evaluated by CEL to
  41. // produce an audit annotation value. The expression must evaluate to either
  42. // a string or null value. If the expression evaluates to a string, the
  43. // audit annotation is included with the string value. If the expression
  44. // evaluates to null or empty string the audit annotation will be omitted.
  45. // The valueExpression may be no longer than 5kb in length.
  46. // If the result of the valueExpression is more than 10kb in length, it
  47. // will be truncated to 10kb.
  48. //
  49. // If multiple ValidatingAdmissionPolicyBinding resources match an
  50. // API request, then the valueExpression will be evaluated for
  51. // each binding. All unique values produced by the valueExpressions
  52. // will be joined together in a comma-separated list.
  53. //
  54. // Required.
  55. optional string valueExpression = 2;
  56. }
  57. // ExpressionWarning is a warning information that targets a specific expression.
  58. message ExpressionWarning {
  59. // The path to the field that refers the expression.
  60. // For example, the reference to the expression of the first item of
  61. // validations is "spec.validations[0].expression"
  62. optional string fieldRef = 2;
  63. // The content of type checking information in a human-readable form.
  64. // Each line of the warning contains the type that the expression is checked
  65. // against, followed by the type check error from the compiler.
  66. optional string warning = 3;
  67. }
  68. message MatchCondition {
  69. // Name is an identifier for this match condition, used for strategic merging of MatchConditions,
  70. // as well as providing an identifier for logging purposes. A good name should be descriptive of
  71. // the associated expression.
  72. // Name must be a qualified name consisting of alphanumeric characters, '-', '_' or '.', and
  73. // must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or
  74. // '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an
  75. // optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')
  76. //
  77. // Required.
  78. optional string name = 1;
  79. // Expression represents the expression which will be evaluated by CEL. Must evaluate to bool.
  80. // CEL expressions have access to the contents of the AdmissionRequest and Authorizer, organized into CEL variables:
  81. //
  82. // 'object' - The object from the incoming request. The value is null for DELETE requests.
  83. // 'oldObject' - The existing object. The value is null for CREATE requests.
  84. // 'request' - Attributes of the admission request(/pkg/apis/admission/types.go#AdmissionRequest).
  85. // 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.
  86. // See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
  87. // 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
  88. // request resource.
  89. // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
  90. //
  91. // Required.
  92. optional string expression = 2;
  93. }
  94. // MatchResources decides whether to run the admission control policy on an object based
  95. // on whether it meets the match criteria.
  96. // The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
  97. // +structType=atomic
  98. message MatchResources {
  99. // NamespaceSelector decides whether to run the admission control policy on an object based
  100. // on whether the namespace for that object matches the selector. If the
  101. // object itself is a namespace, the matching is performed on
  102. // object.metadata.labels. If the object is another cluster scoped resource,
  103. // it never skips the policy.
  104. //
  105. // For example, to run the webhook on any objects whose namespace is not
  106. // associated with "runlevel" of "0" or "1"; you will set the selector as
  107. // follows:
  108. // "namespaceSelector": {
  109. // "matchExpressions": [
  110. // {
  111. // "key": "runlevel",
  112. // "operator": "NotIn",
  113. // "values": [
  114. // "0",
  115. // "1"
  116. // ]
  117. // }
  118. // ]
  119. // }
  120. //
  121. // If instead you want to only run the policy on any objects whose
  122. // namespace is associated with the "environment" of "prod" or "staging";
  123. // you will set the selector as follows:
  124. // "namespaceSelector": {
  125. // "matchExpressions": [
  126. // {
  127. // "key": "environment",
  128. // "operator": "In",
  129. // "values": [
  130. // "prod",
  131. // "staging"
  132. // ]
  133. // }
  134. // ]
  135. // }
  136. //
  137. // See
  138. // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  139. // for more examples of label selectors.
  140. //
  141. // Default to the empty LabelSelector, which matches everything.
  142. // +optional
  143. optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector namespaceSelector = 1;
  144. // ObjectSelector decides whether to run the validation based on if the
  145. // object has matching labels. objectSelector is evaluated against both
  146. // the oldObject and newObject that would be sent to the cel validation, and
  147. // is considered to match if either object matches the selector. A null
  148. // object (oldObject in the case of create, or newObject in the case of
  149. // delete) or an object that cannot have labels (like a
  150. // DeploymentRollback or a PodProxyOptions object) is not considered to
  151. // match.
  152. // Use the object selector only if the webhook is opt-in, because end
  153. // users may skip the admission webhook by setting the labels.
  154. // Default to the empty LabelSelector, which matches everything.
  155. // +optional
  156. optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector objectSelector = 2;
  157. // ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches.
  158. // The policy cares about an operation if it matches _any_ Rule.
  159. // +listType=atomic
  160. // +optional
  161. repeated NamedRuleWithOperations resourceRules = 3;
  162. // ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about.
  163. // The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
  164. // +listType=atomic
  165. // +optional
  166. repeated NamedRuleWithOperations excludeResourceRules = 4;
  167. // matchPolicy defines how the "MatchResources" list is used to match incoming requests.
  168. // Allowed values are "Exact" or "Equivalent".
  169. //
  170. // - Exact: match a request only if it exactly matches a specified rule.
  171. // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
  172. // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
  173. // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.
  174. //
  175. // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
  176. // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
  177. // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
  178. // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.
  179. //
  180. // Defaults to "Equivalent"
  181. // +optional
  182. optional string matchPolicy = 7;
  183. }
  184. // NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.
  185. // +structType=atomic
  186. message NamedRuleWithOperations {
  187. // ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.
  188. // +listType=atomic
  189. // +optional
  190. repeated string resourceNames = 1;
  191. // RuleWithOperations is a tuple of Operations and Resources.
  192. optional k8s.io.api.admissionregistration.v1.RuleWithOperations ruleWithOperations = 2;
  193. }
  194. // ParamKind is a tuple of Group Kind and Version.
  195. // +structType=atomic
  196. message ParamKind {
  197. // APIVersion is the API group version the resources belong to.
  198. // In format of "group/version".
  199. // Required.
  200. optional string apiVersion = 1;
  201. // Kind is the API kind the resources belong to.
  202. // Required.
  203. optional string kind = 2;
  204. }
  205. // ParamRef describes how to locate the params to be used as input to
  206. // expressions of rules applied by a policy binding.
  207. // +structType=atomic
  208. message ParamRef {
  209. // `name` is the name of the resource being referenced.
  210. //
  211. // `name` and `selector` are mutually exclusive properties. If one is set,
  212. // the other must be unset.
  213. //
  214. // +optional
  215. optional string name = 1;
  216. // namespace is the namespace of the referenced resource. Allows limiting
  217. // the search for params to a specific namespace. Applies to both `name` and
  218. // `selector` fields.
  219. //
  220. // A per-namespace parameter may be used by specifying a namespace-scoped
  221. // `paramKind` in the policy and leaving this field empty.
  222. //
  223. // - If `paramKind` is cluster-scoped, this field MUST be unset. Setting this
  224. // field results in a configuration error.
  225. //
  226. // - If `paramKind` is namespace-scoped, the namespace of the object being
  227. // evaluated for admission will be used when this field is left unset. Take
  228. // care that if this is left empty the binding must not match any cluster-scoped
  229. // resources, which will result in an error.
  230. //
  231. // +optional
  232. optional string namespace = 2;
  233. // selector can be used to match multiple param objects based on their labels.
  234. // Supply selector: {} to match all resources of the ParamKind.
  235. //
  236. // If multiple params are found, they are all evaluated with the policy expressions
  237. // and the results are ANDed together.
  238. //
  239. // One of `name` or `selector` must be set, but `name` and `selector` are
  240. // mutually exclusive properties. If one is set, the other must be unset.
  241. //
  242. // +optional
  243. optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 3;
  244. // `parameterNotFoundAction` controls the behavior of the binding when the resource
  245. // exists, and name or selector is valid, but there are no parameters
  246. // matched by the binding. If the value is set to `Allow`, then no
  247. // matched parameters will be treated as successful validation by the binding.
  248. // If set to `Deny`, then no matched parameters will be subject to the
  249. // `failurePolicy` of the policy.
  250. //
  251. // Allowed values are `Allow` or `Deny`
  252. // Default to `Deny`
  253. // +optional
  254. optional string parameterNotFoundAction = 4;
  255. }
  256. // TypeChecking contains results of type checking the expressions in the
  257. // ValidatingAdmissionPolicy
  258. message TypeChecking {
  259. // The type checking warnings for each expression.
  260. // +optional
  261. // +listType=atomic
  262. repeated ExpressionWarning expressionWarnings = 1;
  263. }
  264. // ValidatingAdmissionPolicy describes the definition of an admission validation policy that accepts or rejects an object without changing it.
  265. message ValidatingAdmissionPolicy {
  266. // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
  267. // +optional
  268. optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
  269. // Specification of the desired behavior of the ValidatingAdmissionPolicy.
  270. optional ValidatingAdmissionPolicySpec spec = 2;
  271. // The status of the ValidatingAdmissionPolicy, including warnings that are useful to determine if the policy
  272. // behaves in the expected way.
  273. // Populated by the system.
  274. // Read-only.
  275. // +optional
  276. optional ValidatingAdmissionPolicyStatus status = 3;
  277. }
  278. // ValidatingAdmissionPolicyBinding binds the ValidatingAdmissionPolicy with paramerized resources.
  279. // ValidatingAdmissionPolicyBinding and parameter CRDs together define how cluster administrators configure policies for clusters.
  280. //
  281. // For a given admission request, each binding will cause its policy to be
  282. // evaluated N times, where N is 1 for policies/bindings that don't use
  283. // params, otherwise N is the number of parameters selected by the binding.
  284. //
  285. // The CEL expressions of a policy must have a computed CEL cost below the maximum
  286. // CEL budget. Each evaluation of the policy is given an independent CEL cost budget.
  287. // Adding/removing policies, bindings, or params can not affect whether a
  288. // given (policy, binding, param) combination is within its own CEL budget.
  289. message ValidatingAdmissionPolicyBinding {
  290. // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
  291. // +optional
  292. optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
  293. // Specification of the desired behavior of the ValidatingAdmissionPolicyBinding.
  294. optional ValidatingAdmissionPolicyBindingSpec spec = 2;
  295. }
  296. // ValidatingAdmissionPolicyBindingList is a list of ValidatingAdmissionPolicyBinding.
  297. message ValidatingAdmissionPolicyBindingList {
  298. // Standard list metadata.
  299. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
  300. // +optional
  301. optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
  302. // List of PolicyBinding.
  303. repeated ValidatingAdmissionPolicyBinding items = 2;
  304. }
  305. // ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding.
  306. message ValidatingAdmissionPolicyBindingSpec {
  307. // PolicyName references a ValidatingAdmissionPolicy name which the ValidatingAdmissionPolicyBinding binds to.
  308. // If the referenced resource does not exist, this binding is considered invalid and will be ignored
  309. // Required.
  310. optional string policyName = 1;
  311. // paramRef specifies the parameter resource used to configure the admission control policy.
  312. // It should point to a resource of the type specified in ParamKind of the bound ValidatingAdmissionPolicy.
  313. // If the policy specifies a ParamKind and the resource referred to by ParamRef does not exist, this binding is considered mis-configured and the FailurePolicy of the ValidatingAdmissionPolicy applied.
  314. // If the policy does not specify a ParamKind then this field is ignored, and the rules are evaluated without a param.
  315. // +optional
  316. optional ParamRef paramRef = 2;
  317. // MatchResources declares what resources match this binding and will be validated by it.
  318. // Note that this is intersected with the policy's matchConstraints, so only requests that are matched by the policy can be selected by this.
  319. // If this is unset, all resources matched by the policy are validated by this binding
  320. // When resourceRules is unset, it does not constrain resource matching. If a resource is matched by the other fields of this object, it will be validated.
  321. // Note that this is differs from ValidatingAdmissionPolicy matchConstraints, where resourceRules are required.
  322. // +optional
  323. optional MatchResources matchResources = 3;
  324. // validationActions declares how Validations of the referenced ValidatingAdmissionPolicy are enforced.
  325. // If a validation evaluates to false it is always enforced according to these actions.
  326. //
  327. // Failures defined by the ValidatingAdmissionPolicy's FailurePolicy are enforced according
  328. // to these actions only if the FailurePolicy is set to Fail, otherwise the failures are
  329. // ignored. This includes compilation errors, runtime errors and misconfigurations of the policy.
  330. //
  331. // validationActions is declared as a set of action values. Order does
  332. // not matter. validationActions may not contain duplicates of the same action.
  333. //
  334. // The supported actions values are:
  335. //
  336. // "Deny" specifies that a validation failure results in a denied request.
  337. //
  338. // "Warn" specifies that a validation failure is reported to the request client
  339. // in HTTP Warning headers, with a warning code of 299. Warnings can be sent
  340. // both for allowed or denied admission responses.
  341. //
  342. // "Audit" specifies that a validation failure is included in the published
  343. // audit event for the request. The audit event will contain a
  344. // `validation.policy.admission.k8s.io/validation_failure` audit annotation
  345. // with a value containing the details of the validation failures, formatted as
  346. // a JSON list of objects, each with the following fields:
  347. // - message: The validation failure message string
  348. // - policy: The resource name of the ValidatingAdmissionPolicy
  349. // - binding: The resource name of the ValidatingAdmissionPolicyBinding
  350. // - expressionIndex: The index of the failed validations in the ValidatingAdmissionPolicy
  351. // - validationActions: The enforcement actions enacted for the validation failure
  352. // Example audit annotation:
  353. // `"validation.policy.admission.k8s.io/validation_failure": "[{\"message\": \"Invalid value\", {\"policy\": \"policy.example.com\", {\"binding\": \"policybinding.example.com\", {\"expressionIndex\": \"1\", {\"validationActions\": [\"Audit\"]}]"`
  354. //
  355. // Clients should expect to handle additional values by ignoring
  356. // any values not recognized.
  357. //
  358. // "Deny" and "Warn" may not be used together since this combination
  359. // needlessly duplicates the validation failure both in the
  360. // API response body and the HTTP warning headers.
  361. //
  362. // Required.
  363. // +listType=set
  364. repeated string validationActions = 4;
  365. }
  366. // ValidatingAdmissionPolicyList is a list of ValidatingAdmissionPolicy.
  367. message ValidatingAdmissionPolicyList {
  368. // Standard list metadata.
  369. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
  370. // +optional
  371. optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
  372. // List of ValidatingAdmissionPolicy.
  373. repeated ValidatingAdmissionPolicy items = 2;
  374. }
  375. // ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy.
  376. message ValidatingAdmissionPolicySpec {
  377. // ParamKind specifies the kind of resources used to parameterize this policy.
  378. // If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions.
  379. // If ParamKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied.
  380. // If paramKind is specified but paramRef is unset in ValidatingAdmissionPolicyBinding, the params variable will be null.
  381. // +optional
  382. optional ParamKind paramKind = 1;
  383. // MatchConstraints specifies what resources this policy is designed to validate.
  384. // The AdmissionPolicy cares about a request if it matches _all_ Constraints.
  385. // However, in order to prevent clusters from being put into an unstable state that cannot be recovered from via the API
  386. // ValidatingAdmissionPolicy cannot match ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding.
  387. // Required.
  388. optional MatchResources matchConstraints = 2;
  389. // Validations contain CEL expressions which is used to apply the validation.
  390. // Validations and AuditAnnotations may not both be empty; a minimum of one Validations or AuditAnnotations is
  391. // required.
  392. // +listType=atomic
  393. // +optional
  394. repeated Validation validations = 3;
  395. // failurePolicy defines how to handle failures for the admission policy. Failures can
  396. // occur from CEL expression parse errors, type check errors, runtime errors and invalid
  397. // or mis-configured policy definitions or bindings.
  398. //
  399. // A policy is invalid if spec.paramKind refers to a non-existent Kind.
  400. // A binding is invalid if spec.paramRef.name refers to a non-existent resource.
  401. //
  402. // failurePolicy does not define how validations that evaluate to false are handled.
  403. //
  404. // When failurePolicy is set to Fail, ValidatingAdmissionPolicyBinding validationActions
  405. // define how failures are enforced.
  406. //
  407. // Allowed values are Ignore or Fail. Defaults to Fail.
  408. // +optional
  409. optional string failurePolicy = 4;
  410. // auditAnnotations contains CEL expressions which are used to produce audit
  411. // annotations for the audit event of the API request.
  412. // validations and auditAnnotations may not both be empty; a least one of validations or auditAnnotations is
  413. // required.
  414. // +listType=atomic
  415. // +optional
  416. repeated AuditAnnotation auditAnnotations = 5;
  417. // MatchConditions is a list of conditions that must be met for a request to be validated.
  418. // Match conditions filter requests that have already been matched by the rules,
  419. // namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests.
  420. // There are a maximum of 64 match conditions allowed.
  421. //
  422. // If a parameter object is provided, it can be accessed via the `params` handle in the same
  423. // manner as validation expressions.
  424. //
  425. // The exact matching logic is (in order):
  426. // 1. If ANY matchCondition evaluates to FALSE, the policy is skipped.
  427. // 2. If ALL matchConditions evaluate to TRUE, the policy is evaluated.
  428. // 3. If any matchCondition evaluates to an error (but none are FALSE):
  429. // - If failurePolicy=Fail, reject the request
  430. // - If failurePolicy=Ignore, the policy is skipped
  431. //
  432. // +patchMergeKey=name
  433. // +patchStrategy=merge
  434. // +listType=map
  435. // +listMapKey=name
  436. // +optional
  437. repeated MatchCondition matchConditions = 6;
  438. // Variables contain definitions of variables that can be used in composition of other expressions.
  439. // Each variable is defined as a named CEL expression.
  440. // The variables defined here will be available under `variables` in other expressions of the policy
  441. // except MatchConditions because MatchConditions are evaluated before the rest of the policy.
  442. //
  443. // The expression of a variable can refer to other variables defined earlier in the list but not those after.
  444. // Thus, Variables must be sorted by the order of first appearance and acyclic.
  445. // +patchMergeKey=name
  446. // +patchStrategy=merge
  447. // +listType=map
  448. // +listMapKey=name
  449. // +optional
  450. repeated Variable variables = 7;
  451. }
  452. // ValidatingAdmissionPolicyStatus represents the status of a ValidatingAdmissionPolicy.
  453. message ValidatingAdmissionPolicyStatus {
  454. // The generation observed by the controller.
  455. // +optional
  456. optional int64 observedGeneration = 1;
  457. // The results of type checking for each expression.
  458. // Presence of this field indicates the completion of the type checking.
  459. // +optional
  460. optional TypeChecking typeChecking = 2;
  461. // The conditions represent the latest available observations of a policy's current state.
  462. // +optional
  463. // +listType=map
  464. // +listMapKey=type
  465. repeated k8s.io.apimachinery.pkg.apis.meta.v1.Condition conditions = 3;
  466. }
  467. // Validation specifies the CEL expression which is used to apply the validation.
  468. message Validation {
  469. // Expression represents the expression which will be evaluated by CEL.
  470. // ref: https://github.com/google/cel-spec
  471. // CEL expressions have access to the contents of the API request/response, organized into CEL variables as well as some other useful variables:
  472. //
  473. // - 'object' - The object from the incoming request. The value is null for DELETE requests.
  474. // - 'oldObject' - The existing object. The value is null for CREATE requests.
  475. // - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)).
  476. // - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind.
  477. // - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources.
  478. // - 'variables' - Map of composited variables, from its name to its lazily evaluated value.
  479. // For example, a variable named 'foo' can be accessed as 'variables.foo'.
  480. // - 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.
  481. // See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
  482. // - 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
  483. // request resource.
  484. //
  485. // The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the
  486. // object. No other metadata properties are accessible.
  487. //
  488. // Only property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible.
  489. // Accessible property names are escaped according to the following rules when accessed in the expression:
  490. // - '__' escapes to '__underscores__'
  491. // - '.' escapes to '__dot__'
  492. // - '-' escapes to '__dash__'
  493. // - '/' escapes to '__slash__'
  494. // - Property names that exactly match a CEL RESERVED keyword escape to '__{keyword}__'. The keywords are:
  495. // "true", "false", "null", "in", "as", "break", "const", "continue", "else", "for", "function", "if",
  496. // "import", "let", "loop", "package", "namespace", "return".
  497. // Examples:
  498. // - Expression accessing a property named "namespace": {"Expression": "object.__namespace__ > 0"}
  499. // - Expression accessing a property named "x-prop": {"Expression": "object.x__dash__prop > 0"}
  500. // - Expression accessing a property named "redact__d": {"Expression": "object.redact__underscores__d > 0"}
  501. //
  502. // Equality on arrays with list type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1].
  503. // Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type:
  504. // - 'set': `X + Y` performs a union where the array positions of all elements in `X` are preserved and
  505. // non-intersecting elements in `Y` are appended, retaining their partial order.
  506. // - 'map': `X + Y` performs a merge where the array positions of all keys in `X` are preserved but the values
  507. // are overwritten by values in `Y` when the key sets of `X` and `Y` intersect. Elements in `Y` with
  508. // non-intersecting keys are appended, retaining their partial order.
  509. // Required.
  510. optional string Expression = 1;
  511. // Message represents the message displayed when validation fails. The message is required if the Expression contains
  512. // line breaks. The message must not contain line breaks.
  513. // If unset, the message is "failed rule: {Rule}".
  514. // e.g. "must be a URL with the host matching spec.host"
  515. // If the Expression contains line breaks. Message is required.
  516. // The message must not contain line breaks.
  517. // If unset, the message is "failed Expression: {Expression}".
  518. // +optional
  519. optional string message = 2;
  520. // Reason represents a machine-readable description of why this validation failed.
  521. // If this is the first validation in the list to fail, this reason, as well as the
  522. // corresponding HTTP response code, are used in the
  523. // HTTP response to the client.
  524. // The currently supported reasons are: "Unauthorized", "Forbidden", "Invalid", "RequestEntityTooLarge".
  525. // If not set, StatusReasonInvalid is used in the response to the client.
  526. // +optional
  527. optional string reason = 3;
  528. // messageExpression declares a CEL expression that evaluates to the validation failure message that is returned when this rule fails.
  529. // Since messageExpression is used as a failure message, it must evaluate to a string.
  530. // If both message and messageExpression are present on a validation, then messageExpression will be used if validation fails.
  531. // If messageExpression results in a runtime error, the runtime error is logged, and the validation failure message is produced
  532. // as if the messageExpression field were unset. If messageExpression evaluates to an empty string, a string with only spaces, or a string
  533. // that contains line breaks, then the validation failure message will also be produced as if the messageExpression field were unset, and
  534. // the fact that messageExpression produced an empty string/string with only spaces/string with line breaks will be logged.
  535. // messageExpression has access to all the same variables as the `expression` except for 'authorizer' and 'authorizer.requestResource'.
  536. // Example:
  537. // "object.x must be less than max ("+string(params.max)+")"
  538. // +optional
  539. optional string messageExpression = 4;
  540. }
  541. // Variable is the definition of a variable that is used for composition.
  542. message Variable {
  543. // Name is the name of the variable. The name must be a valid CEL identifier and unique among all variables.
  544. // The variable can be accessed in other expressions through `variables`
  545. // For example, if name is "foo", the variable will be available as `variables.foo`
  546. optional string Name = 1;
  547. // Expression is the expression that will be evaluated as the value of the variable.
  548. // The CEL expression has access to the same identifiers as the CEL expressions in Validation.
  549. optional string Expression = 2;
  550. }