mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-05 19:26:23 +00:00
ValidatingAdmissionPolicy: Variable Composition (#118642)
* [API REVIEW] Variable Composition * lazy map. * variable composition implementation. * check variables during VAP validation. * generated: ./hack/update-vendor.sh * generated: UPDATE_COMPATIBILITY_FIXTURE_DATA (cd staging/src/k8s.io/api/ && env UPDATE_COMPATIBILITY_FIXTURE_DATA=true go test) * cost calucation. * tests for cost calculations. * e2e test for variables. * fix doc for Validation.Expression. * generated: ./hack/update-codegen.sh * fix missing utilruntime import. * generated: ./hack/update-openapi-spec.sh Kubernetes-commit: b635f2a401fd03715f6a33c4a19f11c509c0ce03
This commit is contained in:
parent
560efb3b89
commit
0c7c900fd5
@ -31,6 +31,7 @@ type ValidatingAdmissionPolicySpecApplyConfiguration struct {
|
||||
FailurePolicy *admissionregistrationv1alpha1.FailurePolicyType `json:"failurePolicy,omitempty"`
|
||||
AuditAnnotations []AuditAnnotationApplyConfiguration `json:"auditAnnotations,omitempty"`
|
||||
MatchConditions []MatchConditionApplyConfiguration `json:"matchConditions,omitempty"`
|
||||
Variables []VariableApplyConfiguration `json:"variables,omitempty"`
|
||||
}
|
||||
|
||||
// ValidatingAdmissionPolicySpecApplyConfiguration constructs an declarative configuration of the ValidatingAdmissionPolicySpec type for use with
|
||||
@ -101,3 +102,16 @@ func (b *ValidatingAdmissionPolicySpecApplyConfiguration) WithMatchConditions(va
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithVariables adds the given value to the Variables field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the Variables field.
|
||||
func (b *ValidatingAdmissionPolicySpecApplyConfiguration) WithVariables(values ...*VariableApplyConfiguration) *ValidatingAdmissionPolicySpecApplyConfiguration {
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithVariables")
|
||||
}
|
||||
b.Variables = append(b.Variables, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
// VariableApplyConfiguration represents an declarative configuration of the Variable type for use
|
||||
// with apply.
|
||||
type VariableApplyConfiguration struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Expression *string `json:"expression,omitempty"`
|
||||
}
|
||||
|
||||
// VariableApplyConfiguration constructs an declarative configuration of the Variable type for use with
|
||||
// apply.
|
||||
func Variable() *VariableApplyConfiguration {
|
||||
return &VariableApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithName sets the Name field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Name field is set to the value of the last call.
|
||||
func (b *VariableApplyConfiguration) WithName(value string) *VariableApplyConfiguration {
|
||||
b.Name = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithExpression sets the Expression field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Expression field is set to the value of the last call.
|
||||
func (b *VariableApplyConfiguration) WithExpression(value string) *VariableApplyConfiguration {
|
||||
b.Expression = &value
|
||||
return b
|
||||
}
|
@ -464,6 +464,14 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
elementType:
|
||||
namedType: io.k8s.api.admissionregistration.v1alpha1.Validation
|
||||
elementRelationship: atomic
|
||||
- name: variables
|
||||
type:
|
||||
list:
|
||||
elementType:
|
||||
namedType: io.k8s.api.admissionregistration.v1alpha1.Variable
|
||||
elementRelationship: associative
|
||||
keys:
|
||||
- name
|
||||
- name: io.k8s.api.admissionregistration.v1alpha1.ValidatingAdmissionPolicyStatus
|
||||
map:
|
||||
fields:
|
||||
@ -497,6 +505,17 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
- name: reason
|
||||
type:
|
||||
scalar: string
|
||||
- name: io.k8s.api.admissionregistration.v1alpha1.Variable
|
||||
map:
|
||||
fields:
|
||||
- name: expression
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: name
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: io.k8s.api.admissionregistration.v1beta1.MatchCondition
|
||||
map:
|
||||
fields:
|
||||
|
@ -171,6 +171,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
return &admissionregistrationv1alpha1.ValidatingAdmissionPolicyStatusApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("Validation"):
|
||||
return &admissionregistrationv1alpha1.ValidationApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("Variable"):
|
||||
return &admissionregistrationv1alpha1.VariableApplyConfiguration{}
|
||||
|
||||
// Group=admissionregistration.k8s.io, Version=v1beta1
|
||||
case v1beta1.SchemeGroupVersion.WithKind("MatchCondition"):
|
||||
|
8
go.mod
8
go.mod
@ -23,8 +23,8 @@ require (
|
||||
golang.org/x/term v0.7.0
|
||||
golang.org/x/time v0.3.0
|
||||
google.golang.org/protobuf v1.30.0
|
||||
k8s.io/api v0.0.0-20230711173311-4993e301ed85
|
||||
k8s.io/apimachinery v0.0.0-20230628220152-83d6d372b1a4
|
||||
k8s.io/api v0.0.0-20230714010757-8167ea0e18a0
|
||||
k8s.io/apimachinery v0.0.0-20230712210707-c9b3b3a37189
|
||||
k8s.io/klog/v2 v2.100.1
|
||||
k8s.io/kube-openapi v0.0.0-20230601164746-7562a1006961
|
||||
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
|
||||
@ -60,6 +60,6 @@ require (
|
||||
)
|
||||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20230711173311-4993e301ed85
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230628220152-83d6d372b1a4
|
||||
k8s.io/api => k8s.io/api v0.0.0-20230714010757-8167ea0e18a0
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230712210707-c9b3b3a37189
|
||||
)
|
||||
|
8
go.sum
8
go.sum
@ -146,10 +146,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/api v0.0.0-20230711173311-4993e301ed85 h1:objTFO7gYE2CeGB/qKnBxdUoj2QX5a6ZlLhewph/B0M=
|
||||
k8s.io/api v0.0.0-20230711173311-4993e301ed85/go.mod h1:ghFHmaoujTvUqKl24+WADIX4gEvgTA8BEpgFe3ZPylQ=
|
||||
k8s.io/apimachinery v0.0.0-20230628220152-83d6d372b1a4 h1:ntS2ZHGzNY/ISRKPPU937LFSwjYZ7poMcwAeu1xCnKM=
|
||||
k8s.io/apimachinery v0.0.0-20230628220152-83d6d372b1a4/go.mod h1:tAiIbF8KB8+Ri2DfUWwZGwNOThIwM0fhXLnOymriu+4=
|
||||
k8s.io/api v0.0.0-20230714010757-8167ea0e18a0 h1:T9sVvsPvT6eMUXsLW0PbiIkQB4iX7QP6UdtkQdTH7LQ=
|
||||
k8s.io/api v0.0.0-20230714010757-8167ea0e18a0/go.mod h1:fpwNBY6Bs/ziqh5pV+OznQed0xUjcbaf4ltGHniRCOE=
|
||||
k8s.io/apimachinery v0.0.0-20230712210707-c9b3b3a37189 h1:y3e8tHyqhvrwV/79166VbMgSTy6i9/z8Tk4VrKZc8dg=
|
||||
k8s.io/apimachinery v0.0.0-20230712210707-c9b3b3a37189/go.mod h1:tAiIbF8KB8+Ri2DfUWwZGwNOThIwM0fhXLnOymriu+4=
|
||||
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
|
||||
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20230601164746-7562a1006961 h1:pqRVJGQJz6oeZby8qmPKXYIBjyrcv7EHCe/33UkZMYA=
|
||||
|
Loading…
Reference in New Issue
Block a user