brokerapi

package module
v7.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 11 Imported by: 2

README

brokerapi

Build Status

A Go package for building V2 Open Service Broker API compliant Service Brokers.

Docs

Dependencies

Contributing

We appreciate and welcome open source contibution. We will try to review the changes as soon as we can.

Any changes should be made on the main folders and files and not in the v7 folder. We will review the changes and make sure they are included in the v7 folder as part of the merge process.

Usage

brokerapi defines a ServiceBroker interface. Pass an implementation of this to brokerapi.New, which returns an http.Handler that you can use to serve handle HTTP requests.

Alternatively, if you already have a *mux.Router that you want to attach service broker routes to, you can use brokerapi.AttachRoutes. Note in this case, the Basic Authentication and Originating Identity middleware will not be set up, so you will have to attach them manually if required.

Error types

brokerapi defines a handful of error types in service_broker.go for some common error cases that your service broker may encounter. Return these from your ServiceBroker methods where appropriate, and brokerapi will do the "right thing" (™), and give Cloud Foundry an appropriate status code, as per the Service Broker API specification.

Custom Errors

NewFailureResponse() allows you to return a custom error from any of the ServiceBroker interface methods which return an error. Within this you must define an error, a HTTP response status code and a logging key. You can also use the NewFailureResponseBuilder() to add a custom Error: value in the response, or indicate that the broker should return an empty response rather than the error message.

Request Context

When provisioning a service brokerapi validates the service_id and plan_id in the request, attaching the found instances to the request Context. These values can be retrieved in a brokerapi.ServiceBroker implementation using utility methods RetrieveServiceFromContext and RetrieveServicePlanFromContext as shown below.

func (sb *ServiceBrokerImplementation) Provision(ctx context.Context,
  instanceID string, details brokerapi.ProvisionDetails, asyncAllowed bool) {

  service := brokerapi.RetrieveServiceFromContext(ctx)
  if service == nil {
    // Lookup service
  }

  // [..]
}

Originating Identity

The request context for every request contains the unparsed X-Broker-API-Originating-Identity header under the key originatingIdentityKey. More details on how the Open Service Broker API manages request originating identity is available here.

Example Service Broker

You can see the cf-redis service broker uses the BrokerAPI package to create a service broker for Redis.

Documentation

Index

Constants

View Source
const (
	PermissionRouteForwarding = domain.PermissionRouteForwarding
	PermissionSyslogDrain     = domain.PermissionSyslogDrain
	PermissionVolumeMount     = domain.PermissionVolumeMount
)

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

Variables

View Source
var (
	ErrInstanceAlreadyExists = apiresponses.ErrInstanceAlreadyExists

	ErrInstanceDoesNotExist = apiresponses.ErrInstanceDoesNotExist

	ErrInstanceLimitMet = apiresponses.ErrInstanceLimitMet

	ErrBindingAlreadyExists = apiresponses.ErrBindingAlreadyExists

	ErrBindingDoesNotExist = apiresponses.ErrBindingDoesNotExist

	ErrBindingNotFound = apiresponses.ErrBindingNotFound

	ErrAsyncRequired = apiresponses.ErrAsyncRequired

	ErrPlanChangeNotSupported = apiresponses.ErrPlanChangeNotSupported

	ErrRawParamsInvalid = apiresponses.ErrRawParamsInvalid

	ErrAppGuidNotProvided = apiresponses.ErrAppGuidNotProvided

	ErrPlanQuotaExceeded = apiresponses.ErrPlanQuotaExceeded

	ErrServiceQuotaExceeded = apiresponses.ErrServiceQuotaExceeded

	ErrConcurrentInstanceAccess = apiresponses.ErrConcurrentInstanceAccess

	ErrMaintenanceInfoConflict = apiresponses.ErrMaintenanceInfoConflict

	ErrMaintenanceInfoNilConflict = apiresponses.ErrMaintenanceInfoNilConflict
)

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

Functions

func AddServicePlanToContext

func AddServicePlanToContext(ctx context.Context, plan *ServicePlan) context.Context

func AddServiceToContext

func AddServiceToContext(ctx context.Context, service *Service) context.Context

func AttachRoutes

func AttachRoutes(router *mux.Router, serviceBroker ServiceBroker, logger lager.Logger)

func BindableValue deprecated

func BindableValue(v bool) *bool

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

func FreeValue deprecated

func FreeValue(v bool) *bool

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

func GetJsonNames deprecated

func GetJsonNames(s reflect.Value) (res []string)

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

func New

func New(serviceBroker ServiceBroker, logger lager.Logger, brokerCredentials BrokerCredentials) http.Handler

Types

type AsyncBindResponse deprecated

type AsyncBindResponse = apiresponses.AsyncBindResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type BindDetails deprecated

type BindDetails = domain.BindDetails

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type BindResource deprecated

type BindResource = domain.BindResource

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type Binding deprecated

type Binding = domain.Binding

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type BindingResponse deprecated

type BindingResponse = apiresponses.BindingResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type BrokerCredentials

type BrokerCredentials struct {
	Username string
	Password string
}

type CatalogResponse deprecated

type CatalogResponse = apiresponses.CatalogResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type DeprovisionDetails deprecated

type DeprovisionDetails = domain.DeprovisionDetails

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type DeprovisionResponse deprecated

type DeprovisionResponse = apiresponses.DeprovisionResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type DeprovisionServiceSpec deprecated

type DeprovisionServiceSpec = domain.DeprovisionServiceSpec

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type DetailsWithRawContext deprecated

type DetailsWithRawContext interface {
	domain.DetailsWithRawContext
}

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type DetailsWithRawParameters deprecated

type DetailsWithRawParameters interface {
	domain.DetailsWithRawParameters
}

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type EmptyResponse deprecated

type EmptyResponse = apiresponses.EmptyResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type ErrorResponse deprecated

type ErrorResponse = apiresponses.ErrorResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type ExperimentalVolumeMount deprecated

type ExperimentalVolumeMount = domain.ExperimentalVolumeMount

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ExperimentalVolumeMountBindingResponse deprecated

type ExperimentalVolumeMountBindingResponse = apiresponses.ExperimentalVolumeMountBindingResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type ExperimentalVolumeMountPrivate deprecated

type ExperimentalVolumeMountPrivate = domain.ExperimentalVolumeMountPrivate

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type FailureResponse deprecated

type FailureResponse = apiresponses.FailureResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses FailureResponse can be returned from any of the `ServiceBroker` interface methods which allow an error to be returned. Doing so will provide greater control over the HTTP response.

func NewFailureResponse deprecated

func NewFailureResponse(err error, statusCode int, loggerAction string) *FailureResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses NewFailureResponse returns a pointer to a new instance of FailureResponse. err will by default be used as both a logging message and HTTP response description. statusCode is the HTTP status code to be returned, must be 4xx or 5xx loggerAction is a short description which will be used as the action if the error is logged.

type FailureResponseBuilder deprecated

type FailureResponseBuilder = apiresponses.FailureResponseBuilder

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses FailureResponseBuilder provides a fluent set of methods to build a *FailureResponse.

func NewFailureResponseBuilder deprecated

func NewFailureResponseBuilder(err error, statusCode int, loggerAction string) *FailureResponseBuilder

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses NewFailureResponseBuilder returns a pointer to a newly instantiated FailureResponseBuilder Accepts required arguments to create a FailureResponse.

type GetBindingResponse deprecated

type GetBindingResponse = apiresponses.GetBindingResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type GetBindingSpec deprecated

type GetBindingSpec = domain.GetBindingSpec

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type GetInstanceDetailsSpec deprecated

type GetInstanceDetailsSpec = domain.GetInstanceDetailsSpec

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type GetInstanceResponse deprecated

type GetInstanceResponse = apiresponses.GetInstanceResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type LastOperation deprecated

type LastOperation = domain.LastOperation

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type LastOperationResponse deprecated

type LastOperationResponse = apiresponses.LastOperationResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type LastOperationState deprecated

type LastOperationState = domain.LastOperationState

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

const (
	InProgress LastOperationState = "in progress"
	Succeeded  LastOperationState = "succeeded"
	Failed     LastOperationState = "failed"
)

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type MaintenanceInfo deprecated

type MaintenanceInfo = domain.MaintenanceInfo

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type PollDetails deprecated

type PollDetails = domain.PollDetails

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type PreviousValues deprecated

type PreviousValues = domain.PreviousValues

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ProvisionDetails deprecated

type ProvisionDetails = domain.ProvisionDetails

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ProvisionedServiceSpec deprecated

type ProvisionedServiceSpec = domain.ProvisionedServiceSpec

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ProvisioningResponse deprecated

type ProvisioningResponse = apiresponses.ProvisioningResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type RequiredPermission deprecated

type RequiredPermission = domain.RequiredPermission

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type Schema deprecated

type Schema = domain.Schema

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type Service deprecated

type Service = domain.Service

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

func RetrieveServiceFromContext

func RetrieveServiceFromContext(ctx context.Context) *Service

type ServiceBindingSchema deprecated

type ServiceBindingSchema = domain.ServiceBindingSchema

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ServiceBroker deprecated

type ServiceBroker interface {
	domain.ServiceBroker
}

Deprecated: Use github.com/pivotal-cf/brokerapi/domain Each method of the ServiceBroker interface maps to an individual endpoint of the Open Service Broker API.

The specification is available here: https://github.com/openservicebrokerapi/servicebroker/blob/v2.14/spec.md

The OpenAPI documentation is available here: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/openservicebrokerapi/servicebroker/v2.14/openapi.yaml

type ServiceDashboardClient deprecated

type ServiceDashboardClient = domain.ServiceDashboardClient

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ServiceInstanceSchema deprecated

type ServiceInstanceSchema = domain.ServiceInstanceSchema

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ServiceMetadata deprecated

type ServiceMetadata = domain.ServiceMetadata

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ServicePlan deprecated

type ServicePlan = domain.ServicePlan

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

func RetrieveServicePlanFromContext

func RetrieveServicePlanFromContext(ctx context.Context) *ServicePlan

type ServicePlanCost deprecated

type ServicePlanCost = domain.ServicePlanCost

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ServicePlanMetadata deprecated

type ServicePlanMetadata = domain.ServicePlanMetadata

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type ServiceSchemas deprecated

type ServiceSchemas = domain.ServiceSchemas

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type SharedDevice deprecated

type SharedDevice = domain.SharedDevice

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type UnbindDetails deprecated

type UnbindDetails = domain.UnbindDetails

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type UnbindResponse deprecated

type UnbindResponse = apiresponses.UnbindResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type UnbindSpec deprecated

type UnbindSpec = domain.UnbindSpec

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type UpdateDetails deprecated

type UpdateDetails = domain.UpdateDetails

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type UpdateResponse deprecated

type UpdateResponse = apiresponses.UpdateResponse

Deprecated: Use github.com/pivotal-cf/brokerapi/domain/apiresponses

type UpdateServiceSpec deprecated

type UpdateServiceSpec = domain.UpdateServiceSpec

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

type VolumeMount deprecated

type VolumeMount = domain.VolumeMount

Deprecated: Use github.com/pivotal-cf/brokerapi/domain

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
v7

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL