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

Add Service Credential Bindings of type Key #3635

Closed
wants to merge 7 commits into from

Conversation

ddraganovv
Copy link
Contributor

Is there a related GitHub Issue?

#2320

What is this change about?

With this PR we are introducing a new type of service binding - 'key'.

Does this PR introduce a breaking change?

No

Acceptance Steps

Tag your pair, your PM, and/or team

klapkov and others added 5 commits November 7, 2024 16:14
* Added Service Credential Bindings of type Key 
* Added type label to CFServiceBinding CRD
* Tweaked list for bindings so you can filter by type
---------

Co-authored-by: Dimitar Draganov <[email protected]>
Copy link

linux-foundation-easycla bot commented Nov 27, 2024

CLA Not Signed

Copy link
Member

@georgethebeatle georgethebeatle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments inline. There are also some failing checks - linters and tests - that should be fixed

serviceInstance, err := h.serviceInstanceRepo.GetServiceInstance(r.Context(), authInfo, payload.Relationships.ServiceInstance.Data.GUID)
if err != nil {
return nil, apierrors.LogAndReturn(logger, apierrors.ForbiddenAsNotFound(err), "failed to get "+repositories.ServiceInstanceResourceType)
}

if app.SpaceGUID != serviceInstance.SpaceGUID {
if payload.Type == korifiv1alpha1.CFServiceBindingTypeKey && serviceInstance.Type != korifiv1alpha1.ManagedType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be removed as we do it in the createUserProvided method.

BeforeEach(func() {
createRoleBinding(ctx, userName, spaceDeveloperRole.Name, space.Name)
createMsg = repositories.CreateServiceBindingMessage{
Type: korifiv1alpha1.CFServiceBindingTypeApp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type should be "key"?

},
AppRef: corev1.LocalObjectReference{
Name: appGUID,
It("fails the validation", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error assertion?

Describe("type app", func() {

When("the user is not allowed to create CFServiceBindings", func() {
BeforeEach(func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This BeforeEach should be moved up to the Describe("type app")

).To(Succeed())

Expect(serviceBinding.Labels).To(HaveKeyWithValue("servicebinding.io/provisioned-service", "true"))
Expect(serviceBinding.Spec.Type).To(Equal(korifiv1alpha1.CFServiceBindingTypeKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should assert that type is "app"

"Name": Equal(serviceBinding4.Spec.DisplayName),
"ServiceInstanceGUID": Equal(serviceBinding4.Spec.Service.Name),
"SpaceGUID": Equal(serviceBinding4.Namespace),
}),
))
})
})

When("filtered by service instance GUID", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filtering by instance GUID is orhogonal to filtering by type, so this test should not be changed.

@@ -840,6 +954,9 @@ var _ = Describe("ServiceBindingRepo", func() {
Expect(k8s.PatchResource(ctx, k8sClient, serviceBinding3, func() {
serviceBinding3.Labels = map[string]string{"not_foo": "NOT_FOO"}
})).To(Succeed())
Expect(k8s.PatchResource(ctx, k8sClient, serviceBinding4, func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listing service bindings by labels is orthogonal to type "key" so this test should not be modified

@@ -196,11 +197,11 @@ var _ = Describe("CFServiceBinding", func() {
g.Expect(sbServiceBinding.Spec.Name).To(Equal(binding.Name))
g.Expect(sbServiceBinding.Spec.Type).To(Equal("user-provided"))
g.Expect(sbServiceBinding.Spec.Provider).To(BeEmpty())
g.Expect(sbServiceBinding.Spec.Type).To(Equal(korifiv1alpha1.CFServiceBindingTypeApp))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should go. The sbServiceBinding does not have types "app" and "key" as it is a different spec. It can be of type "user-provided" or "managed" and this is already checked on line 198


g.Expect(sbServiceBinding.Labels).To(SatisfyAll(
HaveKeyWithValue(bindings.ServiceBindingGUIDLabel, binding.Name),
HaveKeyWithValue(korifiv1alpha1.CFAppGUIDLabelKey, cfAppGUID),
HaveKeyWithValue(bindings.ServiceCredentialBindingTypeLabel, "app"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line shoul stay as it checks the labels of the service binding io bindings

@ddraganovv ddraganovv closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants