Skip to content

Commit d53aa90

Browse files
committed
Generate DeepCopy methods for testdata/cronjob
This allows pkg/webhook/testdata to build Signed-off-by: Michael Shen <[email protected]>
1 parent 5a3051b commit d53aa90

File tree

4 files changed

+119
-12
lines changed

4 files changed

+119
-12
lines changed

pkg/webhook/testdata/cronjob_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,28 @@ limitations under the License.
1414
*/
1515

1616
//go:generate ../../../.run-controller-gen.sh webhook paths=. output:dir=.
17+
//go:generate ../../../.run-controller-gen.sh object paths=. output:dir=.
1718

1819
// +groupName=testdata.kubebuilder.io
1920
// +versionName=v1
21+
// +k8s:deepcopy-gen=package
2022
package cronjob
2123

2224
import (
2325
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
"k8s.io/apimachinery/pkg/runtime/schema"
27+
"sigs.k8s.io/controller-runtime/pkg/scheme"
28+
)
29+
30+
var (
31+
// GroupVersion is group version used to register these objects
32+
GroupVersion = schema.GroupVersion{Group: "testdata.kubebuilder.io", Version: "v1"}
33+
34+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
35+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
36+
37+
// AddToScheme adds the types in this group-version to the given scheme.
38+
AddToScheme = SchemeBuilder.AddToScheme
2439
)
2540

2641
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

pkg/webhook/testdata/valid-ordered/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (v cronJobValidator) ValidateDelete(ctx context.Context, obj runtime.Object
4949

5050
// +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
5151

52-
type cronjobListValidator struct {
52+
type cronJobListValidator struct {
5353
client client.Client
5454
}
5555

pkg/webhook/testdata/zz_generated.deepcopy.go

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

test.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,4 @@ make lint
119119

120120
header_text "running go test"
121121

122-
for dir in $(find . -name go.mod -exec dirname {} \;); do
123-
# Includes "BadDeepCopy" types that are not supposed to result in
124-
# valid code generation
125-
if [[ "$dir" == "./pkg/deepcopy/testdata" ]]; then continue; fi
126-
127-
# https://github.com/kubernetes-sigs/controller-tools/issues/1227
128-
if [[ "$dir" == "./pkg/webhook/testdata" ]]; then continue; fi
129-
130-
echo "Testing module in $dir"
131-
(cd "$dir" && go test -race ./... -parallel 4)
132-
done
122+
go test -race ./pkg/... ./cmd/... -parallel 4

0 commit comments

Comments
 (0)