Skip to content

Commit 621a9b0

Browse files
dd
1 parent 6f1bbc3 commit 621a9b0

File tree

11 files changed

+16
-12
lines changed

11 files changed

+16
-12
lines changed

docs/book/src/cronjob-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
184184
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
185185
cronjob, ok := newObj.(*batchv1.CronJob)
186186
if !ok {
187-
return nil, fmt.Errorf("expected a CronJob object for the newObj but got got %T", newObj)
187+
return nil, fmt.Errorf("expected a CronJob object for the newObj but got %T", newObj)
188188
}
189189
cronjoblog.Info("Validation for CronJob upon update", "name", cronjob.GetName())
190190

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
188188
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
189189
cronjob, ok := newObj.(*batchv1.CronJob)
190190
if !ok {
191-
return nil, fmt.Errorf("expected a CronJob object for the newObj but got got %T", newObj)
191+
return nil, fmt.Errorf("expected a CronJob object for the newObj but got %T", newObj)
192192
}
193193
cronjoblog.Info("Validation for CronJob upon update", "name", cronjob.GetName())
194194

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v2/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
120120
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
121121
cronjob, ok := newObj.(*batchv2.CronJob)
122122
if !ok {
123-
return nil, fmt.Errorf("expected a CronJob object for the newObj but got got %T", newObj)
123+
return nil, fmt.Errorf("expected a CronJob object for the newObj but got %T", newObj)
124124
}
125125
cronjoblog.Info("Validation for CronJob upon update", "name", cronjob.GetName())
126126

pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (v *{{ .Resource.Kind }}CustomValidator) ValidateUpdate(ctx context.Context
237237
{{ lower .Resource.Kind }}, ok := newObj.(*{{ .Resource.ImportAlias }}.{{ .Resource.Kind }})
238238
{{- end }}
239239
if !ok {
240-
return nil, fmt.Errorf("expected a {{ .Resource.Kind }} object for the newObj but got got %T", newObj)
240+
return nil, fmt.Errorf("expected a {{ .Resource.Kind }} object for the newObj but got %T", newObj)
241241
}
242242
{{ lower .Resource.Kind }}log.Info("Validation for {{ .Resource.Kind }} upon update", "name", {{ lower .Resource.Kind }}.GetName())
243243

pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook_suitetest.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ func (f *WebhookSuite) SetTemplateDefaults() error {
8484
)
8585

8686
if f.IsLegacyPath {
87-
// If is multigroup the path needs to be ../../.. since it has the group dir.
87+
// If is multigroup the path needs to be ../../../ since it has the group dir.
8888
f.BaseDirectoryRelativePath = `"..", ".."`
8989
if f.MultiGroup && f.Resource.Group != "" {
9090
f.BaseDirectoryRelativePath = `"..", "..", ".."`
9191
}
9292
} else {
93-
// If is multigroup the path needs to be ../../.. since it has the group dir.
93+
// If is multigroup the path needs to be ../../../../ since it has the group dir.
9494
f.BaseDirectoryRelativePath = `"..", "..", ".."`
9595
if f.MultiGroup && f.Resource.Group != "" {
9696
f.BaseDirectoryRelativePath = `"..", "..", "..", ".."`
@@ -245,7 +245,11 @@ var _ = BeforeSuite(func() {
245245
Expect(cfg).NotTo(BeNil())
246246
247247
scheme := apimachineryruntime.NewScheme()
248+
{{- if .IsLegacyPath -}}
249+
err = AddToScheme(scheme)
250+
{{- else }}
248251
err = %s.AddToScheme(scheme)
252+
{{- end }}
249253
Expect(err).NotTo(HaveOccurred())
250254
251255
err = %s.AddToScheme(scheme)

pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook_test_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (f *WebhookTest) SetTemplateDefaults() error {
5050
if f.IsLegacyPath {
5151
// Deprecated code - TODO: remove me for go/v5
5252
if f.MultiGroup && f.Resource.Group != "" {
53-
f.Path = filepath.Join("api", "%[version]", "%[group]", "%[version]", "%[kind]_webhook_test.go")
53+
f.Path = filepath.Join("api", "%[group]", "%[version]", "%[kind]_webhook_test.go")
5454
} else {
5555
f.Path = filepath.Join("api", "%[version]", "%[kind]_webhook_test.go")
5656
}

testdata/project-v4-multigroup/internal/webhook/crew/v1/captain_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (v *CaptainCustomValidator) ValidateCreate(ctx context.Context, obj runtime
105105
func (v *CaptainCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
106106
captain, ok := newObj.(*crewv1.Captain)
107107
if !ok {
108-
return nil, fmt.Errorf("expected a Captain object for the newObj but got got %T", newObj)
108+
return nil, fmt.Errorf("expected a Captain object for the newObj but got %T", newObj)
109109
}
110110
captainlog.Info("Validation for Captain upon update", "name", captain.GetName())
111111

testdata/project-v4-multigroup/internal/webhook/example.com/v1alpha1/memcached_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (v *MemcachedCustomValidator) ValidateCreate(ctx context.Context, obj runti
7676
func (v *MemcachedCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
7777
memcached, ok := newObj.(*examplecomv1alpha1.Memcached)
7878
if !ok {
79-
return nil, fmt.Errorf("expected a Memcached object for the newObj but got got %T", newObj)
79+
return nil, fmt.Errorf("expected a Memcached object for the newObj but got %T", newObj)
8080
}
8181
memcachedlog.Info("Validation for Memcached upon update", "name", memcached.GetName())
8282

testdata/project-v4-multigroup/internal/webhook/ship/v2alpha1/cruiser_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (v *CruiserCustomValidator) ValidateCreate(ctx context.Context, obj runtime
7676
func (v *CruiserCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
7777
cruiser, ok := newObj.(*shipv2alpha1.Cruiser)
7878
if !ok {
79-
return nil, fmt.Errorf("expected a Cruiser object for the newObj but got got %T", newObj)
79+
return nil, fmt.Errorf("expected a Cruiser object for the newObj but got %T", newObj)
8080
}
8181
cruiserlog.Info("Validation for Cruiser upon update", "name", cruiser.GetName())
8282

testdata/project-v4-with-plugins/internal/webhook/v1alpha1/memcached_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (v *MemcachedCustomValidator) ValidateCreate(ctx context.Context, obj runti
7676
func (v *MemcachedCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
7777
memcached, ok := newObj.(*examplecomv1alpha1.Memcached)
7878
if !ok {
79-
return nil, fmt.Errorf("expected a Memcached object for the newObj but got got %T", newObj)
79+
return nil, fmt.Errorf("expected a Memcached object for the newObj but got %T", newObj)
8080
}
8181
memcachedlog.Info("Validation for Memcached upon update", "name", memcached.GetName())
8282

0 commit comments

Comments
 (0)