service

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 10 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

func GetMapFromStruct added in v0.10.0

func GetMapFromStruct(s interface{}) (map[string]interface{}, error)

GetMapFromStruct is a utility function that extracts values from the provided struct into a map[string]interface{}. Maps form the input and output to all ServiceManager functions. This utility function offers ServiceManager implementors the option of working with firendlier, service-specific structs then easily extracting information from those structs into maps.

func GetStructFromMap added in v0.10.0

func GetStructFromMap(m map[string]interface{}, s interface{}) error

GetStructFromMap is a utility function that extracts values from a map[string]interface{} to the provided struct. Maps form the input and output to all ServiceManager functions. This utility function offers ServiceManager implementors the option of working with firendlier, service-specific structs by easily extracting information from maps into thos structs.

Types

type ArrayParameterSchema added in v0.10.0

type ArrayParameterSchema struct {
	Description string
	Required    bool
	ItemsSchema ParameterSchema
}

ArrayParameterSchema represents the attributes of an array type

func (*ArrayParameterSchema) MarshalJSON added in v0.10.0

func (a *ArrayParameterSchema) MarshalJSON() ([]byte, error)

MarshalJSON provides functionality to marshal an ArrayParameterSchema to JSON

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, 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 map[string]interface{}

BindingDetails is an alias for maps intended to contain non-sensitive details of a service binding. It exists only to improve the clarity of function signatures and documentation.

type BindingParameters

type BindingParameters map[string]interface{}

BindingParameters is an alias for maps intended to contain non-sensitive binding parameters. It exists only 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

type CatalogConfig added in v0.10.0

type CatalogConfig struct {
	MinStability Stability
}

CatalogConfig represents details re: which modules' services should be included or excluded from the catalog

func GetCatalogConfigFromEnvironment added in v0.10.0

func GetCatalogConfigFromEnvironment() (CatalogConfig, error)

GetCatalogConfigFromEnvironment returns catalog configuration

func NewCatalogConfigWithDefaults added in v0.10.0

func NewCatalogConfigWithDefaults() CatalogConfig

NewCatalogConfigWithDefaults returns a CatalogConfig object with default values already applied. Callers are then free to set custom values for the remaining fields and/or override default values.

type CombinedBindingParameters added in v0.10.0

type CombinedBindingParameters map[string]interface{}

CombinedBindingParameters is an alias for maps intended to contain inbound binding parameters-- which may contain both sensitive and non-sensitive values. It exists only to improve the clarity of function signatures and documentation.

type CombinedProvisioningParameters added in v0.10.0

type CombinedProvisioningParameters map[string]interface{}

CombinedProvisioningParameters is an alias for maps intended to contain inbound provisioning parameters-- which may contain both sensitive and non-sensitive values. It exists only to improve the clarity of function signatures and documentation.

type Credentials

type Credentials interface{}

Credentials is an interface to be implemented by service-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

func NewInstanceFromJSON(
	jsonBytes []byte,
	codec crypto.Codec,
) (Instance, error)

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 map[string]interface{}

InstanceDetails is an alias for maps intended to contain non-sensitive details of a service instance. It exists only to improve the clarity of function signatures and documentation.

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 modules

type ObjectParameterSchema added in v0.10.0

type ObjectParameterSchema struct {
	Description string
	Required    bool

	Properties map[string]ParameterSchema
	Additional ParameterSchema
	// contains filtered or unexported fields
}

ObjectParameterSchema represents the attributes of a complicated schema type that can have nested properties

func (*ObjectParameterSchema) MarshalJSON added in v0.10.0

func (o *ObjectParameterSchema) MarshalJSON() ([]byte, error)

MarshalJSON provides functionality to marshal an ObjectParameterSchema to JSON

type ParameterSchema added in v0.10.0

type ParameterSchema interface {
	// contains filtered or unexported methods
}

ParameterSchema defines an interface representing a given Parameter schema. This could be a provision or binding parameter.

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"` // nolint: lll
	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 map[string]interface{}

ProvisioningParameters is an alias for maps intended to contain non-sensitive provisioning parameters. It exists only 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 map[string]interface{}

SecureBindingDetails is an alias for maps intended to contain sensitive details of a service binding. It exists only to improve the clarity of function signatures and documentation.

type SecureBindingParameters added in v0.10.0

type SecureBindingParameters map[string]interface{}

SecureBindingParameters is an alias for maps intended to contain sensitive binding parameters. It exists only to improve the clarity of function signatures and documentation.

type SecureInstanceDetails added in v0.10.0

type SecureInstanceDetails map[string]interface{}

SecureInstanceDetails is an alias for maps intended to contain sensitive details of a service instance. It exists only to improve the clarity of function signatures and documentation.

type SecureProvisioningParameters added in v0.10.0

type SecureProvisioningParameters map[string]interface{}

SecureProvisioningParameters is an alias for maps intended to contain sensitive provisioning parameters. It exists only 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 {
	// SplitProvisioningParameters splits a map of provisioning parameters into
	// two separate maps, with one containing non-sensitive provisioning
	// parameters and the other containing sensitive provisioning parameters.
	SplitProvisioningParameters(
		CombinedProvisioningParameters,
	) (ProvisioningParameters, SecureProvisioningParameters, error)
	// 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)
	// 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)
	// SplitBindingParameters splits a map of binding parameters into two separate
	// maps, with one containing non-sensitive binding parameters and the other
	// containing sensitive binding parameters.
	SplitBindingParameters(
		CombinedBindingParameters,
	) (BindingParameters, SecureBindingParameters, error)
	// 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)
	// 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"`
	LongDescription     string `json:"longDescription,omitempty"`
	ProviderDisplayName string `json:"providerDisplayName,omitempty"`
	DocumentationURL    string `json:"documentationUrl,omitempty"`
	SupportURL          string `json:"supportUrl,omitempty"`
}

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:"-"`
	ProvisionParamsSchema map[string]ParameterSchema `json:"-"`
	UpdateParamsSchema    map[string]ParameterSchema `json:"-"`
	BindingParamsSchema   map[string]ParameterSchema `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 SimpleParameterSchema added in v0.10.0

type SimpleParameterSchema struct {
	Type          string      `json:"type"`
	Description   string      `json:"description,omitempty"`
	Required      bool        `json:"-"`
	Default       interface{} `json:"default,omitempty"`
	AllowedValues interface{} `json:"enum,omitempty"`
}

SimpleParameterSchema represents the attributes of a simple schema type such as a string or integer

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