diff --git a/pkg/webhook/testdata/cronjob_types.go b/pkg/webhook/testdata/cronjob_types.go index 9144b496f..67dcbfe88 100644 --- a/pkg/webhook/testdata/cronjob_types.go +++ b/pkg/webhook/testdata/cronjob_types.go @@ -14,13 +14,28 @@ limitations under the License. */ //go:generate ../../../.run-controller-gen.sh webhook paths=. output:dir=. +//go:generate ../../../.run-controller-gen.sh object paths=. output:dir=. // +groupName=testdata.kubebuilder.io // +versionName=v1 +// +k8s:deepcopy-gen=package package cronjob import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "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: "testdata.kubebuilder.io", Version: "v1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! diff --git a/pkg/webhook/testdata/valid-ordered/webhook.go b/pkg/webhook/testdata/valid-ordered/webhook.go index fae0fe383..4ebc3f6d6 100644 --- a/pkg/webhook/testdata/valid-ordered/webhook.go +++ b/pkg/webhook/testdata/valid-ordered/webhook.go @@ -49,7 +49,7 @@ func (v cronJobValidator) ValidateDelete(ctx context.Context, obj runtime.Object // +kubebuilder:webhook:webhookVersions=v1,verbs=create;update,path=/validate-testdata-kubebuilder-io-v1-cronjoblist,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjoblist,versions=v1,name=cronjoblist.testdata.kubebuilder.io,sideEffects=None,admissionReviewVersions=v1;v1beta1,reinvocationPolicy=Never -type cronjobListValidator struct { +type cronJobListValidator struct { client client.Client } diff --git a/pkg/webhook/testdata/zz_generated.deepcopy.go b/pkg/webhook/testdata/zz_generated.deepcopy.go new file mode 100644 index 000000000..2139655a7 --- /dev/null +++ b/pkg/webhook/testdata/zz_generated.deepcopy.go @@ -0,0 +1,102 @@ +//go:build !ignore_autogenerated + +// Code generated by controller-gen. DO NOT EDIT. + +package cronjob + +import ( + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJob) DeepCopyInto(out *CronJob) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJob. +func (in *CronJob) DeepCopy() *CronJob { + if in == nil { + return nil + } + out := new(CronJob) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CronJob) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobList) DeepCopyInto(out *CronJobList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CronJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobList. +func (in *CronJobList) DeepCopy() *CronJobList { + if in == nil { + return nil + } + out := new(CronJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CronJobList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobSpec) DeepCopyInto(out *CronJobSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobSpec. +func (in *CronJobSpec) DeepCopy() *CronJobSpec { + if in == nil { + return nil + } + out := new(CronJobSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobStatus) DeepCopyInto(out *CronJobStatus) { + *out = *in + if in.LastScheduleTime != nil { + in, out := &in.LastScheduleTime, &out.LastScheduleTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobStatus. +func (in *CronJobStatus) DeepCopy() *CronJobStatus { + if in == nil { + return nil + } + out := new(CronJobStatus) + in.DeepCopyInto(out) + return out +} diff --git a/test.sh b/test.sh index c91647d14..df668fd5d 100755 --- a/test.sh +++ b/test.sh @@ -119,14 +119,4 @@ make lint header_text "running go test" -for dir in $(find . -name go.mod -exec dirname {} \;); do - # Includes "BadDeepCopy" types that are not supposed to result in - # valid code generation - if [[ "$dir" == "./pkg/deepcopy/testdata" ]]; then continue; fi - - # https://github.com/kubernetes-sigs/controller-tools/issues/1227 - if [[ "$dir" == "./pkg/webhook/testdata" ]]; then continue; fi - - echo "Testing module in $dir" - (cd "$dir" && go test -race ./... -parallel 4) -done +go test -race ./pkg/... ./cmd/... -parallel 4