Documentation ¶
Index ¶
- Constants
- Variables
- func AuthMiddleware(baseURL string) mux.MiddlewareFunc
- func NormalizeClusterName(name string) string
- type Broker
- func (b Broker) Bind(ctx context.Context, instanceID string, bindingID string, ...) (spec brokerapi.Binding, err error)
- func (b Broker) Deprovision(ctx context.Context, instanceID string, details brokerapi.DeprovisionDetails, ...) (spec brokerapi.DeprovisionServiceSpec, err error)
- func (b Broker) GetBinding(ctx context.Context, instanceID string, bindingID string) (spec brokerapi.GetBindingSpec, err error)
- func (b Broker) GetInstance(ctx context.Context, instanceID string) (spec brokerapi.GetInstanceDetailsSpec, err error)
- func (b Broker) LastBindingOperation(ctx context.Context, instanceID string, bindingID string, ...) (brokerapi.LastOperation, error)
- func (b Broker) LastOperation(ctx context.Context, instanceID string, details brokerapi.PollDetails) (resp brokerapi.LastOperation, err error)
- func (b Broker) Provision(ctx context.Context, instanceID string, details brokerapi.ProvisionDetails, ...) (spec brokerapi.ProvisionedServiceSpec, err error)
- func (b Broker) Services(ctx context.Context) ([]brokerapi.Service, error)
- func (b Broker) Unbind(ctx context.Context, instanceID string, bindingID string, ...) (spec brokerapi.UnbindSpec, err error)
- func (b Broker) Update(ctx context.Context, instanceID string, details brokerapi.UpdateDetails, ...) (spec brokerapi.UpdateServiceSpec, err error)
- type ConnectionDetails
- type ContextKey
- type Whitelist
Constants ¶
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 ¶
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 ¶
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 ¶
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.
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.