Skip to content

Commit bfcc5c8

Browse files
authored
allow btpAccess credentials changes (#607)
* allow btpAccess credentials changes * delete redundant test
1 parent 9afbf5f commit bfcc5c8

File tree

4 files changed

+2
-34
lines changed

4 files changed

+2
-34
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SED = sed -i ''
1818
endif
1919
TEST_PACKAGES=$(shell go list ./... | egrep "controllers|internal/utils|api|client" | egrep -v "client/sm/smfakes" | paste -sd " " -)
2020

21-
GO_TEST = go test $(TEST_PACKAGES) -coverprofile=$(TEST_PROFILE) -ginkgo.flakeAttempts=3
21+
GO_TEST = go test $(TEST_PACKAGES) -coverprofile=$(TEST_PROFILE) -ginkgo.flakeAttempts=2
2222

2323
all: manager
2424

api/v1/serviceinstance_validating_webhook.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,7 @@ func (si *ServiceInstance) ValidateCreate(_ context.Context, _ runtime.Object) (
4545
return nil, nil
4646
}
4747

48-
func (si *ServiceInstance) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (warnings admission.Warnings, err error) {
49-
oldInstance := oldObj.(*ServiceInstance)
50-
newInstance := newObj.(*ServiceInstance)
51-
serviceinstancelog.Info("validate update", "name", newInstance.ObjectMeta.Name)
52-
53-
if oldInstance.Spec.BTPAccessCredentialsSecret != newInstance.Spec.BTPAccessCredentialsSecret {
54-
return nil, fmt.Errorf("changing the btpAccessCredentialsSecret for an existing instance is not allowed")
55-
}
48+
func (si *ServiceInstance) ValidateUpdate(_ context.Context, _, _ runtime.Object) (warnings admission.Warnings, err error) {
5649
return nil, nil
5750
}
5851

api/v1/serviceinstance_validating_webhook_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ var _ = Describe("Service Instance Webhook Test", func() {
1212
instance = getInstance()
1313
})
1414

15-
Context("Validate Update", func() {
16-
When("btpAccessCredentialsSecret changed", func() {
17-
It("should fail", func() {
18-
instance := getInstance()
19-
instance.Spec.BTPAccessCredentialsSecret = ""
20-
newInstance := getInstance()
21-
newInstance.Spec.BTPAccessCredentialsSecret = "new-secret"
22-
_, err := newInstance.ValidateUpdate(nil, instance, newInstance)
23-
Expect(err).To(HaveOccurred())
24-
Expect(err.Error()).To(ContainSubstring("changing the btpAccessCredentialsSecret for an existing instance is not allowed"))
25-
})
26-
})
27-
})
28-
2915
Context("Validate Delete", func() {
3016
When("service instance is marked as prevent deletion", func() {
3117
It("should return error from webhook", func() {

controllers/serviceinstance_controller_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -606,17 +606,6 @@ var _ = Describe("ServiceInstance controller", func() {
606606
})
607607
})
608608

609-
When("subaccount id changed", func() {
610-
It("should fail", func() {
611-
deleteInstance(ctx, serviceInstance, true)
612-
serviceInstance = createInstance(ctx, fakeInstanceName, instanceSpec, nil, true)
613-
serviceInstance.Spec.BTPAccessCredentialsSecret = "12345"
614-
err := k8sClient.Update(ctx, serviceInstance)
615-
Expect(err).To(HaveOccurred())
616-
Expect(err.Error()).To(ContainSubstring("changing the btpAccessCredentialsSecret for an existing instance is not allowed"))
617-
})
618-
})
619-
620609
When("UserInfo changed", func() {
621610
It("should fail", func() {
622611
serviceInstance.Spec.UserInfo = &authv1.UserInfo{

0 commit comments

Comments
 (0)