service

package
v0.9.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: MIT Imports: 6 Imported by: 92

Documentation

Index

Constants

View Source
const (
	// InstanceStateProvisioningDeferred represents the state where service
	// instance provisioning has been requested and deferred pending the
	// completion of some other action
	InstanceStateProvisioningDeferred = "PROVISIONING_DEFERRED"
	// InstanceStateProvisioning represents the state where service instance
	// provisioning is in progress
	InstanceStateProvisioning = "PROVISIONING"
	// InstanceStateProvisioned represents the state where service instance
	// provisioning has completed successfully
	InstanceStateProvisioned = "PROVISIONED"
	// InstanceStateProvisioningFailed represents the state where service instance
	// provisioning has failed
	InstanceStateProvisioningFailed = "PROVISIONING_FAILED"
	// InstanceStateUpdating represents the state where service instance
	// updating is in progress
	InstanceStateUpdating = "UPDATING"
	// InstanceStateUpdated represents the state where service instance
	// updating has completed successfully
	// It redirects to InstanceStateProvisioned because it means the same thing
	// to any other operations besides updating
	InstanceStateUpdated = InstanceStateProvisioned
	// InstanceStateUpdatingFailed represents the state where service instance
	// updating has failed
	InstanceStateUpdatingFailed = "UPDATING_FAILED"
	// InstanceStateDeprovisioningDeferred represents the state where service
	// instance deprovisioning has been requested and deferred pending the
	// completion of some other action
	InstanceStateDeprovisioningDeferred = "DEPROVISIONING_DEFERRED"
	// InstanceStateDeprovisioning represents the state where service instance
	// deprovisioning is in progress
	InstanceStateDeprovisioning = "DEPROVISIONING"
	// InstanceStateDeprovisioningFailed represents the state where service
	// instance deprovisioning has failed
	InstanceStateDeprovisioningFailed = "DEPROVISIONING_FAILED"
	// BindingStateBound represents the state where service binding has completed
	// successfully
	BindingStateBound = "BOUND"
	// BindingStateBindingFailed represents the state where service binding has
	// failed
	BindingStateBindingFailed = "BINDING_FAILED"
	// BindingStateUnbindingFailed represents the state where service unbinding
	// has failed
	BindingStateUnbindingFailed = "UNBINDING_FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	BindingID                        string                  `json:"bindingId"`
	InstanceID                       string                  `json:"instanceId"`
	ServiceID                        string                  `json:"serviceId"`
	BindingParameters                BindingParameters       `json:"bindingParameters"`       // nolint: lll
	EncryptedSecureBindingParameters []byte                  `json:"secureBindingParameters"` // nolint: lll
	SecureBindingParameters          SecureBindingParameters `json:"-"`
	Status                           string                  `json:"status"`
	StatusReason                     string                  `json:"statusReason"`
	Details                          BindingDetails          `json:"details"`
	EncryptedSecureDetails           []byte                  `json:"secureDetails"` // nolint: lll
	SecureDetails                    SecureBindingDetails    `json:"-"`
	Created                          time.Time               `json:"created"`
}

Binding represents a binding to a service

func NewBindingFromJSON

func NewBindingFromJSON(
	jsonBytes []byte,
	bp BindingParameters,
	sbp SecureBindingParameters,
	bd BindingDetails,
	sbd SecureBindingDetails,
	codec crypto.Codec,
) (Binding, error)

NewBindingFromJSON returns a new Binding unmarshalled from the provided JSON []byte

func (Binding) ToJSON

func (b Binding) ToJSON(codec crypto.Codec) ([]byte, error)

ToJSON returns a []byte containing a JSON representation of the instance

type BindingDetails added in v0.10.0

type BindingDetails interface{}

BindingDetails is an interface to be implemented by service-specific types that represent non-sensitive binding details. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type BindingParameters

type BindingParameters interface{}

BindingParameters is an interface to be implemented by service-specific types that represent non-sensitive binding parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type Catalog

type Catalog interface {
	ToJSON() ([]byte, error)
	GetServices() []Service
	GetService(serviceID string) (Service, bool)
}

Catalog is an interface to be implemented by types that represents the service/plans offered by a service module or by the entire broker.

func NewCatalog

func NewCatalog(services []Service) Catalog

NewCatalog initializes and returns a new Catalog

func NewCatalogFromJSON

func NewCatalogFromJSON(jsonBytes []byte) (Catalog, error)

NewCatalogFromJSON returns a new Catalog unmarshalled from the provided JSON []byte

type Credentials

type Credentials interface{}

Credentials is an interface to be implemented by module-specific types that represent service credentials. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type Deprovisioner

type Deprovisioner interface {
	GetFirstStepName() (string, bool)
	GetStep(name string) (DeprovisioningStep, bool)
	GetNextStepName(name string) (string, bool)
}

Deprovisioner is an interface to be implemented by types that model a declared chain of tasks used to asynchronously deprovision a service

func NewDeprovisioner

func NewDeprovisioner(steps ...DeprovisioningStep) (Deprovisioner, error)

NewDeprovisioner returns a new deprovisioner

type DeprovisioningStep

type DeprovisioningStep interface {
	GetName() string
	Execute(
		ctx context.Context,
		instance Instance,
	) (InstanceDetails, SecureInstanceDetails, error)
}

DeprovisioningStep is an interface to be implemented by types that represent a single step in a chain of steps that defines a deprovisioning process

func NewDeprovisioningStep

func NewDeprovisioningStep(
	name string,
	fn DeprovisioningStepFunction,
) DeprovisioningStep

NewDeprovisioningStep returns a new DeprovisioningStep

type DeprovisioningStepFunction

type DeprovisioningStepFunction func(
	ctx context.Context,
	instance Instance,
) (InstanceDetails, SecureInstanceDetails, error)

DeprovisioningStepFunction is the signature for functions that implement a deprovisioning step

type Instance

type Instance struct {
	InstanceID                            string                       `json:"instanceId"` // nolint: lll
	Alias                                 string                       `json:"alias"`      // nolint: lll
	ServiceID                             string                       `json:"serviceId"`  // nolint: lll
	Service                               Service                      `json:"-"`
	PlanID                                string                       `json:"planId"` // nolint: lll
	Plan                                  Plan                         `json:"-"`
	ProvisioningParameters                ProvisioningParameters       `json:"provisioningParameters"`       // nolint: lll
	EncryptedSecureProvisioningParameters []byte                       `json:"secureProvisioningParameters"` // nolint: lll
	SecureProvisioningParameters          SecureProvisioningParameters `json:"-"`
	UpdatingParameters                    ProvisioningParameters       `json:"updatingParameters"`       // nolint: lll
	EncryptedSecureUpdatingParameters     []byte                       `json:"secureUpdatingParameters"` // nolint: lll
	SecureUpdatingParameters              SecureProvisioningParameters `json:"-"`
	Status                                string                       `json:"status"`        // nolint: lll
	StatusReason                          string                       `json:"statusReason"`  // nolint: lll
	Location                              string                       `json:"location"`      // nolint: lll
	ResourceGroup                         string                       `json:"resourceGroup"` // nolint: lll
	Parent                                *Instance                    `json:"-"`
	ParentAlias                           string                       `json:"parentAlias"`   // nolint: lll
	Tags                                  map[string]string            `json:"tags"`          // nolint: lll
	Details                               InstanceDetails              `json:"details"`       // nolint: lll
	EncryptedSecureDetails                []byte                       `json:"secureDetails"` // nolint: lll
	SecureDetails                         SecureInstanceDetails        `json:"-"`
	Created                               time.Time                    `json:"created"` // nolint: lll
}

Instance represents an instance of a service

func NewInstanceFromJSON

NewInstanceFromJSON returns a new Instance unmarshalled from the provided JSON []byte

func (Instance) ToJSON

func (i Instance) ToJSON(codec crypto.Codec) ([]byte, error)

ToJSON returns a []byte containing a JSON representation of the instance

type InstanceDetails added in v0.10.0

type InstanceDetails interface{}

InstanceDetails is an interface to be implemented by service-specific types that represent the non-sensitive details of a service instance.

type Module

type Module interface {
	// GetName returns a module's name
	GetName() string
	// GetStability returns a module's relative level of stability
	GetStability() Stability
	// GetCatalog returns a Catalog of service/plans offered by a module
	GetCatalog() (Catalog, error)
}

Module is an interface to be implemented by the broker's service modules

type Plan

type Plan interface {
	ToJSON() ([]byte, error)
	GetID() string
	GetName() string
	GetProperties() *PlanProperties
}

Plan is an interface to be implemented by types that represent a single variant or "sku" of a service

func NewPlan

func NewPlan(planProperties *PlanProperties) Plan

NewPlan initializes and returns a new Plan

func NewPlanFromJSON

func NewPlanFromJSON(jsonBytes []byte) (Plan, error)

NewPlanFromJSON returns a new Plan unmarshalled from the provided JSON []byte

type PlanProperties

type PlanProperties struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Free        bool                   `json:"free"`
	Metadata    *ServicePlanMetadata   `json:"metadata,omitempty"`
	Extended    map[string]interface{} `json:"-"`
}

PlanProperties represent the properties of a Plan that can be directly instantiated and passed to the NewPlan() constructor function which will carry out all necessary initialization.

type Provisioner

type Provisioner interface {
	GetFirstStepName() (string, bool)
	GetStep(name string) (ProvisioningStep, bool)
	GetNextStepName(name string) (string, bool)
}

Provisioner is an interface to be implemented by types that model a declared chain of tasks used to asynchronously provision a service

func NewProvisioner

func NewProvisioner(steps ...ProvisioningStep) (Provisioner, error)

NewProvisioner returns a new provisioner

type ProvisioningParameters

type ProvisioningParameters interface{}

ProvisioningParameters is an interface to be implemented by module-specific types that represent non-sensitive provisioning parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type ProvisioningStep

type ProvisioningStep interface {
	GetName() string
	Execute(
		ctx context.Context,
		instance Instance,
	) (InstanceDetails, SecureInstanceDetails, error)
}

ProvisioningStep is an interface to be implemented by types that represent a single step in a chain of steps that defines a provisioning process

func NewProvisioningStep

func NewProvisioningStep(
	name string,
	fn ProvisioningStepFunction,
) ProvisioningStep

NewProvisioningStep returns a new ProvisioningStep

type ProvisioningStepFunction

type ProvisioningStepFunction func(
	ctx context.Context,
	instance Instance,
) (InstanceDetails, SecureInstanceDetails, error)

ProvisioningStepFunction is the signature for functions that implement a provisioning step

type SecureBindingDetails added in v0.10.0

type SecureBindingDetails interface{}

SecureBindingDetails is an interface to be implemented by service-specific types that represent secure (sensitive) binding details. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type SecureBindingParameters added in v0.10.0

type SecureBindingParameters interface{}

SecureBindingParameters is an interface to be implemented by service-specific types that represent sensitive binding parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type SecureInstanceDetails added in v0.10.0

type SecureInstanceDetails interface{}

SecureInstanceDetails is an interface to be implemented by service-specific types that represent the secure (sensitive) details of a service instance.

type SecureProvisioningParameters added in v0.10.0

type SecureProvisioningParameters interface{}

SecureProvisioningParameters is an interface to be implemented by module-specific types that represent secure (sensitive) provisioning parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type Service

type Service interface {
	ToJSON() ([]byte, error)
	GetID() string
	GetName() string
	IsBindable() bool
	GetServiceManager() ServiceManager
	GetPlans() []Plan
	GetPlan(planID string) (Plan, bool)
	GetParentServiceID() string
	GetChildServiceID() string
}

Service is an interface to be implemented by types that represent a single type of service with one or more plans

func NewService

func NewService(
	serviceProperties *ServiceProperties,
	serviceManager ServiceManager,
	plans ...Plan,
) Service

NewService initialized and returns a new Service

func NewServiceFromJSON

func NewServiceFromJSON(jsonBytes []byte) (Service, error)

NewServiceFromJSON returns a new Service unmarshalled from the provided JSON []byte

type ServiceManager added in v0.10.0

type ServiceManager interface {
	// GetEmptyProvisioningParameters returns an empty instance of
	// service-specific non-sensitive  provisioning parameters
	GetEmptyProvisioningParameters() ProvisioningParameters
	// GetEmptySecureProvisioningParameters returns an empty instance of
	// service-specific secured (sensitive) provisioning parameters
	GetEmptySecureProvisioningParameters() SecureProvisioningParameters
	// ValidateProvisioningParameters validates the provided
	// provisioningParameters and returns an error if there is any problem
	ValidateProvisioningParameters(
		ProvisioningParameters,
		SecureProvisioningParameters,
	) error
	// GetProvisioner returns a provisioner that defines the steps a module must
	// execute asynchronously to provision a service.
	GetProvisioner(Plan) (Provisioner, error)
	// GetEmptyInstanceDetails returns an empty instance of non-sensitive
	// service-specific instance details
	GetEmptyInstanceDetails() InstanceDetails
	// GetEmptySecureInstanceDetails returns an empty instance of sensitive
	// service-specific instance details
	GetEmptySecureInstanceDetails() SecureInstanceDetails
	// ValidateUpdatingParameters validates the provided
	// updating parameters against allowed values and current instance state
	// and returns an error if there is any problem
	ValidateUpdatingParameters(Instance) error
	// GetUpdater returns a updater that defines the steps a module must
	// execute asynchronously to update a service.
	GetUpdater(Plan) (Updater, error)
	// GetEmptyBindingParameters returns an empty instance of non-sensitive
	// service-specific binding parameters
	GetEmptyBindingParameters() BindingParameters
	// GetEmptySecureBindingParameters returns an empty instance of sensitive
	// service-specific binding parameters
	GetEmptySecureBindingParameters() SecureBindingParameters
	// ValidateBindingParameters validates the provided bindingParameters and
	// returns an error if there is any problem
	ValidateBindingParameters(BindingParameters, SecureBindingParameters) error
	// Bind synchronously binds to a service
	Bind(
		Instance,
		BindingParameters,
		SecureBindingParameters,
	) (BindingDetails, SecureBindingDetails, error)
	// GetEmptyBindingDetails returns an empty instance of service-specific
	// non-sensitive binding details
	GetEmptyBindingDetails() BindingDetails
	// GetEmptySecureBindingDetails returns an empty instance of service-specific
	// secured (sensitive) binding details
	GetEmptySecureBindingDetails() SecureBindingDetails
	// GetCredentials returns service-specific credentials populated from instance
	// and binding details
	GetCredentials(Instance, Binding) (Credentials, error)
	// Unbind synchronously unbinds from a service
	Unbind(Instance, Binding) error
	// GetDeprovisioner returns a deprovisioner that defines the steps a module
	// must execute asynchronously to deprovision a service
	GetDeprovisioner(Plan) (Deprovisioner, error)
}

ServiceManager is an interface to be implemented by module components responsible for managing the lifecycle of services and plans thereof

type ServiceMetadata added in v0.10.0

type ServiceMetadata struct {
	DisplayName         string `json:"displayName,omitempty"`
	ImageUrl            string `json:"imageUrl,omitempty"` // nolint: golint
	LongDescription     string `json:"longDescription,omitempty"`
	ProviderDisplayName string `json:"providerDisplayName,omitempty"`
	DocumentationUrl    string `json:"documentationUrl,omitempty"` // nolint: golint, lll
	SupportUrl          string `json:"supportUrl,omitempty"`       // nolint: golint, lll
}

ServiceMetadata contains metadata about the service classes

type ServicePlanMetadata added in v0.10.0

type ServicePlanMetadata struct {
	DisplayName string   `json:"displayName,omitempty"`
	Bullets     []string `json:"bullets,omitempty"`
}

ServicePlanMetadata contains metadata about the service plans

type ServiceProperties

type ServiceProperties struct {
	Name          string           `json:"name"`
	ID            string           `json:"id"`
	Description   string           `json:"description"`
	Metadata      *ServiceMetadata `json:"metadata,omitempty"`
	Tags          []string         `json:"tags"`
	Bindable      bool             `json:"bindable"`
	PlanUpdatable bool             `json:"plan_updateable"` // Misspelling is
	// deliberate to match the spec
	ParentServiceID string `json:"-"`
	ChildServiceID  string `json:"-"`
}

ServiceProperties represent the properties of a Service that can be directly instantiated and passed to the NewService() constructor function which will carry out all necessary initialization.

type Stability

type Stability int

Stability is a type that represents the relative stability of a service module

const (
	// StabilityExperimental represents relative stability of the most immature
	// service modules. At this level of stability, we're not even certain we've
	// built the right thing!
	StabilityExperimental Stability = iota
	// StabilityPreview represents relative stability of modules we believe are
	// approaching a stable state.
	StabilityPreview
	// StabilityStable represents relative stability of the mature, production-
	// ready service modules.
	StabilityStable
)

type Updater

type Updater interface {
	GetFirstStepName() (string, bool)
	GetStep(name string) (UpdatingStep, bool)
	GetNextStepName(name string) (string, bool)
}

Updater is an interface to be implemented by types that model a declared chain of tasks used to asynchronously update a service

func NewUpdater

func NewUpdater(steps ...UpdatingStep) (Updater, error)

NewUpdater returns a new updater

type UpdatingStep

type UpdatingStep interface {
	GetName() string
	Execute(
		ctx context.Context,
		instance Instance,
	) (InstanceDetails, SecureInstanceDetails, error)
}

UpdatingStep is an interface to be implemented by types that represent a single step in a chain of steps that defines a updating process

func NewUpdatingStep

func NewUpdatingStep(
	name string,
	fn UpdatingStepFunction,
) UpdatingStep

NewUpdatingStep returns a new UpdatingStep

type UpdatingStepFunction

type UpdatingStepFunction func(
	ctx context.Context,
	instance Instance,
) (InstanceDetails, SecureInstanceDetails, error)

UpdatingStepFunction is the signature for functions that implement a updating step

type ValidationError

type ValidationError struct {
	Field string
	Issue string
}

ValidationError represents an error validating requestParameters. This specific error type should be used to allow the broker's framework to differentiate between validation errors and other common, unexpected errors.

func NewValidationError

func NewValidationError(field, issue string) *ValidationError

NewValidationError returns a new ValidationError for the given field and issue

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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