broker

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 37 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(o *Options)

func ApplyParamsToStatement

func ApplyParamsToStatement(statement string, args ...string) string

func CanBeDeleted

func CanBeDeleted(status string) bool

func CanBeModified

func CanBeModified(status string) bool

func CanGetBindings

func CanGetBindings(status string) bool

func ConflictErrorWithMessage

func ConflictErrorWithMessage(description string) error

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 DeleteMysqlReadOnlyRole

func DeleteMysqlReadOnlyRole(dbInstance *DbInstance, databaseUri string, role string) error

func DeletePostgresReadOnlyRole

func DeletePostgresReadOnlyRole(dbInstance *DbInstance, databaseUri string, role string) error

func FinishedTask

func FinishedTask(storage Storage, taskId string, retries int64, result string, status string)

func HttpWrite

func HttpWrite(w http.ResponseWriter, status int, obj interface{})

func InProgress

func InProgress(status string) bool

func InternalServerError

func InternalServerError() error

func IsAvailable

func IsAvailable(status string) bool

func IsReady

func IsReady(status string) bool

func NotFound

func NotFound() error

func RandomString

func RandomString(n int) string

func RestoreBackup

func RestoreBackup(storage Storage, dbInstance *DbInstance, namePrefix string, backup string) error

func RunBackgroundTasks

func RunBackgroundTasks(ctx context.Context, o Options) error

func RunPreprovisionTasks

func RunPreprovisionTasks(ctx context.Context, o Options, namePrefix string, storage Storage, wait int64)

func RunWorkerTasks

func RunWorkerTasks(ctx context.Context, o Options, namePrefix string, storage Storage) error

func TickTocPreprovisionTasks

func TickTocPreprovisionTasks(ctx context.Context, o Options, namePrefix string, storage Storage)

func UnprocessableEntity

func UnprocessableEntity() error

func UnprocessableEntityWithMessage

func UnprocessableEntityWithMessage(err string, description string) error

func UpdateTaskStatus

func UpdateTaskStatus(storage Storage, taskId string, retries int64, result string, status string)

func UpgradeAcrossProviders

func UpgradeAcrossProviders(storage Storage, fromDb *DbInstance, toPlanId string, namePrefix string) (string, error)

func UpgradeWithinProviders

func UpgradeWithinProviders(storage Storage, fromDb *DbInstance, toPlanId string, namePrefix string) (string, error)

Types

type AWSClusteredProvider

type AWSClusteredProvider struct {
	Provider
	// contains filtered or unexported fields
}

func NewAWSClusteredProvider

func NewAWSClusteredProvider(namePrefix string) (*AWSClusteredProvider, error)

func (AWSClusteredProvider) CreateBackup

func (provider AWSClusteredProvider) CreateBackup(dbInstance *DbInstance) (DatabaseBackupSpec, error)

func (AWSClusteredProvider) CreateReadOnlyUser

func (provider AWSClusteredProvider) CreateReadOnlyUser(dbInstance *DbInstance) (DatabaseUrlSpec, error)

func (AWSClusteredProvider) CreateReadReplica

func (provider AWSClusteredProvider) CreateReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (AWSClusteredProvider) DeleteReadOnlyUser

func (provider AWSClusteredProvider) DeleteReadOnlyUser(dbInstance *DbInstance, role string) error

func (AWSClusteredProvider) DeleteReadReplica

func (provider AWSClusteredProvider) DeleteReadReplica(dbInstance *DbInstance) error

func (AWSClusteredProvider) Deprovision

func (provider AWSClusteredProvider) Deprovision(dbInstance *DbInstance, takeSnapshot bool) error

func (AWSClusteredProvider) GetBackup

func (provider AWSClusteredProvider) GetBackup(dbInstance *DbInstance, Id string) (DatabaseBackupSpec, error)

func (AWSClusteredProvider) GetInstance

func (provider AWSClusteredProvider) GetInstance(name string, plan *ProviderPlan) (*DbInstance, error)

func (AWSClusteredProvider) GetLogs

func (provider AWSClusteredProvider) GetLogs(dbInstance *DbInstance, path string) (string, error)

func (AWSClusteredProvider) GetReadReplica

func (provider AWSClusteredProvider) GetReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (AWSClusteredProvider) ListBackups

func (provider AWSClusteredProvider) ListBackups(dbInstance *DbInstance) ([]DatabaseBackupSpec, error)

func (AWSClusteredProvider) ListLogs

func (provider AWSClusteredProvider) ListLogs(dbInstance *DbInstance) ([]DatabaseLogs, error)

func (AWSClusteredProvider) Modify

func (provider AWSClusteredProvider) Modify(dbInstance *DbInstance, plan *ProviderPlan) (*DbInstance, error)

func (AWSClusteredProvider) PerformPostProvision

func (provider AWSClusteredProvider) PerformPostProvision(db *DbInstance) (*DbInstance, error)

func (AWSClusteredProvider) Provision

func (provider AWSClusteredProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*DbInstance, error)

func (AWSClusteredProvider) Restart

func (provider AWSClusteredProvider) Restart(dbInstance *DbInstance) error

func (AWSClusteredProvider) RestoreBackup

func (provider AWSClusteredProvider) RestoreBackup(dbInstance *DbInstance, Id string) error

func (AWSClusteredProvider) RotatePasswordReadOnlyUser

func (provider AWSClusteredProvider) RotatePasswordReadOnlyUser(dbInstance *DbInstance, role string) (DatabaseUrlSpec, error)

func (AWSClusteredProvider) Tag

func (provider AWSClusteredProvider) Tag(dbInstance *DbInstance, Name string, Value string) error

func (AWSClusteredProvider) Untag

func (provider AWSClusteredProvider) Untag(dbInstance *DbInstance, Name string) error

func (AWSClusteredProvider) UpgradeVersion

func (provider AWSClusteredProvider) UpgradeVersion(dbInstance *DbInstance, proposed string) (*DbInstance, error)

type AWSClusteredProviderPrivatePlanSettings

type AWSClusteredProviderPrivatePlanSettings struct {
	Instance rds.CreateDBInstanceInput `json:"Instance"`
	Cluster  rds.CreateDBClusterInput  `json:"Cluster"`
}

type AWSInstanceProvider

type AWSInstanceProvider struct {
	Provider
	// contains filtered or unexported fields
}

func NewAWSInstanceProvider

func NewAWSInstanceProvider(namePrefix string) (*AWSInstanceProvider, error)

func (AWSInstanceProvider) CreateBackup

func (provider AWSInstanceProvider) CreateBackup(dbInstance *DbInstance) (DatabaseBackupSpec, error)

func (AWSInstanceProvider) CreateReadOnlyUser

func (provider AWSInstanceProvider) CreateReadOnlyUser(dbInstance *DbInstance) (DatabaseUrlSpec, error)

func (AWSInstanceProvider) CreateReadReplica

func (provider AWSInstanceProvider) CreateReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (AWSInstanceProvider) DeleteReadOnlyUser

func (provider AWSInstanceProvider) DeleteReadOnlyUser(dbInstance *DbInstance, role string) error

func (AWSInstanceProvider) DeleteReadReplica

func (provider AWSInstanceProvider) DeleteReadReplica(dbInstance *DbInstance) error

func (AWSInstanceProvider) Deprovision

func (provider AWSInstanceProvider) Deprovision(dbInstance *DbInstance, takeSnapshot bool) error

func (AWSInstanceProvider) GetBackup

func (provider AWSInstanceProvider) GetBackup(dbInstance *DbInstance, Id string) (DatabaseBackupSpec, error)

func (AWSInstanceProvider) GetInstance

func (provider AWSInstanceProvider) GetInstance(name string, plan *ProviderPlan) (*DbInstance, error)

func (AWSInstanceProvider) GetLogs

func (provider AWSInstanceProvider) GetLogs(dbInstance *DbInstance, path string) (string, error)

func (AWSInstanceProvider) GetReadReplica

func (provider AWSInstanceProvider) GetReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (AWSInstanceProvider) ListBackups

func (provider AWSInstanceProvider) ListBackups(dbInstance *DbInstance) ([]DatabaseBackupSpec, error)

func (AWSInstanceProvider) ListLogs

func (provider AWSInstanceProvider) ListLogs(dbInstance *DbInstance) ([]DatabaseLogs, error)

func (AWSInstanceProvider) Modify

func (provider AWSInstanceProvider) Modify(dbInstance *DbInstance, plan *ProviderPlan) (*DbInstance, error)

func (AWSInstanceProvider) ModifyWithSettings

func (provider AWSInstanceProvider) ModifyWithSettings(dbInstance *DbInstance, plan *ProviderPlan, settings *rds.CreateDBInstanceInput) (*DbInstance, error)

func (AWSInstanceProvider) PerformPostProvision

func (provider AWSInstanceProvider) PerformPostProvision(db *DbInstance) (*DbInstance, error)

func (AWSInstanceProvider) Provision

func (provider AWSInstanceProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*DbInstance, error)

func (AWSInstanceProvider) ProvisionWithSettings

func (provider AWSInstanceProvider) ProvisionWithSettings(Id string, plan *ProviderPlan, settings *rds.CreateDBInstanceInput) (*DbInstance, error)

func (AWSInstanceProvider) Restart

func (provider AWSInstanceProvider) Restart(dbInstance *DbInstance) error

func (AWSInstanceProvider) RestoreBackup

func (provider AWSInstanceProvider) RestoreBackup(dbInstance *DbInstance, Id string) error

func (AWSInstanceProvider) RotatePasswordReadOnlyUser

func (provider AWSInstanceProvider) RotatePasswordReadOnlyUser(dbInstance *DbInstance, role string) (DatabaseUrlSpec, error)

func (AWSInstanceProvider) Tag

func (provider AWSInstanceProvider) Tag(dbInstance *DbInstance, Name string, Value string) error

func (AWSInstanceProvider) Untag

func (provider AWSInstanceProvider) Untag(dbInstance *DbInstance, Name string) error

func (AWSInstanceProvider) UpgradeVersion

func (provider AWSInstanceProvider) UpgradeVersion(dbInstance *DbInstance, proposed string, settings *rds.CreateDBInstanceInput) (*DbInstance, error)

type Action

type Action struct {
	// contains filtered or unexported fields
}

type ActionBase

type ActionBase struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*ActionBase) ActionSchemaHandler

func (b *ActionBase) ActionSchemaHandler(w http.ResponseWriter, r *http.Request)

func (*ActionBase) AddActions

func (b *ActionBase) AddActions(name string, path string, method string, handler func(string, map[string]string, *broker.RequestContext) (interface{}, error)) error

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) ActionCreateBackup

func (b *BusinessLogic) ActionCreateBackup(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionCreateReplica

func (b *BusinessLogic) ActionCreateReplica(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionCreateRole

func (b *BusinessLogic) ActionCreateRole(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionDeleteReplica

func (b *BusinessLogic) ActionDeleteReplica(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionDeleteRole

func (b *BusinessLogic) ActionDeleteRole(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionGetBackup

func (b *BusinessLogic) ActionGetBackup(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionGetLogs

func (b *BusinessLogic) ActionGetLogs(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionGetReplica

func (b *BusinessLogic) ActionGetReplica(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionGetRole

func (b *BusinessLogic) ActionGetRole(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionListBackups

func (b *BusinessLogic) ActionListBackups(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionListLogs

func (b *BusinessLogic) ActionListLogs(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionListRoles

func (b *BusinessLogic) ActionListRoles(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionRestart

func (b *BusinessLogic) ActionRestart(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionRestoreBackup

func (b *BusinessLogic) ActionRestoreBackup(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionRotateRole

func (b *BusinessLogic) ActionRotateRole(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) ActionViewLogs

func (b *BusinessLogic) ActionViewLogs(InstanceID string, vars map[string]string, context *broker.RequestContext) (interface{}, error)

func (*BusinessLogic) Bind

func (*BusinessLogic) Deprovision

func (*BusinessLogic) GetBinding

func (b *BusinessLogic) GetBinding(request *osb.GetBindingRequest, context *broker.RequestContext) (*osb.GetBindingResponse, error)

func (*BusinessLogic) GetCatalog

func (*BusinessLogic) GetInstanceById

func (b *BusinessLogic) GetInstanceById(Id string) (*DbInstance, error)

func (*BusinessLogic) GetUnclaimedInstance

func (b *BusinessLogic) GetUnclaimedInstance(PlanId string, InstanceId string) (*DbInstance, error)

func (*BusinessLogic) LastOperation

func (*BusinessLogic) Provision

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 (*BusinessLogic) Update

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 DatabaseBackupSpec

type DatabaseBackupSpec struct {
	Database DatabaseSpec `json:"database"`
	Id       *string      `json:"id"`
	Progress *int64       `json:"progress"`
	Status   *string      `json:"status"`
	Created  string       `json:"created_at"`
}

type DatabaseLogs

type DatabaseLogs struct {
	Size    *int64  `json:"size"`
	Name    *string `json:"name"`
	Updated string  `json:"updated_at"`
}

type DatabaseSpec

type DatabaseSpec struct {
	Name string `json:"name"`
}

type DatabaseUrlSpec

type DatabaseUrlSpec struct {
	Username string
	Password string
	Endpoint string
	Plan     string
}

func CreateMysqlReadOnlyRole

func CreateMysqlReadOnlyRole(dbInstance *DbInstance, databaseUri string) (DatabaseUrlSpec, error)

Technically the create role functions are used by any provider that implements mysql but we'll place them here, but be aware they're not specific to this provider.

func CreatePostgresReadOnlyRole

func CreatePostgresReadOnlyRole(dbInstance *DbInstance, databaseUri string) (DatabaseUrlSpec, error)

Technically the create role functions are used by any provider that implements postgres but we'll place them here, but be aware they're not specific to this provider.

func RotateMysqlReadOnlyRole

func RotateMysqlReadOnlyRole(dbInstance *DbInstance, databaseUri string, role string) (DatabaseUrlSpec, error)

func RotatePostgresReadOnlyRole

func RotatePostgresReadOnlyRole(dbInstance *DbInstance, databaseUri string, role string) (DatabaseUrlSpec, error)

type DbEntry

type DbEntry struct {
	Id       string
	Name     string
	PlanId   string
	Claimed  bool
	Tasks    int
	Status   string
	Username string
	Password string
	Endpoint string
}

type DbInstance

type DbInstance 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

func GetInstanceById(namePrefix string, storage Storage, Id string) (*DbInstance, error)

func GetReplicaById

func GetReplicaById(namePrefix string, storage Storage, Id string) (*DbInstance, error)

func (*DbInstance) Match

func (i *DbInstance) Match(other *DbInstance) bool

type GCloudInstanceProvider

type GCloudInstanceProvider struct {
	Provider
	// contains filtered or unexported fields
}

func NewGCloudInstanceProvider

func NewGCloudInstanceProvider(namePrefix string) (*GCloudInstanceProvider, error)

func (GCloudInstanceProvider) CreateBackup

func (provider GCloudInstanceProvider) CreateBackup(dbInstance *DbInstance) (DatabaseBackupSpec, error)

func (GCloudInstanceProvider) CreateReadOnlyUser

func (provider GCloudInstanceProvider) CreateReadOnlyUser(dbInstance *DbInstance) (DatabaseUrlSpec, error)

func (GCloudInstanceProvider) CreateReadReplica

func (provider GCloudInstanceProvider) CreateReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (GCloudInstanceProvider) DeleteReadOnlyUser

func (provider GCloudInstanceProvider) DeleteReadOnlyUser(dbInstance *DbInstance, role string) error

func (GCloudInstanceProvider) DeleteReadReplica

func (provider GCloudInstanceProvider) DeleteReadReplica(dbInstance *DbInstance) error

func (GCloudInstanceProvider) Deprovision

func (provider GCloudInstanceProvider) Deprovision(dbInstance *DbInstance, takeSnapshot bool) error

func (GCloudInstanceProvider) GetBackup

func (provider GCloudInstanceProvider) GetBackup(dbInstance *DbInstance, Id string) (DatabaseBackupSpec, error)

func (GCloudInstanceProvider) GetInstance

func (provider GCloudInstanceProvider) GetInstance(name string, plan *ProviderPlan) (*DbInstance, error)

func (GCloudInstanceProvider) GetLogs

func (provider GCloudInstanceProvider) GetLogs(dbInstance *DbInstance, path string) (string, error)

func (GCloudInstanceProvider) GetReadReplica

func (provider GCloudInstanceProvider) GetReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (GCloudInstanceProvider) ListBackups

func (provider GCloudInstanceProvider) ListBackups(dbInstance *DbInstance) ([]DatabaseBackupSpec, error)

func (GCloudInstanceProvider) ListLogs

func (provider GCloudInstanceProvider) ListLogs(dbInstance *DbInstance) ([]DatabaseLogs, error)

func (GCloudInstanceProvider) Modify

func (provider GCloudInstanceProvider) Modify(dbInstance *DbInstance, plan *ProviderPlan) (*DbInstance, error)

func (GCloudInstanceProvider) ModifyWithSettings

func (provider GCloudInstanceProvider) ModifyWithSettings(dbInstance *DbInstance, plan *ProviderPlan, settings *sqladmin.Settings) (*DbInstance, error)

func (GCloudInstanceProvider) PerformPostProvision

func (provider GCloudInstanceProvider) PerformPostProvision(db *DbInstance) (*DbInstance, error)

func (GCloudInstanceProvider) Provision

func (provider GCloudInstanceProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*DbInstance, error)

func (GCloudInstanceProvider) ProvisionWithSettings

func (provider GCloudInstanceProvider) ProvisionWithSettings(Id string, plan *ProviderPlan, settings *sqladmin.DatabaseInstance, user *sqladmin.User) (*DbInstance, error)

func (GCloudInstanceProvider) Restart

func (provider GCloudInstanceProvider) Restart(dbInstance *DbInstance) error

func (GCloudInstanceProvider) RestoreBackup

func (provider GCloudInstanceProvider) RestoreBackup(dbInstance *DbInstance, Id string) error

func (GCloudInstanceProvider) RotatePasswordReadOnlyUser

func (provider GCloudInstanceProvider) RotatePasswordReadOnlyUser(dbInstance *DbInstance, role string) (DatabaseUrlSpec, error)

func (GCloudInstanceProvider) Tag

func (provider GCloudInstanceProvider) Tag(dbInstance *DbInstance, Name string, Value string) error

func (GCloudInstanceProvider) Untag

func (provider GCloudInstanceProvider) Untag(dbInstance *DbInstance, Name string) error

type MysqlSharedProvider

type MysqlSharedProvider struct {
	Provider
	// contains filtered or unexported fields
}

func NewMysqlSharedProvider

func NewMysqlSharedProvider(namePrefix string) (MysqlSharedProvider, error)

func (MysqlSharedProvider) CreateBackup

func (provider MysqlSharedProvider) CreateBackup(dbInstance *DbInstance) (DatabaseBackupSpec, error)

func (MysqlSharedProvider) CreateReadOnlyUser

func (provider MysqlSharedProvider) CreateReadOnlyUser(dbInstance *DbInstance) (DatabaseUrlSpec, error)

func (MysqlSharedProvider) CreateReadReplica

func (provider MysqlSharedProvider) CreateReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (MysqlSharedProvider) DeleteReadOnlyUser

func (provider MysqlSharedProvider) DeleteReadOnlyUser(dbInstance *DbInstance, role string) error

func (MysqlSharedProvider) DeleteReadReplica

func (provider MysqlSharedProvider) DeleteReadReplica(dbInstance *DbInstance) error

func (MysqlSharedProvider) Deprovision

func (provider MysqlSharedProvider) Deprovision(dbInstance *DbInstance, takeSnapshot bool) error

TODO: take snapshot somehow.

func (MysqlSharedProvider) GetBackup

func (provider MysqlSharedProvider) GetBackup(dbInstance *DbInstance, Id string) (DatabaseBackupSpec, error)

func (MysqlSharedProvider) GetInstance

func (provider MysqlSharedProvider) GetInstance(name string, plan *ProviderPlan) (*DbInstance, error)

func (MysqlSharedProvider) GetLogs

func (provider MysqlSharedProvider) GetLogs(dbInstance *DbInstance, path string) (string, error)

func (MysqlSharedProvider) GetReadReplica

func (provider MysqlSharedProvider) GetReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (MysqlSharedProvider) ListBackups

func (provider MysqlSharedProvider) ListBackups(dbInstance *DbInstance) ([]DatabaseBackupSpec, error)

func (MysqlSharedProvider) ListLogs

func (provider MysqlSharedProvider) ListLogs(dbInstance *DbInstance) ([]DatabaseLogs, error)

func (MysqlSharedProvider) Modify

func (provider MysqlSharedProvider) Modify(dbInstance *DbInstance, plan *ProviderPlan) (*DbInstance, error)

func (MysqlSharedProvider) PerformPostProvision

func (provider MysqlSharedProvider) PerformPostProvision(db *DbInstance) (*DbInstance, error)

func (MysqlSharedProvider) Provision

func (provider MysqlSharedProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*DbInstance, error)

func (MysqlSharedProvider) Restart

func (provider MysqlSharedProvider) Restart(dbInstance *DbInstance) error

func (MysqlSharedProvider) RestoreBackup

func (provider MysqlSharedProvider) RestoreBackup(dbInstance *DbInstance, Id string) error

func (MysqlSharedProvider) RotatePasswordReadOnlyUser

func (provider MysqlSharedProvider) RotatePasswordReadOnlyUser(dbInstance *DbInstance, role string) (DatabaseUrlSpec, error)

func (MysqlSharedProvider) Tag

func (provider MysqlSharedProvider) Tag(dbInstance *DbInstance, Name string, Value string) error

func (MysqlSharedProvider) Untag

func (provider MysqlSharedProvider) Untag(dbInstance *DbInstance, Name string) error

type MysqlSharedProviderPrivatePlanSettings

type MysqlSharedProviderPrivatePlanSettings struct {
	MasterUri     string `json:"master_uri"`
	Engine        string `json:"engine"`
	EngineVersion string `json:"engine_version"`
	SchemeType    string `json:"scheme_type"` /* Can be 'dsn', 'uri' */
}

provider=shared-mysql in database These values come out of the plans table provider_private_details column.

func (MysqlSharedProviderPrivatePlanSettings) GetMasterUriAsDsn

func (psppps MysqlSharedProviderPrivatePlanSettings) GetMasterUriAsDsn() string

func (MysqlSharedProviderPrivatePlanSettings) GetMasterUriWithDb

func (psppps MysqlSharedProviderPrivatePlanSettings) GetMasterUriWithDb(dbName string) string

func (MysqlSharedProviderPrivatePlanSettings) GetMasterUriWithDbAsDsn

func (psppps MysqlSharedProviderPrivatePlanSettings) GetMasterUriWithDbAsDsn(dbName string) string

func (MysqlSharedProviderPrivatePlanSettings) MasterHost

func (psppps MysqlSharedProviderPrivatePlanSettings) MasterHost() string

type Options

type Options struct {
	DatabaseUrl string
	NamePrefix  string
}

type PostgresSharedProvider

type PostgresSharedProvider struct {
	Provider
	// contains filtered or unexported fields
}

func NewPostgresSharedProvider

func NewPostgresSharedProvider(namePrefix string) (PostgresSharedProvider, error)

func (PostgresSharedProvider) CreateBackup

func (provider PostgresSharedProvider) CreateBackup(dbInstance *DbInstance) (DatabaseBackupSpec, error)

func (PostgresSharedProvider) CreateReadOnlyUser

func (provider PostgresSharedProvider) CreateReadOnlyUser(dbInstance *DbInstance) (DatabaseUrlSpec, error)

func (PostgresSharedProvider) CreateReadReplica

func (provider PostgresSharedProvider) CreateReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (PostgresSharedProvider) DeleteReadOnlyUser

func (provider PostgresSharedProvider) DeleteReadOnlyUser(dbInstance *DbInstance, role string) error

func (PostgresSharedProvider) DeleteReadReplica

func (provider PostgresSharedProvider) DeleteReadReplica(dbInstance *DbInstance) error

func (PostgresSharedProvider) Deprovision

func (provider PostgresSharedProvider) Deprovision(dbInstance *DbInstance, takeSnapshot bool) error

TODO: take snapshot somehow.

func (PostgresSharedProvider) GetBackup

func (provider PostgresSharedProvider) GetBackup(dbInstance *DbInstance, Id string) (DatabaseBackupSpec, error)

func (PostgresSharedProvider) GetInstance

func (provider PostgresSharedProvider) GetInstance(name string, plan *ProviderPlan) (*DbInstance, error)

func (PostgresSharedProvider) GetLogs

func (provider PostgresSharedProvider) GetLogs(dbInstance *DbInstance, path string) (string, error)

func (PostgresSharedProvider) GetReadReplica

func (provider PostgresSharedProvider) GetReadReplica(dbInstance *DbInstance) (*DbInstance, error)

func (PostgresSharedProvider) ListBackups

func (provider PostgresSharedProvider) ListBackups(dbInstance *DbInstance) ([]DatabaseBackupSpec, error)

func (PostgresSharedProvider) ListLogs

func (provider PostgresSharedProvider) ListLogs(dbInstance *DbInstance) ([]DatabaseLogs, error)

func (PostgresSharedProvider) Modify

func (provider PostgresSharedProvider) Modify(dbInstance *DbInstance, plan *ProviderPlan) (*DbInstance, error)

func (PostgresSharedProvider) PerformPostProvision

func (provider PostgresSharedProvider) PerformPostProvision(db *DbInstance) (*DbInstance, error)

func (PostgresSharedProvider) Provision

func (provider PostgresSharedProvider) Provision(Id string, plan *ProviderPlan, Owner string) (*DbInstance, error)

func (PostgresSharedProvider) Restart

func (provider PostgresSharedProvider) Restart(dbInstance *DbInstance) error

func (PostgresSharedProvider) RestoreBackup

func (provider PostgresSharedProvider) RestoreBackup(dbInstance *DbInstance, Id string) error

func (PostgresSharedProvider) RotatePasswordReadOnlyUser

func (provider PostgresSharedProvider) RotatePasswordReadOnlyUser(dbInstance *DbInstance, role string) (DatabaseUrlSpec, error)

func (PostgresSharedProvider) Tag

func (provider PostgresSharedProvider) Tag(dbInstance *DbInstance, Name string, Value string) error

func (PostgresSharedProvider) Untag

func (provider PostgresSharedProvider) Untag(dbInstance *DbInstance, Name string) error

type PostgresSharedProviderPrivatePlanSettings

type PostgresSharedProviderPrivatePlanSettings struct {
	MasterUri     string `json:"master_uri"`
	Engine        string `json:"engine"`
	EngineVersion string `json:"engine_version"`
}

provider=shared-postgres in database These values come out of the plans table provider_private_details column.

func (PostgresSharedProviderPrivatePlanSettings) GetMasterUriWithDb

func (psppps PostgresSharedProviderPrivatePlanSettings) GetMasterUriWithDb(dbName string) string

func (PostgresSharedProviderPrivatePlanSettings) MasterHost

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(dbInstance *DbInstance) error

func (*PostgresStorage) AddReplica

func (b *PostgresStorage) AddReplica(dbInstance *DbInstance) error

func (*PostgresStorage) AddRole

func (b *PostgresStorage) AddRole(dbInstance *DbInstance, username string, password string) (DatabaseUrlSpec, error)

func (*PostgresStorage) AddTask

func (b *PostgresStorage) AddTask(Id string, action TaskAction, metadata string) (string, error)

func (*PostgresStorage) DeleteInstance

func (b *PostgresStorage) DeleteInstance(dbInstance *DbInstance) error

func (*PostgresStorage) DeleteReplica

func (b *PostgresStorage) DeleteReplica(dbInstance *DbInstance) error

func (*PostgresStorage) DeleteRole

func (b *PostgresStorage) DeleteRole(dbInstance *DbInstance, username string) error

func (*PostgresStorage) GetInstance

func (b *PostgresStorage) GetInstance(Id string) (*DbEntry, 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) GetReplicas

func (b *PostgresStorage) GetReplicas(dbInstance *DbInstance) (DatabaseUrlSpec, error)

func (*PostgresStorage) GetRole

func (b *PostgresStorage) GetRole(dbInstance *DbInstance, r string) (DatabaseUrlSpec, error)

func (*PostgresStorage) GetServices

func (b *PostgresStorage) GetServices() ([]osb.Service, error)

func (*PostgresStorage) GetUnclaimedInstance

func (b *PostgresStorage) GetUnclaimedInstance(PlanId string, InstanceId string) (*DbEntry, error)

func (*PostgresStorage) HasReplicas

func (b *PostgresStorage) HasReplicas(dbInstance *DbInstance) (int64, error)

func (*PostgresStorage) HasRole

func (b *PostgresStorage) HasRole(dbInstance *DbInstance, username string) (int64, 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) ListRoles

func (b *PostgresStorage) ListRoles(dbInstance *DbInstance) ([]DatabaseUrlSpec, 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() ([]DbEntry, error)

func (*PostgresStorage) UpdateInstance

func (b *PostgresStorage) UpdateInstance(dbInstance *DbInstance, PlanId string) error

func (*PostgresStorage) UpdateReplica

func (b *PostgresStorage) UpdateReplica(dbInstance *DbInstance) error

func (*PostgresStorage) UpdateRole

func (b *PostgresStorage) UpdateRole(dbInstance *DbInstance, username string, password string) (DatabaseUrlSpec, error)

func (*PostgresStorage) UpdateTask

func (b *PostgresStorage) UpdateTask(Id string, status *string, retries *int64, metadata *string, result *string, started *time.Time, finsihed *time.Time) error

func (*PostgresStorage) ValidateInstanceID

func (b *PostgresStorage) ValidateInstanceID(id string) error

ValidateInstanceID(string)

This is used to ensure that the instance ID being requested to be created is a valid
instance id that we can use, it can either check to ensure its not already an existing
instance or that the id doesn't contain invalid characters.

func (*PostgresStorage) WarnOnUnfinishedTasks

func (b *PostgresStorage) WarnOnUnfinishedTasks()

type Provider

type Provider interface {
	GetInstance(string, *ProviderPlan) (*DbInstance, error)
	Provision(string, *ProviderPlan, string) (*DbInstance, error)
	Deprovision(*DbInstance, bool) error
	Modify(*DbInstance, *ProviderPlan) (*DbInstance, error)
	Tag(*DbInstance, string, string) error
	Untag(*DbInstance, string) error
	GetBackup(*DbInstance, string) (DatabaseBackupSpec, error)
	ListBackups(*DbInstance) ([]DatabaseBackupSpec, error)
	CreateBackup(*DbInstance) (DatabaseBackupSpec, error)
	RestoreBackup(*DbInstance, string) error
	Restart(*DbInstance) error
	ListLogs(*DbInstance) ([]DatabaseLogs, error)
	GetLogs(*DbInstance, string) (string, error)
	CreateReadOnlyUser(*DbInstance) (DatabaseUrlSpec, error)
	DeleteReadOnlyUser(*DbInstance, string) error
	RotatePasswordReadOnlyUser(*DbInstance, string) (DatabaseUrlSpec, error)
	CreateReadReplica(*DbInstance) (*DbInstance, error)
	GetReadReplica(*DbInstance) (*DbInstance, error)
	DeleteReadReplica(*DbInstance) error
	PerformPostProvision(*DbInstance) (*DbInstance, error)
}

func GetProviderByPlan

func GetProviderByPlan(namePrefix string, plan *ProviderPlan) (Provider, error)

type ProviderPlan

type ProviderPlan struct {
	Provider Providers `json:"provider"`

	ID     string `json:"id"`
	Scheme string `json:"scheme"`
	// contains filtered or unexported fields
}

type Providers

type Providers string
const (
	AWSInstance    Providers = "aws-instance"
	AWSCluster     Providers = "aws-cluster"
	GCloudInstance Providers = "gcloud-instance"
	PostgresShared Providers = "postgres-shared"
	MysqlShared    Providers = "mysql-shared"
	Unknown        Providers = "unknown"
)

func GetProvidersFromString

func GetProvidersFromString(str string) Providers

type RestoreDbTaskMetadata

type RestoreDbTaskMetadata struct {
	Backup string `json:"backup"`
}

type Storage

type Storage interface {
	GetPlans(string) ([]ProviderPlan, error)
	GetPlanByID(string) (*ProviderPlan, error)
	GetReplicas(*DbInstance) (DatabaseUrlSpec, error)
	HasReplicas(*DbInstance) (int64, error)
	AddReplica(*DbInstance) error
	UpdateReplica(*DbInstance) error
	DeleteReplica(*DbInstance) error
	ListRoles(*DbInstance) ([]DatabaseUrlSpec, error)
	GetRole(*DbInstance, string) (DatabaseUrlSpec, error)
	AddRole(*DbInstance, string, string) (DatabaseUrlSpec, error)
	UpdateRole(*DbInstance, string, string) (DatabaseUrlSpec, error)
	HasRole(*DbInstance, string) (int64, error)
	DeleteRole(*DbInstance, string) error
	GetInstance(string) (*DbEntry, error)
	AddInstance(*DbInstance) error
	DeleteInstance(*DbInstance) error
	UpdateInstance(*DbInstance, 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) (*DbEntry, error)
	ReturnClaimedInstance(string) error
	StartProvisioningTasks() ([]DbEntry, error)
	NukeInstance(string) error
	WarnOnUnfinishedTasks()
	IsRestoring(string) (bool, error)
	IsUpgrading(string) (bool, error)
	ValidateInstanceID(id string) error
}

func InitFromOptions

func InitFromOptions(ctx context.Context, o Options) (Storage, string, error)

type Task

type Task struct {
	Id         string
	Action     TaskAction
	DatabaseId string
	Status     string
	Retries    int64
	Metadata   string
	Result     string
	Started    *time.Time
	Finished   *time.Time
}

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"
	ResyncReplicasFromProviderTask       TaskAction = "resync-replicas-from-provider-task"
)

type WebhookTaskMetadata

type WebhookTaskMetadata struct {
	Url    string `json:"url"`
	Secret string `json:"secret"`
}

Jump to

Keyboard shortcuts

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