Skip to content

Commit

Permalink
dd
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed Sep 20, 2024
1 parent 6f1bbc3 commit 621a9b0
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
cronjob, ok := newObj.(*batchv1.CronJob)
if !ok {
return nil, fmt.Errorf("expected a CronJob object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a CronJob object for the newObj but got %T", newObj)
}
cronjoblog.Info("Validation for CronJob upon update", "name", cronjob.GetName())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
cronjob, ok := newObj.(*batchv1.CronJob)
if !ok {
return nil, fmt.Errorf("expected a CronJob object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a CronJob object for the newObj but got %T", newObj)
}
cronjoblog.Info("Validation for CronJob upon update", "name", cronjob.GetName())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (v *CronJobCustomValidator) ValidateCreate(ctx context.Context, obj runtime
func (v *CronJobCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
cronjob, ok := newObj.(*batchv2.CronJob)
if !ok {
return nil, fmt.Errorf("expected a CronJob object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a CronJob object for the newObj but got %T", newObj)
}
cronjoblog.Info("Validation for CronJob upon update", "name", cronjob.GetName())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (v *{{ .Resource.Kind }}CustomValidator) ValidateUpdate(ctx context.Context
{{ lower .Resource.Kind }}, ok := newObj.(*{{ .Resource.ImportAlias }}.{{ .Resource.Kind }})
{{- end }}
if !ok {
return nil, fmt.Errorf("expected a {{ .Resource.Kind }} object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a {{ .Resource.Kind }} object for the newObj but got %T", newObj)
}
{{ lower .Resource.Kind }}log.Info("Validation for {{ .Resource.Kind }} upon update", "name", {{ lower .Resource.Kind }}.GetName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func (f *WebhookSuite) SetTemplateDefaults() error {
)

if f.IsLegacyPath {
// If is multigroup the path needs to be ../../.. since it has the group dir.
// If is multigroup the path needs to be ../../../ since it has the group dir.
f.BaseDirectoryRelativePath = `"..", ".."`
if f.MultiGroup && f.Resource.Group != "" {
f.BaseDirectoryRelativePath = `"..", "..", ".."`
}
} else {
// If is multigroup the path needs to be ../../.. since it has the group dir.
// If is multigroup the path needs to be ../../../../ since it has the group dir.
f.BaseDirectoryRelativePath = `"..", "..", ".."`
if f.MultiGroup && f.Resource.Group != "" {
f.BaseDirectoryRelativePath = `"..", "..", "..", ".."`
Expand Down Expand Up @@ -245,7 +245,11 @@ var _ = BeforeSuite(func() {
Expect(cfg).NotTo(BeNil())
scheme := apimachineryruntime.NewScheme()
{{- if .IsLegacyPath -}}
err = AddToScheme(scheme)
{{- else }}
err = %s.AddToScheme(scheme)
{{- end }}
Expect(err).NotTo(HaveOccurred())
err = %s.AddToScheme(scheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (f *WebhookTest) SetTemplateDefaults() error {
if f.IsLegacyPath {
// Deprecated code - TODO: remove me for go/v5
if f.MultiGroup && f.Resource.Group != "" {
f.Path = filepath.Join("api", "%[version]", "%[group]", "%[version]", "%[kind]_webhook_test.go")
f.Path = filepath.Join("api", "%[group]", "%[version]", "%[kind]_webhook_test.go")
} else {
f.Path = filepath.Join("api", "%[version]", "%[kind]_webhook_test.go")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (v *CaptainCustomValidator) ValidateCreate(ctx context.Context, obj runtime
func (v *CaptainCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
captain, ok := newObj.(*crewv1.Captain)
if !ok {
return nil, fmt.Errorf("expected a Captain object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a Captain object for the newObj but got %T", newObj)
}
captainlog.Info("Validation for Captain upon update", "name", captain.GetName())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (v *MemcachedCustomValidator) ValidateCreate(ctx context.Context, obj runti
func (v *MemcachedCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
memcached, ok := newObj.(*examplecomv1alpha1.Memcached)
if !ok {
return nil, fmt.Errorf("expected a Memcached object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a Memcached object for the newObj but got %T", newObj)
}
memcachedlog.Info("Validation for Memcached upon update", "name", memcached.GetName())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (v *CruiserCustomValidator) ValidateCreate(ctx context.Context, obj runtime
func (v *CruiserCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
cruiser, ok := newObj.(*shipv2alpha1.Cruiser)
if !ok {
return nil, fmt.Errorf("expected a Cruiser object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a Cruiser object for the newObj but got %T", newObj)
}
cruiserlog.Info("Validation for Cruiser upon update", "name", cruiser.GetName())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (v *MemcachedCustomValidator) ValidateCreate(ctx context.Context, obj runti
func (v *MemcachedCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
memcached, ok := newObj.(*examplecomv1alpha1.Memcached)
if !ok {
return nil, fmt.Errorf("expected a Memcached object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a Memcached object for the newObj but got %T", newObj)
}
memcachedlog.Info("Validation for Memcached upon update", "name", memcached.GetName())

Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4/internal/webhook/v1/captain_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (v *CaptainCustomValidator) ValidateCreate(ctx context.Context, obj runtime
func (v *CaptainCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
captain, ok := newObj.(*crewv1.Captain)
if !ok {
return nil, fmt.Errorf("expected a Captain object for the newObj but got got %T", newObj)
return nil, fmt.Errorf("expected a Captain object for the newObj but got %T", newObj)
}
captainlog.Info("Validation for Captain upon update", "name", captain.GetName())

Expand Down

0 comments on commit 621a9b0

Please sign in to comment.