broker

package
v0.9.0-beta Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyAtlasClient contextKey = "atlas-client"
	ContextKeyGroupID     contextKey = "group-id"
)

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

Variables

This section is empty.

Functions

This section is empty.

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,
	cfg Config,
	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 (b *Broker) GetDashboardURL(groupID, clusterName string) string

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

func (b *Broker) Services(ctx context.Context) ([]domain.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 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.

func (Broker) Update

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

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

type Config

type Config struct {
	AtlasURL            string
	RealmURL            string
	Host                string
	Port                uint16
	CertPath            string
	KeyPath             string
	ServiceName         string
	ServiceDisplayName  string
	ServiceDesc         string
	ServiceTags         string
	ImageURL            string
	DocumentationURL    string
	ProviderDisplayName string
	LongDescription     string
}

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 InstanceSize

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

InstanceSize represents an available cluster size.

type Provider

type Provider struct {
	Name          string `json:"@provider"`
	InstanceSizes map[string]InstanceSize
}

Provider represents a single cloud provider to which a cluster can be deployed.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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