Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Graduate ExpansionTemplate CRD to beta #2857

Merged
merged 10 commits into from
Jul 7, 2023
1 change: 0 additions & 1 deletion apis/expansion/v1alpha1/expansiontemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type GeneratedGVK struct {
// +kubebuilder:resource:path="expansiontemplate"
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
davis-haba marked this conversation as resolved.
Show resolved Hide resolved

// ExpansionTemplate is the Schema for the ExpansionTemplate API.
type ExpansionTemplate struct {
Expand Down
5 changes: 5 additions & 0 deletions apis/expansion/v1beta1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Package v1beta1 includes v1beta1 expansion

// +k8s:conversion-gen=github.com/open-policy-agent/gatekeeper/v3/apis/expansion/unversioned
// -external-types=github.com/open-policy-agent/gatekeeper/v3/apis/expansion/v1beta1
package v1beta1
88 changes: 88 additions & 0 deletions apis/expansion/v1beta1/expansiontemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*

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.
*/

package v1beta1

import (
status "github.com/open-policy-agent/gatekeeper/v3/apis/status/v1beta1"
"github.com/open-policy-agent/gatekeeper/v3/pkg/mutation/match"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ExpansionTemplateSpec defines the desired state of ExpansionTemplate.
type ExpansionTemplateSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// ApplyTo lists the specific groups, versions and kinds of generator resources
// which will be expanded.
ApplyTo []match.ApplyTo `json:"applyTo,omitempty"`

// TemplateSource specifies the source field on the generator resource to
// use as the base for expanded resource. For Pod-creating generators, this
// is usually spec.template
TemplateSource string `json:"templateSource,omitempty"`

// GeneratedGVK specifies the GVK of the resources which the generator
// resource creates.
GeneratedGVK GeneratedGVK `json:"generatedGVK,omitempty"`

// EnforcementAction specifies the enforcement action to be used for resources
// matching the ExpansionTemplate. Specifying an empty value will use the
// enforcement action specified by the Constraint in violation.
EnforcementAction string `json:"enforcementAction,omitempty"`
}

type GeneratedGVK struct {
Group string `json:"group,omitempty"`
Version string `json:"version,omitempty"`
Kind string `json:"kind,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path="expansiontemplate"
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:subresource:status
// +kubebuilder:storageversion

// ExpansionTemplate is the Schema for the ExpansionTemplate API.
type ExpansionTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ExpansionTemplateSpec `json:"spec,omitempty"`
Status ExpansionTemplateStatus `json:"status,omitempty"`
}

// ExpansionTemplateStatus defines the observed state of ExpansionTemplate.
type ExpansionTemplateStatus struct {
ByPod []status.ExpansionTemplatePodStatusStatus `json:"byPod,omitempty"`
}

// +kubebuilder:object:root=true

// ExpansionTemplateList contains a list of ExpansionTemplate.
type ExpansionTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ExpansionTemplate `json:"items"`
}

func init() {
SchemeBuilder.Register(&ExpansionTemplate{}, &ExpansionTemplateList{})
}
38 changes: 38 additions & 0 deletions apis/expansion/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*

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.
*/

// Package v1beta1 contains API Schema definitions for the expansion v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=expansion.gatekeeper.sh
package v1beta1

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "expansion.gatekeeper.sh", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

localSchemeBuilder = runtime.NewSchemeBuilder(SchemeBuilder.AddToScheme)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = localSchemeBuilder.AddToScheme
)
218 changes: 218 additions & 0 deletions apis/expansion/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.