Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 For go/v3 plugin: Avoid to add duplicated code fragments #2619

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved

%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
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved

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