bundle

package
v0.0.0-...-793517a Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// StateNotYetStarted - Executor has not yet started state.
	StateNotYetStarted State = "not yet started"
	// StateInProgress - APB is in progress state
	StateInProgress State = "in progress"
	// StateSucceeded - Succeeded state
	StateSucceeded State = "succeeded"
	// StateFailed - Failed state
	StateFailed State = "failed"

	// ApbContainerName - The name of the apb container
	ApbContainerName = "apb"

	// ProvisionCredentialsKey parameter name passed to APBs
	ProvisionCredentialsKey = "_apb_provision_creds"
	// BindCredentialsKey parameter name passed to APBs
	BindCredentialsKey = "_apb_bind_creds"
	// ClusterKey parameter name passed to APBs
	ClusterKey = "cluster"
	// NamespaceKey parameter name passed to APBs
	NamespaceKey = "namespace"
)
View Source
const (
	// GatherCredentialsCommand - Command used when execing for bind credentials
	// moving this constant here because eventually Extracting creds will
	// need to be moved to runtime. Therefore keeping all of this together
	// makes sense
	GatherCredentialsCommand = "broker-bind-creds"
)
View Source
const MaxRuntimeVersion = 2

MaxRuntimeVersion constant to describe maximum supported runtime version

View Source
const MaxSpecVersion = "1.0.0"

MaxSpecVersion constant to describe maximum supported spec version

View Source
const MinRuntimeVersion = 1

MinRuntimeVersion constant to describe minimum supported runtime version

View Source
const MinSpecVersion = "1.0.0"

MinSpecVersion constant to describe minimum supported spec version

Variables

View Source
var (
	// ErrExtractedCredentialsNotFound - Extracted Credentials are not found.
	ErrExtractedCredentialsNotFound = fmt.Errorf("credentials not found")
)

Functions

func AddSecrets

func AddSecrets(specs []*Spec)

AddSecrets - Uses the AssociationRules generated from config to link specs to secrets and add them to the global secrets cache

func AddSecretsFor

func AddSecretsFor(spec *Spec)

AddSecretsFor - Uses AssociationRules for a given spec to link the spec to secrets and add them to the global secrets cache

func DeleteExtractedCredentials

func DeleteExtractedCredentials(id string) error

DeleteExtractedCredentials - Will delete the extracted credentials for a caller of the APB package. Please use this method with caution.

func DumpJSON

func DumpJSON(obj interface{}) (string, error)

DumpJSON - Generic function to marshal obj to json string

func InitializeClusterConfig

func InitializeClusterConfig(config ClusterConfig)

InitializeClusterConfig - initialize the cluster config.

func InitializeSecretsCache

func InitializeSecretsCache(rules []AssociationRule)

InitializeSecretsCache - Generates AssociationRules from config and initializes the global secrets cache

func LoadJSON

func LoadJSON(payload string, obj interface{}) error

LoadJSON - Generic function to unmarshal json

func RecoverExtractCredentials

func RecoverExtractCredentials(podname, ns, fqname, id string, method JobMethod, targets []string, rt int) error

RecoverExtractCredentials - Recover extracted credentials.

func SetExtractedCredentials

func SetExtractedCredentials(id string, creds *ExtractedCredentials) error

SetExtractedCredentials - Will set new credentials for an id. Please use this method with caution.

func SetExtractedCredentialsWithLabels

func SetExtractedCredentialsWithLabels(id string, creds *ExtractedCredentials, labels map[string]string) error

SetExtractedCredentialsWithLabels - Will set new credentials for an id and add specified labels Please use this method with caution.

func SpecLogDump

func SpecLogDump(spec *Spec)

SpecLogDump - log spec for debug

func SpecsLogDump

func SpecsLogDump(specs []*Spec)

SpecsLogDump - log specs for debug

Types

type AssociationRule

type AssociationRule struct {
	BundleName string
	Secret     string
}

AssociationRule - A rule to associate an apb with a secret

type BindInstance

type BindInstance struct {
	ID           uuid.UUID   `json:"id"`
	ServiceID    uuid.UUID   `json:"service_id"`
	Parameters   *Parameters `json:"parameters"`
	CreateJobKey string
}

BindInstance - Binding Instance describes a completed binding

func (*BindInstance) IsEqual

func (bi *BindInstance) IsEqual(newbi *BindInstance) bool

IsEqual - Determines if two BindInstances are equal, omitting any Parameters that generally get added by the broker itself.

func (*BindInstance) UserParameters

func (bi *BindInstance) UserParameters() Parameters

UserParameters - returns the Parameters field with any keys and values removed that are typically added by the broker itself. The return value should represent what a OSB API client provides in a bind request.

type ClusterConfig

type ClusterConfig struct {
	PullPolicy           string `yaml:"image_pull_policy"`
	SandboxRole          string `yaml:"sandbox_role"`
	Namespace            string `yaml:"namespace"`
	KeepNamespace        bool   `yaml:"keep_namespace"`
	KeepNamespaceOnError bool   `yaml:"keep_namespace_on_error"`
}

ClusterConfig - Configuration for the cluster.

type Context

type Context struct {
	Platform  string `json:"platform"`
	Namespace string `json:"namespace"`
}

Context - Determines the context in which the service is running

type Dependency

type Dependency struct {
	Key   string      `json:"key,omitempty" yaml:"key,omitempty"`
	Value interface{} `json:"value,omitempty" yaml:"value,omitempty"`
}

Dependency - a parameter dependency

type Executor

type Executor interface {
	ExecutorAccessors
	ExecutorAsync
}

Executor - Composite executor interface.

func NewExecutor

func NewExecutor(config ExecutorConfig) Executor

NewExecutor - Creates a new Executor for running an APB.

type ExecutorAccessors

type ExecutorAccessors interface {
	PodName() string
	LastStatus() StatusMessage
	DashboardURL() string
	ExtractedCredentials() *ExtractedCredentials
}

ExecutorAccessors - Accessors for Executor state.

type ExecutorAsync

type ExecutorAsync interface {
	Provision(*ServiceInstance) <-chan StatusMessage
	Deprovision(instance *ServiceInstance) <-chan StatusMessage
	Bind(instance *ServiceInstance, parameters *Parameters, bindingID string) <-chan StatusMessage
	Unbind(instance *ServiceInstance, parameters *Parameters, bindingID string) <-chan StatusMessage
	Update(instance *ServiceInstance) <-chan StatusMessage
}

ExecutorAsync - Main interface used for running APBs asynchronously.

type ExecutorConfig

type ExecutorConfig struct {
	// This will tell the executor to use the context namespace as the
	// namespace for the bundle to be created in.
	SkipCreateNS bool
}

ExecutorConfig - configuration for the executor.

type ExtractedCredentials

type ExtractedCredentials struct {
	Credentials map[string]interface{} `json:"credentials,omitempty"`
}

ExtractedCredentials - Credentials that are extracted from the pods

func GetExtractedCredentials

func GetExtractedCredentials(id string) (*ExtractedCredentials, error)

GetExtractedCredentials - Will get the extracted credentials for a caller of the APB package.

type JobMethod

type JobMethod string

JobMethod - APB Method Type that the job was spawned from.

const (
	// JobMethodProvision - Provision MethodType const.
	JobMethodProvision JobMethod = "provision"

	// JobMethodDeprovision - Deprovision MethodType const.
	JobMethodDeprovision JobMethod = "deprovision"

	// JobMethodBind - Bind MethodType const.
	JobMethodBind JobMethod = "bind"

	// JobMethodUnbind - Unbind MethodType const.
	JobMethodUnbind JobMethod = "unbind"

	// JobMethodUpdate - Update MethodType const.
	JobMethodUpdate JobMethod = "update"
)

type JobState

type JobState struct {
	Token       string    `json:"token"`
	State       State     `json:"state"`
	Podname     string    `json:"podname"`
	Method      JobMethod `json:"method"`
	Error       string    `json:"error"`
	Description string    `json:"description"`
}

JobState - The job state

type MockExecutor

type MockExecutor struct {
	mock.Mock
}

MockExecutor is an autogenerated mock type for the Executor type

func (*MockExecutor) Bind

func (_m *MockExecutor) Bind(instance *ServiceInstance, parameters *Parameters, bindingID string) <-chan StatusMessage

Bind provides a mock function with given fields: instance, parameters, bindingID

func (*MockExecutor) DashboardURL

func (_m *MockExecutor) DashboardURL() string

DashboardURL provides a mock function with given fields:

func (*MockExecutor) Deprovision

func (_m *MockExecutor) Deprovision(instance *ServiceInstance) <-chan StatusMessage

Deprovision provides a mock function with given fields: instance

func (*MockExecutor) ExtractedCredentials

func (_m *MockExecutor) ExtractedCredentials() *ExtractedCredentials

ExtractedCredentials provides a mock function with given fields:

func (*MockExecutor) LastStatus

func (_m *MockExecutor) LastStatus() StatusMessage

LastStatus provides a mock function with given fields:

func (*MockExecutor) PodName

func (_m *MockExecutor) PodName() string

PodName provides a mock function with given fields:

func (*MockExecutor) Provision

func (_m *MockExecutor) Provision(_a0 *ServiceInstance) <-chan StatusMessage

Provision provides a mock function with given fields: _a0

func (*MockExecutor) Unbind

func (_m *MockExecutor) Unbind(instance *ServiceInstance, parameters *Parameters, bindingID string) <-chan StatusMessage

Unbind provides a mock function with given fields: instance, parameters, bindingID

func (*MockExecutor) Update

func (_m *MockExecutor) Update(instance *ServiceInstance) <-chan StatusMessage

Update provides a mock function with given fields: instance

type NilableNumber

type NilableNumber float64

NilableNumber - Number that could be nil (e.g. when omitted from json/yaml)

type ParameterDescriptor

type ParameterDescriptor struct {
	Name        string      `json:"name"`
	Title       string      `json:"title"`
	Type        string      `json:"type"`
	Description string      `json:"description,omitempty"`
	Default     interface{} `json:"default,omitempty"`

	// string validators
	DeprecatedMaxlength int    `json:"maxlength,omitempty" yaml:"maxlength,omitempty"` // backwards compatibility
	MaxLength           int    `json:"maxLength,omitempty" yaml:"max_length,omitempty"`
	MinLength           int    `json:"minLength,omitempty" yaml:"min_length,omitempty"`
	Pattern             string `json:"pattern,omitempty"`

	// number validators
	MultipleOf       float64        `json:"multipleOf,omitempty" yaml:"multiple_of,omitempty"`
	Maximum          *NilableNumber `json:"maximum,omitempty"`
	ExclusiveMaximum *NilableNumber `json:"exclusiveMaximum,omitempty" yaml:"exclusive_maximum,omitempty"`
	Minimum          *NilableNumber `json:"minimum,omitempty"`
	ExclusiveMinimum *NilableNumber `json:"exclusiveMinimum,omitempty" yaml:"exclusive_minimum,omitempty"`

	Enum         []string     `json:"enum,omitempty"`
	Required     bool         `json:"required"`
	Updatable    bool         `json:"updatable"`
	DisplayType  string       `json:"displayType,omitempty" yaml:"display_type,omitempty"`
	DisplayGroup string       `json:"displayGroup,omitempty" yaml:"display_group,omitempty"`
	Dependencies []Dependency `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
}

ParameterDescriptor - a parameter to be used by the service catalog to get data.

type Parameters

type Parameters map[string]interface{}

Parameters - generic string to object or value parameter

func (*Parameters) Add

func (p *Parameters) Add(key string, val interface{})

Add adds a values to the parameters indexed by key

func (*Parameters) EnsureDefaults

func (p *Parameters) EnsureDefaults()

EnsureDefaults returns the sets any expected parameters that are not present with default values

type Plan

type Plan struct {
	ID             string                 `json:"id" yaml:"-"`
	Name           string                 `json:"name"`
	Description    string                 `json:"description"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
	Free           bool                   `json:"free,omitempty"`
	Bindable       bool                   `json:"bindable,omitempty"`
	Parameters     []ParameterDescriptor  `json:"parameters"`
	BindParameters []ParameterDescriptor  `json:"bind_parameters,omitempty" yaml:"bind_parameters,omitempty"`
	UpdatesTo      []string               `json:"updates_to,omitempty" yaml:"updates_to,omitempty"`
}

Plan - Plan object describing an APB deployment plan and associated parameters

func (*Plan) GetParameter

func (p *Plan) GetParameter(name string) *ParameterDescriptor

GetParameter - retrieves a reference to a ParameterDescriptor from a plan by name. Will return nil if the requested ParameterDescriptor does not exist.

type RecoverStatus

type RecoverStatus struct {
	InstanceID uuid.UUID `json:"id"`
	State      JobState  `json:"state"`
}

RecoverStatus - Status of the recovery.

type Schema

type Schema struct {
	ServiceInstance ServiceInstanceSchema `json:"service_instance"`
	ServiceBinding  ServiceBindingSchema  `json:"service_binding"`
}

Schema - Schema to be returned based on 2.13 of the open service broker api. https://github.com/avade/servicebroker/blob/cda8c57b6a4bb7eaee84be20bb52dc155269758a/spec.md

type SchemaPlan

type SchemaPlan struct {
	ID          string                 `json:"id" yaml:"-"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	Free        bool                   `json:"free,omitempty"`
	Bindable    bool                   `json:"bindable,omitempty"`
	UpdatesTo   []string               `json:"updates_to,omitempty" yaml:"updates_to,omitempty"`
	Schemas     Schema                 `json:"schema,omitempty"`
}

SchemaPlan - Plan object describing an APB deployment plan and associated parameters

func ConvertPlansToSchema

func ConvertPlansToSchema(plans []Plan) ([]SchemaPlan, error)

ConvertPlansToSchema - converts plans to schema

type SecretsConfig

type SecretsConfig struct {
	Name    string `yaml:"name"`
	ApbName string `yaml:"apb_name"`
	Secret  string `yaml:"secret"`
}

SecretsConfig - Entry for a secret config block in broker config

func (SecretsConfig) Validate

func (c SecretsConfig) Validate() bool

Validate - Ensures that the secrets config is valid (i.e., all strings are non-empty

type ServiceBindingSchema

type ServiceBindingSchema struct {
	Create map[string]*schema.Schema `json:"create"`
}

ServiceBindingSchema - Schema definitions for creating a service binding.

type ServiceInstance

type ServiceInstance struct {
	ID           uuid.UUID       `json:"id"`
	Spec         *Spec           `json:"spec"`
	Context      *Context        `json:"context"`
	Parameters   *Parameters     `json:"parameters"`
	BindingIDs   map[string]bool `json:"binding_ids"`
	DashboardURL string          `json:"dashboard_url"`
}

ServiceInstance - Service Instance describes a running service.

func (*ServiceInstance) AddBinding

func (si *ServiceInstance) AddBinding(bindingUUID uuid.UUID)

AddBinding - Add binding ID to service instance

func (*ServiceInstance) RemoveBinding

func (si *ServiceInstance) RemoveBinding(bindingUUID uuid.UUID)

RemoveBinding - Remove binding ID from service instance

type ServiceInstanceSchema

type ServiceInstanceSchema struct {
	Create map[string]*schema.Schema `json:"create"`
	Update map[string]*schema.Schema `json:"update"`
}

ServiceInstanceSchema - Schema definitions for creating and updating a service instance. Toyed with the idea of making an InputParameters that was a *schema.Schema based on 2.13 of the open service broker api. https://github.com/avade/servicebroker/blob/cda8c57b6a4bb7eaee84be20bb52dc155269758a/spec.md

type Spec

type Spec struct {
	ID          string                 `json:"id"`
	Runtime     int                    `json:"runtime"`
	Version     string                 `json:"version"`
	FQName      string                 `json:"name" yaml:"name" mapstructure:"name"`
	Image       string                 `json:"image" yaml:"-"`
	Tags        []string               `json:"tags"`
	Bindable    bool                   `json:"bindable"`
	Description string                 `json:"description"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	Async       string                 `json:"async"`
	Plans       []Plan                 `json:"plans"`
	Alpha       map[string]interface{} `json:"alpha,omitempty"`
	Delete      bool                   `json:"delete"`
}

Spec - A APB spec

func FilterSecrets

func FilterSecrets(inSpecs []*Spec) ([]*Spec, error)

FilterSecrets - Filters all parameters masked by a secret out of the given specs

func (*Spec) GetPlan

func (s *Spec) GetPlan(name string) (Plan, bool)

GetPlan - retrieves a plan from a spec by name. Will return empty plan and false if the requested plan does not exist.

func (*Spec) GetPlanFromID

func (s *Spec) GetPlanFromID(id string) (Plan, bool)

GetPlanFromID - retrieves a plan from a spec by id. Will return empty plan and false if the requested plan does not exist.

func (*Spec) ValidateVersion

func (s *Spec) ValidateVersion() bool

ValidateVersion - Ensure the Bundle Spec Version and Bundle Runtime Version are within bounds

type SpecManifest

type SpecManifest map[string]*Spec

SpecManifest - Spec ID to Spec manifest

func NewSpecManifest

func NewSpecManifest(specs []*Spec) SpecManifest

NewSpecManifest - Creates Spec manifest

type State

type State string

State - Job State

type StatusMessage

type StatusMessage struct {
	State       State
	Description string
	Error       error
}

StatusMessage - Describes the latest known status of a running APB

Jump to

Keyboard shortcuts

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