Skip to content

Commit

Permalink
add subaccountId to status
Browse files Browse the repository at this point in the history
  • Loading branch information
TalShorSap committed Sep 21, 2023
1 parent 60199ed commit acf2b62
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/serviceinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ func (r *ServiceInstanceReconciler) createInstance(ctx context.Context, smClient
}
log.Info("Instance provisioned successfully")
serviceInstance.Status.InstanceID = provision.InstanceID
if serviceInstance.Spec.SubaccountID != "" {
serviceInstance.Status.SubaccountID = serviceInstance.Spec.SubaccountID
}

if len(provision.Tags) > 0 {
tags, err := getTags(provision.Tags)
Expand Down
26 changes: 26 additions & 0 deletions controllers/serviceinstance_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
testNamespace = "ic-test-namespace"
fakeOfferingName = "offering-a"
fakePlanName = "plan-a"
testSubaccountID = "subaccountID"
)

var _ = Describe("ServiceInstance controller", func() {
Expand Down Expand Up @@ -69,6 +70,24 @@ var _ = Describe("ServiceInstance controller", func() {
},
}

subaccountInstanceSpec := v1.ServiceInstanceSpec{
ExternalName: fakeInstanceExternalName,
SubaccountID: testSubaccountID,
ServicePlanName: fakePlanName,
ServiceOfferingName: fakeOfferingName,
Parameters: &runtime.RawExtension{
Raw: []byte(`{"key": "value"}`),
},
ParametersFrom: []v1.ParametersFromSource{
{
SecretKeyRef: &v1.SecretKeyReference{
Name: "param-secret",
Key: "secret-parameter",
},
},
},
}

sharedInstanceSpec := v1.ServiceInstanceSpec{
ExternalName: fakeInstanceExternalName + "shared",
ServicePlanName: fakePlanName + "shared",
Expand Down Expand Up @@ -228,6 +247,13 @@ var _ = Describe("ServiceInstance controller", func() {
})
})

When("subaccountID provided", func() {
It("should add the subaccountID also to the status", func() {
serviceInstance = createInstance(ctx, subaccountInstanceSpec, true)
Expect(serviceInstance.Status.SubaccountID).To(Equal(testSubaccountID))
})
})

When("provision request to SM fails", func() {
Context("with 400 status", func() {
errMessage := "failed to provision instance"
Expand Down

0 comments on commit acf2b62

Please sign in to comment.