/
rule.go
156 lines (136 loc) · 7.81 KB
/
rule.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
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 v2beta1
import (
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
v1 "github.com/kyverno/kyverno/pkg/client/applyconfigurations/kyverno/v1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
)
// RuleApplyConfiguration represents an declarative configuration of the Rule type for use
// with apply.
type RuleApplyConfiguration struct {
Name *string `json:"name,omitempty"`
Context []v1.ContextEntryApplyConfiguration `json:"context,omitempty"`
MatchResources *MatchResourcesApplyConfiguration `json:"match,omitempty"`
ExcludeResources *MatchResourcesApplyConfiguration `json:"exclude,omitempty"`
ImageExtractors *kyvernov1.ImageExtractorConfigs `json:"imageExtractors,omitempty"`
RawAnyAllConditions *AnyAllConditionsApplyConfiguration `json:"preconditions,omitempty"`
CELPreconditions []admissionregistrationv1.MatchCondition `json:"celPreconditions,omitempty"`
Mutation *v1.MutationApplyConfiguration `json:"mutate,omitempty"`
Validation *ValidationApplyConfiguration `json:"validate,omitempty"`
Generation *v1.GenerationApplyConfiguration `json:"generate,omitempty"`
VerifyImages []ImageVerificationApplyConfiguration `json:"verifyImages,omitempty"`
SkipBackgroundRequests *bool `json:"skipBackgroundRequests,omitempty"`
}
// RuleApplyConfiguration constructs an declarative configuration of the Rule type for use with
// apply.
func Rule() *RuleApplyConfiguration {
return &RuleApplyConfiguration{}
}
// 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 *RuleApplyConfiguration) WithName(value string) *RuleApplyConfiguration {
b.Name = &value
return b
}
// WithContext adds the given value to the Context 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 Context field.
func (b *RuleApplyConfiguration) WithContext(values ...*v1.ContextEntryApplyConfiguration) *RuleApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithContext")
}
b.Context = append(b.Context, *values[i])
}
return b
}
// WithMatchResources sets the MatchResources 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 MatchResources field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithMatchResources(value *MatchResourcesApplyConfiguration) *RuleApplyConfiguration {
b.MatchResources = value
return b
}
// WithExcludeResources sets the ExcludeResources 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 ExcludeResources field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithExcludeResources(value *MatchResourcesApplyConfiguration) *RuleApplyConfiguration {
b.ExcludeResources = value
return b
}
// WithImageExtractors sets the ImageExtractors 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 ImageExtractors field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithImageExtractors(value kyvernov1.ImageExtractorConfigs) *RuleApplyConfiguration {
b.ImageExtractors = &value
return b
}
// WithRawAnyAllConditions sets the RawAnyAllConditions 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 RawAnyAllConditions field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithRawAnyAllConditions(value *AnyAllConditionsApplyConfiguration) *RuleApplyConfiguration {
b.RawAnyAllConditions = value
return b
}
// WithCELPreconditions adds the given value to the CELPreconditions 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 CELPreconditions field.
func (b *RuleApplyConfiguration) WithCELPreconditions(values ...admissionregistrationv1.MatchCondition) *RuleApplyConfiguration {
for i := range values {
b.CELPreconditions = append(b.CELPreconditions, values[i])
}
return b
}
// WithMutation sets the Mutation 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 Mutation field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithMutation(value *v1.MutationApplyConfiguration) *RuleApplyConfiguration {
b.Mutation = value
return b
}
// WithValidation sets the Validation 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 Validation field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithValidation(value *ValidationApplyConfiguration) *RuleApplyConfiguration {
b.Validation = value
return b
}
// WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithGeneration(value *v1.GenerationApplyConfiguration) *RuleApplyConfiguration {
b.Generation = value
return b
}
// WithVerifyImages adds the given value to the VerifyImages 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 VerifyImages field.
func (b *RuleApplyConfiguration) WithVerifyImages(values ...*ImageVerificationApplyConfiguration) *RuleApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithVerifyImages")
}
b.VerifyImages = append(b.VerifyImages, *values[i])
}
return b
}
// WithSkipBackgroundRequests sets the SkipBackgroundRequests 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 SkipBackgroundRequests field is set to the value of the last call.
func (b *RuleApplyConfiguration) WithSkipBackgroundRequests(value bool) *RuleApplyConfiguration {
b.SkipBackgroundRequests = &value
return b
}