broker

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheTTL = 1 * time.Hour

CacheTTL TTL for catalog cache record expiry

Functions

func AddFlags

func AddFlags(o *Options)

AddFlags adds defined flags to cli options

func AwsDdbClientGetter

func AwsDdbClientGetter(sess *session.Session) *dynamodb.DynamoDB

func AwsIamClientGetter

func AwsIamClientGetter(sess *session.Session) iamiface.IAMAPI

func AwsLambdaClientGetter added in v1.0.3

func AwsLambdaClientGetter(sess *session.Session) lambdaiface.LambdaAPI

func AwsSessionGetter

func AwsSessionGetter(keyid string, secretkey string, region string, accountId string, profile string, params map[string]string) *session.Session

Create AWS Session

func AwsSsmClientGetter

func AwsSsmClientGetter(sess *session.Session) ssmiface.SSMAPI

func AwsStsClientGetter

func AwsStsClientGetter(sess *session.Session) *sts.STS

func GetCallerId

func GetCallerId(svc stsiface.STSAPI) (*sts.GetCallerIdentityOutput, error)

func ListTemplates

func ListTemplates(s3source *BucketDetailsRequest, b *AwsBroker) (*[]ServiceLastUpdate, error)

func ListingUpdate

func ListingUpdate(l *[]ServiceLastUpdate, c cache.Cache) error

func MetadataUpdate

func MetadataUpdate(l cache.Cache, c cache.Cache, bd BucketDetailsRequest, s3svc S3Client, db Db, metadataUpdate MetadataUpdater, templatefilter string) error

func PollUpdate

func PollUpdate(interval int, l cache.Cache, c cache.Cache, bd BucketDetailsRequest, s3svc S3Client, db Db, bl AwsBroker, updateCatalog UpdateCataloger, listTemplates ListTemplateser)

func UpdateCatalog

func UpdateCatalog(listingcache cache.Cache, catalogcache cache.Cache, bd BucketDetailsRequest, s3svc S3Client, db Db, bl AwsBroker, listTemplates ListTemplateser, listingUpdate ListingUpdater, metadataUpdate MetadataUpdater) error

Types

type AwsBroker

type AwsBroker struct {
	sync.RWMutex

	GetSession GetAwsSession
	Clients    AwsClients
	// contains filtered or unexported fields
}

AwsBroker holds configuration, caches and aws service clients

func NewAWSBroker

func NewAWSBroker(o Options, awssess GetAwsSession, clients AwsClients, getCallerId GetCallerIder, updateCatalog UpdateCataloger, pollUpdate PollUpdater, mc *MetricsCollector) (*AwsBroker, error)

Runs at startup and bootstraps the broker

func (*AwsBroker) Bind

Bind is executed when the OSB API receives `PUT /v2/service_instances/:instance_id/service_bindings/:binding_id` (https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#request-4).

func (*AwsBroker) BindingLastOperation

BindingLastOperation is not implemented, as async binding is not supported.

func (*AwsBroker) Deprovision

Deprovision is executed when the OSB API receives `DELETE /v2/service_instances/:instance_id` (https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#deprovisioning).

func (*AwsBroker) GetBinding

GetBinding is not implemented, as async binding is not supported.

func (*AwsBroker) GetCatalog

GetCatalog is executed on a /v2/catalog/ osb api call https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#catalog-management

func (*AwsBroker) LastOperation

LastOperation is executed when the OSB API receives `GET /v2/service_instances/:instance_id/last_operation` (https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#polling-last-operation).

func (*AwsBroker) Provision

Provision is executed when the OSB API receives `PUT /v2/service_instances/:instance_id` (https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#provisioning).

func (*AwsBroker) Unbind

Unbind is executed when the OSB API receives `DELETE /v2/service_instances/:instance_id/service_bindings/:binding_id` (https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#request-5).

func (*AwsBroker) Update

Update is executed when the OSB API receives `PATCH /v2/service_instances/:instance_id` (https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#updating-a-service-instance).

func (*AwsBroker) ValidateBrokerAPIVersion

func (b *AwsBroker) ValidateBrokerAPIVersion(version string) error

ValidateBrokerAPIVersion still to determine supported api versions

type AwsClients

type AwsClients struct {
	NewCfn    GetCfnClient
	NewSsm    GetSsmClient
	NewS3     GetS3Client
	NewDdb    GetDdbClient
	NewSts    GetStsClient
	NewIam    GetIamClient
	NewLambda GetLambdaClient
}

type AwsTags

type AwsTags []struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

type BucketDetailsRequest

type BucketDetailsRequest struct {
	// contains filtered or unexported fields
}

BucketDetailsRequest describes the details required to fetch metadata and templates from s3

type CfnClient

type CfnClient struct {
	Client cloudformationiface.CloudFormationAPI
}

func AwsCfnClientGetter

func AwsCfnClientGetter(sess *session.Session) CfnClient

type CfnCost added in v1.0.3

type CfnCost struct {
	Amount map[string]float64 `yaml:"Amount,omitempty" json:"amount,omitempty"`
	Unit   string             `yaml:"Unit,omitempty" json:"unit,omitempty"`
}

type CfnServicePlan added in v1.0.3

type CfnServicePlan struct {
	DisplayName       string            `yaml:"DisplayName,omitempty"`
	Description       string            `yaml:"Description,omitempty"`
	LongDescription   string            `yaml:"LongDescription,omitempty"`
	Cost              string            `yaml:"Cost,omitempty"`
	Costs             []CfnCost         `yaml:"Costs,omitempty"`
	ParameterValues   map[string]string `yaml:"ParameterValues,omitempty"`
	ParameterDefaults map[string]string `yaml:"ParameterDefaults,omitempty"`
}

type CfnTemplate

type CfnTemplate struct {
	Description string `yaml:"Description,omitempty"`
	Parameters  map[string]struct {
		Description   string   `yaml:"Description,omitempty"`
		Type          string   `yaml:"Type,omitempty"`
		Default       *string  `yaml:"Default,omitempty"`
		AllowedValues []string `yaml:"AllowedValues,omitempty"`
	} `yaml:"Parameters,omitempty"`
	Outputs map[string]struct {
		Description string `yaml:"Description,omitempty"`
	} `yaml:"Outputs,omitempty"`
	Metadata struct {
		Spec struct {
			Version             string   `yaml:"Version,omitempty"`
			Tags                []string `yaml:"Tags,omitempty"`
			Name                string   `yaml:"Name,omitempty"`
			DisplayName         string   `yaml:"DisplayName,omitempty"`
			LongDescription     string   `yaml:"LongDescription,omitempty"`
			ImageUrl            string   `yaml:"ImageUrl,omitempty"`
			DocumentationUrl    string   `yaml:"DocumentationUrl,omitempty"`
			ProviderDisplayName string   `yaml:"ProviderDisplayName,omitempty"`
			OutputsAsIs         bool     `yaml:"OutputsAsIs,omitempty"`
			CloudFoundry        bool     `yaml:"CloudFoundry,omitempty"`
			BindViaLambda       bool     `yaml:"BindViaLambda"`
			Bindings            struct {
				IAM struct {
					AddKeypair bool `yaml:"AddKeypair,omitempty"`
					Policies   []struct {
						PolicyDocument map[string]interface{} `yaml:"PolicyDocument,omitempty"`
					} `yaml:"Policies,omitempty"`
				} `yaml:"IAM,omitempty"`
				CFNOutputs []string `yaml:"CFNOutputs,omitempty"`
			} `yaml:"Bindings,omitempty"`
			ServicePlans        map[string]CfnServicePlan `yaml:"ServicePlans,omitempty"`
			UpdatableParameters []string                  `yaml:"UpdatableParameters,omitempty"`
		} `yaml:"AWS::ServiceBroker::Specification,omitempty"`
		Interface struct {
			ParameterGroups []struct {
				Label struct {
					Name string `yaml:"default,omitempty"`
				} `yaml:"Label,omitempty"`
				Parameters []string `yaml:"Parameters,omitempty"`
			} `yaml:"ParameterGroups,omitempty"`
			ParameterLabels map[string]struct {
				Label string `yaml:"default,omitempty"`
			} `yaml:"ParameterLabels,omitempty"`
		} `yaml:"AWS::CloudFormation::Interface,omitempty"`
	} `yaml:"Metadata,omitempty"`
}

type DataStore

type DataStore interface {
	PutServiceDefinition(sd osb.Service) error
	GetParam(paramname string) (value string, err error)
	PutParam(paramname string, paramvalue string) error
	GetServiceDefinition(serviceuuid string) (*osb.Service, error)
	GetServiceInstance(sid string) (*serviceinstance.ServiceInstance, error)
	PutServiceInstance(si serviceinstance.ServiceInstance) error
	DeleteServiceInstance(sid string) error
	GetServiceBinding(id string) (*serviceinstance.ServiceBinding, error)
	PutServiceBinding(sb serviceinstance.ServiceBinding) error
	DeleteServiceBinding(id string) error
}

DataStore port, any backend datastore must provide at least these interfaces

type Db

type Db struct {
	Accountid     string
	Accountuuid   uuid.UUID
	Brokerid      string
	DataStorePort DataStore
}

Db configuration

func (Db) ServiceDefinitionToOsb

func (db Db) ServiceDefinitionToOsb(sd CfnTemplate) osb.Service

ServiceDefinitionToOsb converts apb service definition into osb.Service struct

type GetAwsSession

type GetAwsSession func(keyid string, secretkey string, region string, accountId string, profile string, params map[string]string) *session.Session

type GetCallerIder

type GetCallerIder func(svc stsiface.STSAPI) (*sts.GetCallerIdentityOutput, error)

type GetCfnClient

type GetCfnClient func(sess *session.Session) CfnClient

type GetDdbClient

type GetDdbClient func(sess *session.Session) *dynamodb.DynamoDB

type GetIamClient

type GetIamClient func(sess *session.Session) iamiface.IAMAPI

type GetLambdaClient added in v1.0.3

type GetLambdaClient func(sess *session.Session) lambdaiface.LambdaAPI

type GetS3Client

type GetS3Client func(sess *session.Session) S3Client

type GetSsmClient

type GetSsmClient func(sess *session.Session) ssmiface.SSMAPI

type GetStsClient

type GetStsClient func(sess *session.Session) *sts.STS

type ListTemplateser

type ListTemplateser func(s3source *BucketDetailsRequest, b *AwsBroker) (*[]ServiceLastUpdate, error)

type ListingUpdater

type ListingUpdater func(l *[]ServiceLastUpdate, c cache.Cache) error

type MetadataUpdater

type MetadataUpdater func(l cache.Cache, c cache.Cache, bd BucketDetailsRequest, s3svc S3Client, db Db, metadataUpdate MetadataUpdater, templatefilter string) error

type MetricsCollector added in v1.0.4

type MetricsCollector struct {
	Actions *prom.CounterVec
}

MetricsCollector is a prometheus metrics collector that is capable of providing better (more fine grained) action counts that the OSBMetricsCollector provided by the osb-broker-lib library - mainly it exists so that we don't reuse the same metric name, and we don't conflict with the metric gathering in that library.

func NewMetricsCollector added in v1.0.4

func NewMetricsCollector() *MetricsCollector

New initialises the MetricsCollector with a counter vec.

func (*MetricsCollector) Collect added in v1.0.4

func (c *MetricsCollector) Collect(ch chan<- prom.Metric)

Collect returns the current state of all metrics of the collector.

func (*MetricsCollector) Describe added in v1.0.4

func (c *MetricsCollector) Describe(ch chan<- *prom.Desc)

Describe returns all descriptions of the collector.

type OpenshiftFormDefinition

type OpenshiftFormDefinition struct {
	Type  string
	Title string
	Items []string
}

type Options

type Options struct {
	CatalogPath        string
	KeyID              string
	SecretKey          string
	Profile            string
	TableName          string
	S3Bucket           string
	S3Region           string
	S3Key              string
	TemplateFilter     string
	Region             string
	BrokerID           string
	RoleArn            string
	PrescribeOverrides bool
}

Options cli options

type PollUpdater

type PollUpdater func(interval int, l cache.Cache, c cache.Cache, bd BucketDetailsRequest, s3svc S3Client, db Db, bl AwsBroker, updateCatalog UpdateCataloger, listTemplates ListTemplateser)

type S3Client

type S3Client struct {
	Client s3iface.S3API
}

func AwsS3ClientGetter

func AwsS3ClientGetter(sess *session.Session) S3Client

type ServiceLastUpdate

type ServiceLastUpdate struct {
	Name string
	Date time.Time
}

ServiceLastUpdate date when a service exposed by the broker was last updated from s3

type ServiceNeedsUpdate

type ServiceNeedsUpdate struct {
	Name   string
	Update bool
}

ServiceNeedsUpdate if Update == true the metadata should be refreshed from s3

type UpdateCataloger

type UpdateCataloger func(listingcache cache.Cache, catalogcache cache.Cache, bd BucketDetailsRequest, s3svc S3Client, db Db, bl AwsBroker, listTemplates ListTemplateser, listingUpdate ListingUpdater, metadataUpdate MetadataUpdater) error

Jump to

Keyboard shortcuts

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