Skip to content

Commit

Permalink
Remove SecretName from CFServiceInstance record
Browse files Browse the repository at this point in the history
  • Loading branch information
klapkov committed Dec 12, 2024
1 parent b731f8e commit 612645d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
5 changes: 2 additions & 3 deletions api/handlers/service_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ var _ = Describe("ServiceInstance", func() {
Describe("GET /v3/service_instances/:guid/credentials", func() {
BeforeEach(func() {
serviceInstanceRepo.GetServiceInstanceReturns(repositories.ServiceInstanceRecord{
GUID: "service-instance-guid",
Type: korifiv1alpha1.UserProvidedType,
SecretName: "secret-name",
GUID: "service-instance-guid",
Type: korifiv1alpha1.UserProvidedType,
}, nil)

serviceInstanceRepo.GetServiceInstanceCredentialsReturns(map[string]any{
Expand Down
15 changes: 7 additions & 8 deletions api/presenter/service_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ var _ = Describe("Service Instance", func() {
baseURL, err = url.Parse("https://api.example.org")
Expect(err).NotTo(HaveOccurred())
record = repositories.ServiceInstanceRecord{
Name: "service-instance-name",
GUID: "service-instance-guid",
SpaceGUID: "space-guid",
SecretName: "secret-name",
Tags: []string{"foo", "bar"},
Type: "user-provided",
CreatedAt: time.UnixMilli(1000),
UpdatedAt: tools.PtrTo(time.UnixMilli(2000)),
Name: "service-instance-name",
GUID: "service-instance-guid",
SpaceGUID: "space-guid",
Tags: []string{"foo", "bar"},
Type: "user-provided",
CreatedAt: time.UnixMilli(1000),
UpdatedAt: tools.PtrTo(time.UnixMilli(2000)),
Labels: map[string]string{
"foo": "bar",
},
Expand Down
2 changes: 0 additions & 2 deletions api/repositories/service_instance_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ type ServiceInstanceRecord struct {
GUID string
SpaceGUID string
PlanGUID string
SecretName string
Tags []string
Type string
Labels map[string]string
Expand Down Expand Up @@ -586,7 +585,6 @@ func cfServiceInstanceToRecord(cfServiceInstance korifiv1alpha1.CFServiceInstanc
GUID: cfServiceInstance.Name,
SpaceGUID: cfServiceInstance.Namespace,
PlanGUID: cfServiceInstance.Spec.PlanGUID,
SecretName: cfServiceInstance.Spec.SecretName,
Tags: cfServiceInstance.Spec.Tags,
Type: string(cfServiceInstance.Spec.Type),
Labels: cfServiceInstance.Labels,
Expand Down
18 changes: 9 additions & 9 deletions api/repositories/service_instance_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ var _ = Describe("ServiceInstanceRepository", func() {
Expect(record.Name).To(Equal(serviceInstanceName))
Expect(record.Type).To(Equal("user-provided"))
Expect(record.Tags).To(ConsistOf([]string{"foo", "bar"}))
Expect(record.SecretName).NotTo(BeEmpty())
Expect(record.Relationships()).To(Equal(map[string]string{
"space": space.Name,
}))
Expand Down Expand Up @@ -134,10 +133,18 @@ var _ = Describe("ServiceInstanceRepository", func() {
It("creates the credentials secret", func() {
Expect(createErr).NotTo(HaveOccurred())

cfServiceInstance := &korifiv1alpha1.CFServiceInstance{
ObjectMeta: metav1.ObjectMeta{
Namespace: record.SpaceGUID,
Name: record.GUID,
},
}
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(cfServiceInstance), cfServiceInstance)).To(Succeed())

credentialsSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: record.SpaceGUID,
Name: record.SecretName,
Name: cfServiceInstance.Spec.SecretName,
},
}
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(credentialsSecret), credentialsSecret)).To(Succeed())
Expand Down Expand Up @@ -209,7 +216,6 @@ var _ = Describe("ServiceInstanceRepository", func() {
Expect(record.Name).To(Equal(serviceInstanceName))
Expect(record.Type).To(Equal("managed"))
Expect(record.Tags).To(ConsistOf([]string{"foo", "bar"}))
Expect(record.SecretName).To(BeEmpty())
Expect(record.Relationships()).To(Equal(map[string]string{
"service_plan": servicePlan.Name,
"space": space.Name,
Expand Down Expand Up @@ -659,11 +665,6 @@ var _ = Describe("ServiceInstanceRepository", func() {
})).To(Succeed())
})

It("updates the secret in the record", func() {
Expect(err).NotTo(HaveOccurred())
Expect(serviceInstanceRecord.SecretName).To(Equal("foo"))
})

It("updates the secret in the spec", func() {
Expect(err).NotTo(HaveOccurred())
Eventually(func(g Gomega) {
Expand Down Expand Up @@ -952,7 +953,6 @@ var _ = Describe("ServiceInstanceRepository", func() {
Expect(record.Name).To(Equal(serviceInstance.Spec.DisplayName))
Expect(record.GUID).To(Equal(serviceInstance.Name))
Expect(record.SpaceGUID).To(Equal(serviceInstance.Namespace))
Expect(record.SecretName).To(Equal(serviceInstance.Spec.SecretName))
Expect(record.Tags).To(Equal(serviceInstance.Spec.Tags))
Expect(record.Type).To(Equal(string(serviceInstance.Spec.Type)))
Expect(record.Labels).To(Equal(map[string]string{"a-label": "a-label-value"}))
Expand Down

0 comments on commit 612645d

Please sign in to comment.