Skip to content

Commit

Permalink
Merge pull request #2619 from mrkm4ntr/webhook-version
Browse files Browse the repository at this point in the history
🐛 For go/v3 plugin: Avoid to add duplicated code fragments
  • Loading branch information
k8s-ci-robot authored Apr 29, 2022
2 parents 69de830 + 252a250 commit 0976383
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (f *WebhookSuite) SetTemplateDefaults() error {

f.TemplateBody = fmt.Sprintf(webhookTestSuiteTemplate,
machinery.NewMarkerFor(f.Path, importMarker),
admissionImportAlias,
machinery.NewMarkerFor(f.Path, addSchemeMarker),
machinery.NewMarkerFor(f.Path, addWebhookManagerMarker),
"%s",
Expand Down Expand Up @@ -113,7 +114,6 @@ func (f *WebhookSuite) GetCodeFragments() machinery.CodeFragmentsMap {

// Generate add scheme code fragments
addScheme := make([]string, 0)
addScheme = append(addScheme, fmt.Sprintf(addschemeCodeFragment, admissionImportAlias))

// Generate add webhookManager code fragments
addWebhookManager := make([]string, 0)
Expand Down Expand Up @@ -198,6 +198,9 @@ var _ = BeforeSuite(func() {
err = AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
err = %s.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
%s
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
Expand Down
3 changes: 0 additions & 3 deletions testdata/project-v3-config/api/v1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ var _ = BeforeSuite(func() {
err = admissionv1beta1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = admissionv1beta1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:scheme

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
Expand Down
6 changes: 0 additions & 6 deletions testdata/project-v3/api/v1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ var _ = BeforeSuite(func() {
err = admissionv1beta1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = admissionv1beta1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = admissionv1beta1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:scheme

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
Expand Down

0 comments on commit 0976383

Please sign in to comment.