Skip to content

Commit

Permalink
prevent deletion init
Browse files Browse the repository at this point in the history
  • Loading branch information
TalShorSap committed Aug 2, 2023
1 parent f07d401 commit 87b57b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions controllers/serviceinstance_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ var _ = Describe("ServiceInstance controller", func() {

instanceSpec := v1.ServiceInstanceSpec{
ExternalName: fakeInstanceExternalName,
PreventDeletion: true,
ServicePlanName: fakePlanName,
ServiceOfferingName: fakeOfferingName,
Parameters: &runtime.RawExtension{
Expand Down Expand Up @@ -625,7 +624,7 @@ var _ = Describe("ServiceInstance controller", func() {
BeforeEach(func() {
fakeClient.DeprovisionReturns("", nil)
})
FIt("should delete the k8s instance", func() {
It("should delete the k8s instance", func() {
deleteInstance(ctx, serviceInstance, true)
})
})
Expand Down
26 changes: 14 additions & 12 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,23 @@ package controllers
import (
"context"
"crypto/tls"
"github.com/SAP/sap-btp-service-operator/api/v1/webhooks"
"net"
"path/filepath"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
"testing"
"time"

"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"fmt"
"github.com/SAP/sap-btp-service-operator/api"
"github.com/SAP/sap-btp-service-operator/api/v1/webhooks"
"github.com/SAP/sap-btp-service-operator/client/sm"
"github.com/SAP/sap-btp-service-operator/client/sm/smfakes"
"github.com/SAP/sap-btp-service-operator/internal/config"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"

"fmt"

ctrl "sigs.k8s.io/controller-runtime"

Expand Down Expand Up @@ -113,6 +111,16 @@ var _ = BeforeSuite(func(done Done) {
testConfig := config.Get()
testConfig.SyncPeriod = syncPeriod
testConfig.PollInterval = pollInterval

k8sManager.GetWebhookServer().Register("/mutate-services-cloud-sap-com-v1-serviceinstance", &webhook.Admission{Handler: &webhooks.ServiceInstanceDefaulter{Decoder: admission.NewDecoder(k8sManager.GetScheme())}})
k8sManager.GetWebhookServer().Register("/mutate-services-cloud-sap-com-v1-servicebinding", &webhook.Admission{Handler: &webhooks.ServiceBindingDefaulter{Decoder: admission.NewDecoder(k8sManager.GetScheme())}})

err = (&servicesv1.ServiceBinding{}).SetupWebhookWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

err = (&servicesv1.ServiceInstance{}).SetupWebhookWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

err = (&ServiceInstanceReconciler{
BaseReconciler: &BaseReconciler{
Client: k8sManager.GetClient(),
Expand All @@ -125,12 +133,6 @@ var _ = BeforeSuite(func(done Done) {
}).SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

k8sManager.GetWebhookServer().Register("/mutate-services-cloud-sap-com-v1-serviceinstance", &webhook.Admission{Handler: &webhooks.ServiceInstanceDefaulter{Decoder: admission.NewDecoder(k8sManager.GetScheme())}})
k8sManager.GetWebhookServer().Register("/mutate-services-cloud-sap-com-v1-servicebinding", &webhook.Admission{Handler: &webhooks.ServiceBindingDefaulter{Decoder: admission.NewDecoder(k8sManager.GetScheme())}})

err = (&servicesv1.ServiceBinding{}).SetupWebhookWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

err = (&ServiceBindingReconciler{
BaseReconciler: &BaseReconciler{
Client: k8sManager.GetClient(),
Expand Down

0 comments on commit 87b57b8

Please sign in to comment.