broker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationProvision   = "provision"
	OperationDeprovision = "deprovision"
	OperationUpdate      = "update"
	InstanceSizeNameM2   = "M2"
	InstanceSizeNameM5   = "M5"
)

The different async operations that can be performed. These constants are returned during provisioning, deprovisioning, and updates and are subsequently included in async polls from the platform.

Variables

View Source
var ContextKeyAtlasClient = ContextKey("atlas-client")

ContextKeyAtlasClient is the key used to store the Atlas client in the request context.

Functions

func AuthMiddleware

func AuthMiddleware(baseURL string) mux.MiddlewareFunc

AuthMiddleware is used to validate and parse Atlas API credentials passed using basic auth. The credentials parsed into an Atlas client which is attached to the request context. This client can later be retrieved by the broker from the context.

func NormalizeClusterName

func NormalizeClusterName(name string) string

NormalizeClusterName will sanitize a name to make sure it will be accepted by the Atlas API. Atlas has different name length requirements depending on which environment it's running in. A length of 23 is a safe choice and truncates UUIDs nicely.

Types

type Broker

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

Broker is responsible for translating OSB calls to Atlas API calls. Implements the brokerapi.ServiceBroker interface making it easy to spin up an API server.

func NewBroker

func NewBroker(logger *zap.SugaredLogger) *Broker

NewBroker creates a new Broker with a logger.

func NewBrokerWithWhitelist added in v0.1.1

func NewBrokerWithWhitelist(logger *zap.SugaredLogger, whitelist Whitelist) *Broker

NewBrokerWithWhitelist creates a new Broker with a given logger and a whitelist for allowed providers and their plans.

func (Broker) Bind

func (b Broker) Bind(ctx context.Context, instanceID string, bindingID string, details brokerapi.BindDetails, asyncAllowed bool) (spec brokerapi.Binding, err error)

Bind will create a new database user with a username matching the binding ID and a randomly generated password. The user credentials will be returned back.

func (Broker) Deprovision

func (b Broker) Deprovision(ctx context.Context, instanceID string, details brokerapi.DeprovisionDetails, asyncAllowed bool) (spec brokerapi.DeprovisionServiceSpec, err error)

Deprovision will destroy an Atlas cluster asynchronously.

func (Broker) GetBinding

func (b Broker) GetBinding(ctx context.Context, instanceID string, bindingID string) (spec brokerapi.GetBindingSpec, err error)

GetBinding is currently not supported as specified by the BindingsRetrievable setting in the service catalog.

func (Broker) GetInstance

func (b Broker) GetInstance(ctx context.Context, instanceID string) (spec brokerapi.GetInstanceDetailsSpec, err error)

GetInstance is currently not supported as specified by the InstancesRetrievable setting in the service catalog.

func (Broker) LastBindingOperation

func (b Broker) LastBindingOperation(ctx context.Context, instanceID string, bindingID string, details brokerapi.PollDetails) (brokerapi.LastOperation, error)

LastBindingOperation should fetch the status of the last creation/deletion of a database user.

func (Broker) LastOperation

func (b Broker) LastOperation(ctx context.Context, instanceID string, details brokerapi.PollDetails) (resp brokerapi.LastOperation, err error)

LastOperation should fetch the state of the provision/deprovision of a cluster.

func (Broker) Provision

func (b Broker) Provision(ctx context.Context, instanceID string, details brokerapi.ProvisionDetails, asyncAllowed bool) (spec brokerapi.ProvisionedServiceSpec, err error)

Provision will create a new Atlas cluster with the instance ID as its name. The process is always async.

func (Broker) Services

func (b Broker) Services(ctx context.Context) ([]brokerapi.Service, error)

Services generates the service catalog which will be presented to consumers of the API.

func (Broker) Unbind

func (b Broker) Unbind(ctx context.Context, instanceID string, bindingID string, details brokerapi.UnbindDetails, asyncAllowed bool) (spec brokerapi.UnbindSpec, err error)

Unbind will delete the database user for a specific binding. The database user should have the binding ID as its username.

func (Broker) Update

func (b Broker) Update(ctx context.Context, instanceID string, details brokerapi.UpdateDetails, asyncAllowed bool) (spec brokerapi.UpdateServiceSpec, err error)

Update will change the configuration of an existing Atlas cluster asynchronously.

type ConnectionDetails

type ConnectionDetails struct {
	Username string `json:"username"`
	Password string `json:"password"`
	URI      string `json:"uri"`
}

ConnectionDetails will be returned when a new binding is created.

type ContextKey

type ContextKey string

ContextKey represents the key for a value saved in a context. Linter requires keys to have their own type.

type Whitelist added in v0.1.1

type Whitelist map[string][]string

func ReadWhitelistFile added in v0.1.1

func ReadWhitelistFile(path string) (Whitelist, error)

Jump to

Keyboard shortcuts

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