Documentation ¶
Index ¶
- Constants
- func NormalizeClusterName(name string) string
- type Broker
- func (b *Broker) AuthMiddleware() mux.MiddlewareFunc
- func (b Broker) Bind(ctx context.Context, instanceID string, bindingID string, ...) (spec domain.Binding, err error)
- func (b Broker) Deprovision(ctx context.Context, instanceID string, details domain.DeprovisionDetails, ...) (spec domain.DeprovisionServiceSpec, err error)
- func (b Broker) GetBinding(ctx context.Context, instanceID string, bindingID string) (spec domain.GetBindingSpec, err error)
- func (b *Broker) GetDashboardURL(groupID, clusterName string) string
- func (b Broker) GetInstance(ctx context.Context, instanceID string) (spec domain.GetInstanceDetailsSpec, err error)
- func (b Broker) LastBindingOperation(ctx context.Context, instanceID string, bindingID string, ...) (domain.LastOperation, error)
- func (b Broker) LastOperation(ctx context.Context, instanceID string, details domain.PollDetails) (resp domain.LastOperation, err error)
- func (b Broker) Provision(ctx context.Context, instanceID string, details domain.ProvisionDetails, ...) (spec domain.ProvisionedServiceSpec, err error)
- func (b *Broker) Services(ctx context.Context) ([]domain.Service, error)
- func (b Broker) Unbind(ctx context.Context, instanceID string, bindingID string, ...) (spec domain.UnbindSpec, err error)
- func (b Broker) Update(ctx context.Context, instanceID string, details domain.UpdateDetails, ...) (spec domain.UpdateServiceSpec, err error)
- type ConnectionDetails
- type StateStorage
- type Whitelist
Constants ¶
const ( ContextKeyAtlasClient contextKey = "atlas-client" ContextKeyGroupID contextKey = "group-id" )
ContextKeyAtlasClient is the key used to store the Atlas client in the request context.
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 ¶
This section is empty.
Functions ¶
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 domain.ServiceBroker interface making it easy to spin up an API server.
func New ¶
func New( logger *zap.SugaredLogger, credentials *credentials.Credentials, atlasURL string, realmURL string, whitelist Whitelist, userAgent string, ) *Broker
New creates a new Broker with a logger.
func (*Broker) AuthMiddleware ¶
func (b *Broker) AuthMiddleware() mux.MiddlewareFunc
func (Broker) Bind ¶
func (b Broker) Bind(ctx context.Context, instanceID string, bindingID string, details domain.BindDetails, asyncAllowed bool) (spec domain.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 domain.DeprovisionDetails, asyncAllowed bool) (spec domain.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 domain.GetBindingSpec, err error)
GetBinding is currently not supported as specified by the BindingsRetrievable setting in the service catalog.
func (*Broker) GetDashboardURL ¶
func (Broker) GetInstance ¶
func (b Broker) GetInstance(ctx context.Context, instanceID string) (spec domain.GetInstanceDetailsSpec, err error)
GetInstance should fetch the stored instance from state storage
func (Broker) LastBindingOperation ¶
func (b Broker) LastBindingOperation(ctx context.Context, instanceID string, bindingID string, details domain.PollDetails) (domain.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 domain.PollDetails) (resp domain.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 domain.ProvisionDetails, asyncAllowed bool) (spec domain.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 domain.UnbindDetails, asyncAllowed bool) (spec domain.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"` ConnectionString string `json:"connectionString"` Database string `json:"database"` }
ConnectionDetails will be returned when a new binding is created.
type StateStorage ¶
type StateStorage interface { Put(ctx context.Context, key string, value *domain.GetInstanceDetailsSpec) error Get(ctx context.Context, key string) (*domain.GetInstanceDetailsSpec, error) Update(ctx context.Context, key string, value *domain.GetInstanceDetailsSpec) error Delete(ctx context.Context, key string) error }
func NewMongoStorage ¶
func NewMongoStorage(client *mongo.Client) StateStorage