Implement "POST /v3/service_brokers" #3330
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Is there a related GitHub Issue?
#3263
What is this change about?
Implement
POST /v3/service_brokers
brokers are currently out of scope)
CFServiceBroker
custom resourceCFServiceBroker
controller sets itsReady
statePOST /v3/service_brokers
CFServiceBroker
object is created in the root namespace (as itis globally available)
GET /v3/jobs/service_broker.create~<broker-guid>
to returnCOMPLETE
job state once the broker is readyDiscussion
I would like to take the opportunity of this PR to discuss an alternative way to model Korifi objects.
Currently, we have three types - the k8s object spec, the repository record, the request objects in the API (on e.g.
create
) and the object being returned from the API (on e.g.get
). While those types are quite similar, we need boilerplate code to convert them. For example:CFApp
payload object describes the CFAppCFApp.Spec
CFApp
object is translated to repository recordThe approach this PR takes to model the new
ServiceBroker
resource is a bit different. Instead of having so many different types, model the object into multiple small reusable type and aggregate them as necessary. Here are the details:model
package where we put small reusable typesCFResource
type is a layer that is needed for API responses - it has all the common API response fields likeGUID
,createdAt
, etc.model.services.ServiceBroker
type describes a service broker resource and only contains the fields that are specific to the service broker resource onlykorifiv1alhpa1.CFServiceBrokerSpec
type embedsmodel.services.ServiceBroker
and adds a k8s-specific field to reference the credentials secret. Note that this reference only makes sense to k8s and is therefore placed in the spec typerepositories.CreateServiceBrokerMessage
) composes the common typesrepositories.ServiceBrokerResource
object which, agains, only composes model typespayloads.ServiceBrokerCreate
composes the model objects in a way to conform to the CF API specificationget service-broker
is implemented, the resource object returned by the repository could be presented in a fairly simple manner as the service broker resource already fits the CF API service broker object. It only lacks the links section which could be added by the presenter.So what do you think about this approach? I think it has its merits though it might look a bit confusing at first. If we agree on it, then we could use it for new resources and experiment with migrating existing ones (hopefully that should be possible in a backwards compatible manner). If not, we could always use the well known pattern.
Does this PR introduce a breaking change?
No
Acceptance Steps
See story
Tag your pair, your PM, and/or team
@cloudfoundry/wg-cf-on-k8s