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 CanBeDeleted(status string) bool
- func CanBeModified(status string) bool
- 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 IsReady(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 AWSInstanceS3Provider
- func (provider AWSInstanceS3Provider) AddBucketPolicy(BucketName string, ARN string) error
- func (provider AWSInstanceS3Provider) AttachUserPolicy(UserName string, Policy *SimplePolicy) error
- func (provider AWSInstanceS3Provider) CreateBucket(BucketName string, Plan *S3Settings) (*string, error)
- func (provider AWSInstanceS3Provider) CreateRandomName() string
- func (provider AWSInstanceS3Provider) CreateUser(UserName string) (*User, error)
- func (provider AWSInstanceS3Provider) CreateUserPolicy(UserName string, BucketName string, Encrypted bool, KMSKeyID string) (*SimplePolicy, error)
- func (provider AWSInstanceS3Provider) DeleteAccessKey(BucketName string) error
- func (provider AWSInstanceS3Provider) DeleteBucket(BucketName string) error
- func (provider AWSInstanceS3Provider) DeleteUser(UserName string) error
- func (provider AWSInstanceS3Provider) DeleteUserPolicy(policy string) error
- func (provider AWSInstanceS3Provider) Deprovision(Instance *Instance, takeSnapshot bool) error
- func (provider AWSInstanceS3Provider) DetachUserPolicy(BucketName string) error
- func (provider AWSInstanceS3Provider) GetAccessKeyId(BucketName string) (*string, error)
- func (provider AWSInstanceS3Provider) GetInstance(name string, plan *ProviderPlan) (*Instance, error)
- func (provider AWSInstanceS3Provider) GetPolicyARN(BucketName string) (*string, error)
- func (provider AWSInstanceS3Provider) GetTags(BucketName string) ([]*s3.Tag, error)
- func (provider AWSInstanceS3Provider) GetUrl(instance *Instance) map[string]interface{}
- func (provider AWSInstanceS3Provider) Modify(Instance *Instance, plan *ProviderPlan) (*Instance, error)
- func (provider AWSInstanceS3Provider) PerformPostProvision(db *Instance) (*Instance, error)
- func (provider AWSInstanceS3Provider) Provision(Id string, plan *ProviderPlan, Owner string) (*Instance, error)
- func (provider AWSInstanceS3Provider) Tag(Instance *Instance, Name string, Value string) error
- func (provider AWSInstanceS3Provider) Untag(Instance *Instance, Name 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 BucketPolicy
- type BucketPolicyStatement
- 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 Instance
- 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 Principal
- type Provider
- type ProviderPlan
- type Providers
- type ResourceSpec
- type ResourceUrlSpec
- type RestoreDbTaskMetadata
- type S3Settings
- type SimplePolicy
- type Stat
- type Storage
- type Task
- type TaskAction
- type User
- type UserPolicy
- type UserPolicyStatement
- type WebhookTaskMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyParamsToStatement ¶
func CanBeDeleted ¶
available, failed, incompatible-parameters, incompatible-network, restore-failed, recovering
func CanBeModified ¶
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 AWSInstanceS3Provider ¶
type AWSInstanceS3Provider struct { Provider // contains filtered or unexported fields }
func NewAWSInstanceS3Provider ¶
func NewAWSInstanceS3Provider(namePrefix string) (*AWSInstanceS3Provider, error)
func (AWSInstanceS3Provider) AddBucketPolicy ¶
func (provider AWSInstanceS3Provider) AddBucketPolicy(BucketName string, ARN string) error
func (AWSInstanceS3Provider) AttachUserPolicy ¶
func (provider AWSInstanceS3Provider) AttachUserPolicy(UserName string, Policy *SimplePolicy) error
func (AWSInstanceS3Provider) CreateBucket ¶
func (provider AWSInstanceS3Provider) CreateBucket(BucketName string, Plan *S3Settings) (*string, error)
func (AWSInstanceS3Provider) CreateRandomName ¶
func (provider AWSInstanceS3Provider) CreateRandomName() string
func (AWSInstanceS3Provider) CreateUser ¶
func (provider AWSInstanceS3Provider) CreateUser(UserName string) (*User, error)
func (AWSInstanceS3Provider) CreateUserPolicy ¶
func (provider AWSInstanceS3Provider) CreateUserPolicy(UserName string, BucketName string, Encrypted bool, KMSKeyID string) (*SimplePolicy, error)
func (AWSInstanceS3Provider) DeleteAccessKey ¶
func (provider AWSInstanceS3Provider) DeleteAccessKey(BucketName string) error
func (AWSInstanceS3Provider) DeleteBucket ¶
func (provider AWSInstanceS3Provider) DeleteBucket(BucketName string) error
func (AWSInstanceS3Provider) DeleteUser ¶
func (provider AWSInstanceS3Provider) DeleteUser(UserName string) error
func (AWSInstanceS3Provider) DeleteUserPolicy ¶
func (provider AWSInstanceS3Provider) DeleteUserPolicy(policy string) error
func (AWSInstanceS3Provider) Deprovision ¶
func (provider AWSInstanceS3Provider) Deprovision(Instance *Instance, takeSnapshot bool) error
func (AWSInstanceS3Provider) DetachUserPolicy ¶
func (provider AWSInstanceS3Provider) DetachUserPolicy(BucketName string) error
func (AWSInstanceS3Provider) GetAccessKeyId ¶
func (provider AWSInstanceS3Provider) GetAccessKeyId(BucketName string) (*string, error)
func (AWSInstanceS3Provider) GetInstance ¶
func (provider AWSInstanceS3Provider) GetInstance(name string, plan *ProviderPlan) (*Instance, error)
func (AWSInstanceS3Provider) GetPolicyARN ¶
func (provider AWSInstanceS3Provider) GetPolicyARN(BucketName string) (*string, error)
func (AWSInstanceS3Provider) GetTags ¶
func (provider AWSInstanceS3Provider) GetTags(BucketName string) ([]*s3.Tag, error)
func (AWSInstanceS3Provider) GetUrl ¶
func (provider AWSInstanceS3Provider) GetUrl(instance *Instance) map[string]interface{}
func (AWSInstanceS3Provider) Modify ¶
func (provider AWSInstanceS3Provider) Modify(Instance *Instance, plan *ProviderPlan) (*Instance, error)
func (AWSInstanceS3Provider) PerformPostProvision ¶
func (provider AWSInstanceS3Provider) PerformPostProvision(db *Instance) (*Instance, error)
func (AWSInstanceS3Provider) Provision ¶
func (provider AWSInstanceS3Provider) Provision(Id string, plan *ProviderPlan, Owner string) (*Instance, error)
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 BucketPolicy ¶
type BucketPolicy struct { Version string `json:"Version"` ID string `json:"Id"` Statement []BucketPolicyStatement `json:"Statement"` }
type BucketPolicyStatement ¶
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 peice 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 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 S3Settings ¶
type SimplePolicy ¶
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 UserPolicy ¶
type UserPolicy struct { Statement []UserPolicyStatement `json:"Statement"` Version string `json:"Version"` }
type UserPolicyStatement ¶
type WebhookTaskMetadata ¶
Click to show internal directories.
Click to hide internal directories.