Skip to content

Commit 9a90aad

Browse files
davis-habaritazh
andauthored
feat: Graduate ExpansionTemplate CRD to beta (#2857)
Signed-off-by: davis-haba <[email protected]> Signed-off-by: Davis Haba <[email protected]> Co-authored-by: Rita Zhang <[email protected]>
1 parent 3adf472 commit 9a90aad

24 files changed

+846
-34
lines changed

apis/addtoscheme_expansion_v1beta1.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
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+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package apis
17+
18+
import (
19+
"github.com/open-policy-agent/gatekeeper/v3/apis/expansion/v1beta1"
20+
)
21+
22+
func init() {
23+
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
24+
AddToSchemes = append(AddToSchemes, v1beta1.AddToScheme)
25+
}

apis/expansion/v1beta1/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Package v1beta1 includes v1beta1 expansion
2+
3+
// +k8s:conversion-gen=github.com/open-policy-agent/gatekeeper/v3/apis/expansion/unversioned
4+
// -external-types=github.com/open-policy-agent/gatekeeper/v3/apis/expansion/v1beta1
5+
package v1beta1
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
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+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package v1beta1
17+
18+
import (
19+
status "github.com/open-policy-agent/gatekeeper/v3/apis/status/v1beta1"
20+
"github.com/open-policy-agent/gatekeeper/v3/pkg/mutation/match"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
25+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26+
27+
// ExpansionTemplateSpec defines the desired state of ExpansionTemplate.
28+
type ExpansionTemplateSpec struct {
29+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
30+
// Important: Run "make" to regenerate code after modifying this file
31+
32+
// ApplyTo lists the specific groups, versions and kinds of generator resources
33+
// which will be expanded.
34+
ApplyTo []match.ApplyTo `json:"applyTo,omitempty"`
35+
36+
// TemplateSource specifies the source field on the generator resource to
37+
// use as the base for expanded resource. For Pod-creating generators, this
38+
// is usually spec.template
39+
TemplateSource string `json:"templateSource,omitempty"`
40+
41+
// GeneratedGVK specifies the GVK of the resources which the generator
42+
// resource creates.
43+
GeneratedGVK GeneratedGVK `json:"generatedGVK,omitempty"`
44+
45+
// EnforcementAction specifies the enforcement action to be used for resources
46+
// matching the ExpansionTemplate. Specifying an empty value will use the
47+
// enforcement action specified by the Constraint in violation.
48+
EnforcementAction string `json:"enforcementAction,omitempty"`
49+
}
50+
51+
type GeneratedGVK struct {
52+
Group string `json:"group,omitempty"`
53+
Version string `json:"version,omitempty"`
54+
Kind string `json:"kind,omitempty"`
55+
}
56+
57+
// +kubebuilder:object:root=true
58+
// +kubebuilder:resource:path="expansiontemplate"
59+
// +kubebuilder:resource:scope="Cluster"
60+
// +kubebuilder:subresource:status
61+
62+
// ExpansionTemplate is the Schema for the ExpansionTemplate API.
63+
type ExpansionTemplate struct {
64+
metav1.TypeMeta `json:",inline"`
65+
metav1.ObjectMeta `json:"metadata,omitempty"`
66+
67+
Spec ExpansionTemplateSpec `json:"spec,omitempty"`
68+
Status ExpansionTemplateStatus `json:"status,omitempty"`
69+
}
70+
71+
// ExpansionTemplateStatus defines the observed state of ExpansionTemplate.
72+
type ExpansionTemplateStatus struct {
73+
ByPod []status.ExpansionTemplatePodStatusStatus `json:"byPod,omitempty"`
74+
}
75+
76+
// +kubebuilder:object:root=true
77+
78+
// ExpansionTemplateList contains a list of ExpansionTemplate.
79+
type ExpansionTemplateList struct {
80+
metav1.TypeMeta `json:",inline"`
81+
metav1.ListMeta `json:"metadata,omitempty"`
82+
Items []ExpansionTemplate `json:"items"`
83+
}
84+
85+
func init() {
86+
SchemeBuilder.Register(&ExpansionTemplate{}, &ExpansionTemplateList{})
87+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
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+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
// Package v1beta1 contains API Schema definitions for the expansion v1beta1 API group
17+
// +kubebuilder:object:generate=true
18+
// +groupName=expansion.gatekeeper.sh
19+
package v1beta1
20+
21+
import (
22+
"k8s.io/apimachinery/pkg/runtime"
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "expansion.gatekeeper.sh", Version: "v1beta1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
localSchemeBuilder = runtime.NewSchemeBuilder(SchemeBuilder.AddToScheme)
35+
36+
// AddToScheme adds the types in this group-version to the given scheme.
37+
AddToScheme = localSchemeBuilder.AddToScheme
38+
)

apis/expansion/v1beta1/zz_generated.conversion.go

Lines changed: 218 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)