Documentation ¶
Overview ¶
Package broker holds the code that users of the skeleton write for their broker. To make a broker, fill out:
- The Options type, which holds options for the broker
- The AddFlags function, which adds CLI flags for an Options
- The methods of the BusinessLogic type, which implements the broker's business logic
- The NewBusinessLogic function, which creates a BusinessLogic from the Options the program is run with
Index ¶
- func AddFlags(o *Options)
- func ApplyParamsToStatement(statement string, args ...string) string
- func CanGetBindings(status string) bool
- func ConflictErrorWithMessage(description string) error
- func CrudeOSBIHacks(router *mux.Router, b *BusinessLogic)
- func FinishedTask(storage Storage, taskId string, retries int64, result string, status string)
- func HttpWrite(w http.ResponseWriter, status int, obj interface{})
- func InProgress(status string) bool
- func InternalServerError() error
- func IsAvailable(status string) bool
- func NotFound() error
- func RandomString(n int) string
- func RunBackgroundTasks(ctx context.Context, o Options) error
- func RunPreprovisionTasks(ctx context.Context, o Options, namePrefix string, storage Storage, wait int64)
- func RunWorkerTasks(ctx context.Context, o Options, namePrefix string, storage Storage) error
- func TickTocPreprovisionTasks(ctx context.Context, o Options, namePrefix string, storage Storage)
- func UnprocessableEntity() error
- func UnprocessableEntityWithMessage(err string, description string) error
- func UpdateTaskStatus(storage Storage, taskId string, retries int64, result string, status string)
- func UpgradeAcrossProviders(storage Storage, fromDb *Instance, toPlanId string, namePrefix string) (string, error)
- func UpgradeWithinProviders(storage Storage, fromDb *Instance, toPlanId string, namePrefix string) (string, error)
- type Action
- type ActionBase
- func (b *ActionBase) ActionSchemaHandler(w http.ResponseWriter, r *http.Request)
- func (b *ActionBase) AddActions(name string, path string, method string, ...) error
- func (b *ActionBase) ConvertActionsToExtensions(serviceId string) []osb.ExtensionAPI
- func (b *ActionBase) RouteActions(router *mux.Router) error
- type BusinessLogic
- func (b *BusinessLogic) Bind(request *osb.BindRequest, c *broker.RequestContext) (*broker.BindResponse, error)
- func (b *BusinessLogic) Deprovision(request *osb.DeprovisionRequest, c *broker.RequestContext) (*broker.DeprovisionResponse, error)
- func (b *BusinessLogic) GetBinding(request *osb.GetBindingRequest, context *broker.RequestContext) (*osb.GetBindingResponse, error)
- func (b *BusinessLogic) GetCatalog(c *broker.RequestContext) (*broker.CatalogResponse, error)
- func (b *BusinessLogic) GetInstanceById(Id string) (*Instance, error)
- func (b *BusinessLogic) GetUnclaimedInstance(PlanId string, InstanceId string) (*Instance, error)
- func (b *BusinessLogic) LastOperation(request *osb.LastOperationRequest, c *broker.RequestContext) (*broker.LastOperationResponse, error)
- func (b *BusinessLogic) Provision(request *osb.ProvisionRequest, c *broker.RequestContext) (*broker.ProvisionResponse, error)
- func (b *BusinessLogic) Unbind(request *osb.UnbindRequest, c *broker.RequestContext) (*broker.UnbindResponse, error)
- func (b *BusinessLogic) Update(request *osb.UpdateInstanceRequest, c *broker.RequestContext) (*broker.UpdateInstanceResponse, error)
- func (b *BusinessLogic) ValidateBrokerAPIVersion(version string) error
- type ChangePlansTaskMetadata
- type ChangeProvidersTaskMetadata
- type Entry
- type InfoData
- type Instance
- type MongodbProvider
- func (provider MongodbProvider) Deprovision(instance *Instance, takeSnapshot bool) error
- func (provider MongodbProvider) GetInstance(name string, plan *ProviderPlan) (*Instance, error)
- func (provider MongodbProvider) Modify(instance *Instance, plan *ProviderPlan) (*Instance, error)
- func (provider MongodbProvider) PerformPostProvision(db *Instance) (*Instance, error)
- func (provider MongodbProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*Instance, error)
- func (provider MongodbProvider) Tag(Instance *Instance, Name string, Value string) error
- func (provider MongodbProvider) Untag(Instance *Instance, Name string) error
- type MongodbProviderPlanSettings
- type Options
- type PostgresStorage
- func (b *PostgresStorage) AddInstance(Instance *Instance) error
- func (b *PostgresStorage) AddTask(Id string, action TaskAction, metadata string) (string, error)
- func (b *PostgresStorage) DeleteInstance(Instance *Instance) error
- func (b *PostgresStorage) GetInstance(Id string) (*Entry, error)
- func (b *PostgresStorage) GetPlanByID(planId string) (*ProviderPlan, error)
- func (b *PostgresStorage) GetPlans(serviceId string) ([]ProviderPlan, error)
- func (b *PostgresStorage) GetServices() ([]osb.Service, error)
- func (b *PostgresStorage) GetUnclaimedInstance(PlanId string, InstanceId string) (*Entry, error)
- func (b *PostgresStorage) IsRestoring(dbId string) (bool, error)
- func (b *PostgresStorage) IsUpgrading(dbId string) (bool, error)
- func (b *PostgresStorage) NukeInstance(Id string) error
- func (b *PostgresStorage) PopPendingTask() (*Task, error)
- func (b *PostgresStorage) ReturnClaimedInstance(Id string) error
- func (b *PostgresStorage) StartProvisioningTasks() ([]Entry, error)
- func (b *PostgresStorage) UpdateInstance(Instance *Instance, PlanId string) error
- func (b *PostgresStorage) UpdateTask(Id string, status *string, retries *int64, metadata *string, result *string, ...) error
- func (b *PostgresStorage) ValidateInstanceID(id string) error
- func (b *PostgresStorage) WarnOnUnfinishedTasks()
- type Provider
- type ProviderPlan
- type Providers
- type ResourceSpec
- type ResourceUrlSpec
- type RestoreDbTaskMetadata
- type Stat
- type Storage
- type Task
- type TaskAction
- type WebhookTaskMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyParamsToStatement ¶
func CanGetBindings ¶
func CrudeOSBIHacks ¶
func CrudeOSBIHacks(router *mux.Router, b *BusinessLogic)
These are hacks to support more of V2.14 such as get service instance and get service bindings.
func FinishedTask ¶
func HttpWrite ¶
func HttpWrite(w http.ResponseWriter, status int, obj interface{})
func InProgress ¶
func InternalServerError ¶
func InternalServerError() error
func IsAvailable ¶
func RandomString ¶
func RunPreprovisionTasks ¶
func RunWorkerTasks ¶
func UnprocessableEntity ¶
func UnprocessableEntity() error
func UpdateTaskStatus ¶
func UpgradeAcrossProviders ¶
Types ¶
type ActionBase ¶
func (*ActionBase) ActionSchemaHandler ¶
func (b *ActionBase) ActionSchemaHandler(w http.ResponseWriter, r *http.Request)
func (*ActionBase) AddActions ¶
func (*ActionBase) ConvertActionsToExtensions ¶
func (b *ActionBase) ConvertActionsToExtensions(serviceId string) []osb.ExtensionAPI
func (*ActionBase) RouteActions ¶
func (b *ActionBase) RouteActions(router *mux.Router) error
type BusinessLogic ¶
type BusinessLogic struct { ActionBase // contains filtered or unexported fields }
func NewBusinessLogic ¶
func NewBusinessLogic(ctx context.Context, o Options) (*BusinessLogic, error)
func (*BusinessLogic) Bind ¶
func (b *BusinessLogic) Bind(request *osb.BindRequest, c *broker.RequestContext) (*broker.BindResponse, error)
func (*BusinessLogic) Deprovision ¶
func (b *BusinessLogic) Deprovision(request *osb.DeprovisionRequest, c *broker.RequestContext) (*broker.DeprovisionResponse, error)
func (*BusinessLogic) GetBinding ¶
func (b *BusinessLogic) GetBinding(request *osb.GetBindingRequest, context *broker.RequestContext) (*osb.GetBindingResponse, error)
func (*BusinessLogic) GetCatalog ¶
func (b *BusinessLogic) GetCatalog(c *broker.RequestContext) (*broker.CatalogResponse, error)
func (*BusinessLogic) GetInstanceById ¶
func (b *BusinessLogic) GetInstanceById(Id string) (*Instance, error)
func (*BusinessLogic) GetUnclaimedInstance ¶
func (b *BusinessLogic) GetUnclaimedInstance(PlanId string, InstanceId string) (*Instance, error)
func (*BusinessLogic) LastOperation ¶
func (b *BusinessLogic) LastOperation(request *osb.LastOperationRequest, c *broker.RequestContext) (*broker.LastOperationResponse, error)
func (*BusinessLogic) Provision ¶
func (b *BusinessLogic) Provision(request *osb.ProvisionRequest, c *broker.RequestContext) (*broker.ProvisionResponse, error)
A piece of advice, never try to make this syncronous by waiting for a to return a response. The problem is that can take up to 10 minutes in my experience (depending on the provider), and aside from the API call timing out the other issue is it can cause the mutex lock to make the entire API unresponsive.
func (*BusinessLogic) Unbind ¶
func (b *BusinessLogic) Unbind(request *osb.UnbindRequest, c *broker.RequestContext) (*broker.UnbindResponse, error)
func (*BusinessLogic) Update ¶
func (b *BusinessLogic) Update(request *osb.UpdateInstanceRequest, c *broker.RequestContext) (*broker.UpdateInstanceResponse, error)
func (*BusinessLogic) ValidateBrokerAPIVersion ¶
func (b *BusinessLogic) ValidateBrokerAPIVersion(version string) error
type ChangePlansTaskMetadata ¶
type ChangePlansTaskMetadata struct {
Plan string `json:"plan"`
}
type ChangeProvidersTaskMetadata ¶
type ChangeProvidersTaskMetadata struct {
Plan string `json:"plan"`
}
type Instance ¶
type Instance struct { Id string `json:"id"` Name string `json:"name"` ProviderId string `json:"provider_id"` Plan *ProviderPlan `json:"plan,omitempty"` Username string `json:"username"` Password string `json:"password"` Endpoint string `json:"endpoint"` Status string `json:"status"` Ready bool `json:"ready"` Engine string `json:"engine"` EngineVersion string `json:"engine_version"` Scheme string `json:"scheme"` }
func GetInstanceById ¶
type MongodbProvider ¶
type MongodbProvider struct { Provider // contains filtered or unexported fields }
func NewMongodbProvider ¶
func NewMongodbProvider(namePrefix string) (MongodbProvider, error)
func (MongodbProvider) Deprovision ¶
func (provider MongodbProvider) Deprovision(instance *Instance, takeSnapshot bool) error
func (MongodbProvider) GetInstance ¶
func (provider MongodbProvider) GetInstance(name string, plan *ProviderPlan) (*Instance, error)
func (MongodbProvider) Modify ¶
func (provider MongodbProvider) Modify(instance *Instance, plan *ProviderPlan) (*Instance, error)
func (MongodbProvider) PerformPostProvision ¶
func (provider MongodbProvider) PerformPostProvision(db *Instance) (*Instance, error)
func (MongodbProvider) Provision ¶
func (provider MongodbProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*Instance, error)
type MongodbProviderPlanSettings ¶
type MongodbProviderPlanSettings struct { MasterUri string `json:"master_uri"` Engine string `json:"engine"` EngineVersion string `json:"engine_version"` }
provider=mongodb in database These values come out of the plans table provider_private_details column.
func (MongodbProviderPlanSettings) MasterHost ¶
func (mpps MongodbProviderPlanSettings) MasterHost() string
type PostgresStorage ¶
type PostgresStorage struct { Storage // contains filtered or unexported fields }
func InitStorage ¶
func InitStorage(ctx context.Context, o Options) (*PostgresStorage, error)
func (*PostgresStorage) AddInstance ¶
func (b *PostgresStorage) AddInstance(Instance *Instance) error
func (*PostgresStorage) AddTask ¶
func (b *PostgresStorage) AddTask(Id string, action TaskAction, metadata string) (string, error)
func (*PostgresStorage) DeleteInstance ¶
func (b *PostgresStorage) DeleteInstance(Instance *Instance) error
func (*PostgresStorage) GetInstance ¶
func (b *PostgresStorage) GetInstance(Id string) (*Entry, error)
func (*PostgresStorage) GetPlanByID ¶
func (b *PostgresStorage) GetPlanByID(planId string) (*ProviderPlan, error)
func (*PostgresStorage) GetPlans ¶
func (b *PostgresStorage) GetPlans(serviceId string) ([]ProviderPlan, error)
func (*PostgresStorage) GetServices ¶
func (b *PostgresStorage) GetServices() ([]osb.Service, error)
func (*PostgresStorage) GetUnclaimedInstance ¶
func (b *PostgresStorage) GetUnclaimedInstance(PlanId string, InstanceId string) (*Entry, error)
func (*PostgresStorage) IsRestoring ¶
func (b *PostgresStorage) IsRestoring(dbId string) (bool, error)
func (*PostgresStorage) IsUpgrading ¶
func (b *PostgresStorage) IsUpgrading(dbId string) (bool, error)
func (*PostgresStorage) NukeInstance ¶
func (b *PostgresStorage) NukeInstance(Id string) error
func (*PostgresStorage) PopPendingTask ¶
func (b *PostgresStorage) PopPendingTask() (*Task, error)
func (*PostgresStorage) ReturnClaimedInstance ¶
func (b *PostgresStorage) ReturnClaimedInstance(Id string) error
func (*PostgresStorage) StartProvisioningTasks ¶
func (b *PostgresStorage) StartProvisioningTasks() ([]Entry, error)
func (*PostgresStorage) UpdateInstance ¶
func (b *PostgresStorage) UpdateInstance(Instance *Instance, PlanId string) error
func (*PostgresStorage) UpdateTask ¶
func (*PostgresStorage) ValidateInstanceID ¶
func (b *PostgresStorage) ValidateInstanceID(id string) error
func (*PostgresStorage) WarnOnUnfinishedTasks ¶
func (b *PostgresStorage) WarnOnUnfinishedTasks()
type Provider ¶
type Provider interface { GetInstance(string, *ProviderPlan) (*Instance, error) Provision(string, *ProviderPlan, string) (*Instance, error) Deprovision(*Instance, bool) error Modify(*Instance, *ProviderPlan) (*Instance, error) Tag(*Instance, string, string) error Untag(*Instance, string) error PerformPostProvision(*Instance) (*Instance, error) GetUrl(*Instance) map[string]interface{} }
func GetProviderByPlan ¶
func GetProviderByPlan(namePrefix string, plan *ProviderPlan) (Provider, error)
type ProviderPlan ¶
type ResourceSpec ¶
type ResourceSpec struct {
Name string `json:"name"`
}
type ResourceUrlSpec ¶
type RestoreDbTaskMetadata ¶
type RestoreDbTaskMetadata struct {
Backup string `json:"backup"`
}
type Storage ¶
type Storage interface { GetPlans(string) ([]ProviderPlan, error) GetPlanByID(string) (*ProviderPlan, error) GetInstance(string) (*Entry, error) AddInstance(*Instance) error DeleteInstance(*Instance) error UpdateInstance(*Instance, string) error AddTask(string, TaskAction, string) (string, error) GetServices() ([]osb.Service, error) UpdateTask(string, *string, *int64, *string, *string, *time.Time, *time.Time) error PopPendingTask() (*Task, error) GetUnclaimedInstance(string, string) (*Entry, error) ReturnClaimedInstance(string) error StartProvisioningTasks() ([]Entry, error) NukeInstance(string) error WarnOnUnfinishedTasks() IsRestoring(string) (bool, error) IsUpgrading(string) (bool, error) ValidateInstanceID(string) error }
type TaskAction ¶
type TaskAction string
const ( DeleteTask TaskAction = "delete" ResyncFromProviderTask TaskAction = "resync-from-provider" ResyncFromProviderUntilAvailableTask TaskAction = "resync-until-available" NotifyCreateServiceWebhookTask TaskAction = "notify-create-service-webhook" NotifyCreateBindingWebhookTask TaskAction = "notify-create-binding-webhook" ChangeProvidersTask TaskAction = "change-providers" ChangePlansTask TaskAction = "change-plans" RestoreDbTask TaskAction = "restore-database" PerformPostProvisionTask TaskAction = "perform-post-provision" )
type WebhookTaskMetadata ¶
Click to show internal directories.
Click to hide internal directories.