catalog

package
v0.0.0-...-51c5060 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: CC0-1.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoServiceFound represents the error to return when the service could not be found by its ID.
	ErrNoServiceFound = errors.New("No service found for given service id.")
	// ErrNoPlanFound represents the error to return when the plan could not be found by its ID.
	ErrNoPlanFound = errors.New("No plan found for given plan id.")
)

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	// Instances of Services
	RdsService           RDSService           `yaml:"rds" json:"-"`
	RedisService         RedisService         `yaml:"redis" json:"-"`
	ElasticsearchService ElasticsearchService `yaml:"elasticsearch" json:"-"`
	// contains filtered or unexported fields
}

Catalog struct holds a collections of services

func InitCatalog

func InitCatalog(path string) *Catalog

InitCatalog initializes a Catalog struct that contains services and plans defined in the catalog.yaml configuration file and returns a pointer to that catalog

func (*Catalog) GetResources

func (c *Catalog) GetResources() Resources

GetResources returns the resources wrapper for all the resources generated from the secrets.

func (*Catalog) GetServices

func (c *Catalog) GetServices() []interface{}

GetServices returns the list of all the Services. In order to do this, it uses reflection to look for all the exported values of the catalog.

type ElasticsearchDBSecret

type ElasticsearchDBSecret struct {
	common.DBConfig `yaml:",inline" validate:"required,dive,required"`
	PlanID          string `yaml:"plan_id" validate:"required"`
}

ElasticsearchDBSecret contains the config to connect to a database and the corresponding plan id.

type ElasticsearchPlan

type ElasticsearchPlan struct {
	Plan                       `yaml:",inline" validate:"required"`
	Tags                       map[string]string `yaml:"tags" json:"-" validate:"required" `
	ElasticsearchVersion       string            `yaml:"elasticsearchVersion" json:"-" validate:"required"`
	MasterCount                string            `yaml:"masterCount" json:"-"`
	DataCount                  string            `yaml:"dataCount" json:"-" validate:"required"`
	InstanceType               string            `yaml:"instanceType" json:"-" validate:"required"`
	MasterInstanceType         string            `yaml:"masterInstanceType" json:"-"`
	VolumeSize                 string            `yaml:"volumeSize" json:"-" validate:"required"`
	VolumeType                 string            `yaml:"volumeType" json:"-" validate:"required"`
	MasterEnabled              bool              `yaml:"masterEnabled" json:"-"`
	NodeToNodeEncryption       bool              `yaml:"nodeToNodeEncryption" json:"-"`
	EncryptAtRest              bool              `yaml:"encryptAtRest" json:"-"`
	AutomatedSnapshotStartHour string            `yaml:"automatedSnapshotStartHour" json:"-"`
	SubnetID1AZ1               string            `yaml:"subnetID1az1" json:"-" validate:"required"`
	SubnetID2AZ2               string            `yaml:"subnetID2az2" json:"-" validate:"required"`
	SubnetID3AZ1               string            `yaml:"subnetID3az1" json:"-" validate:"required"`
	SubnetID4AZ2               string            `yaml:"subnetID4az2" json:"-" validate:"required"`
	SecurityGroup              string            `yaml:"securityGroup" json:"-" validate:"required"`
	ApprovedMajorVersions      []string          `yaml:"approvedMajorVersions" json:"-"`
}

ElasticsearchPlan inherits from a plan and adds fields needed for AWS Redis.

func (ElasticsearchPlan) CheckVersion

func (p ElasticsearchPlan) CheckVersion(version string) bool

CheckVersion verifies that a specific version chosen by the user for a new elasticsearch instances is valid and supported in the chosen plan.

type ElasticsearchSecret

type ElasticsearchSecret struct {
	ServiceID      string          `yaml:"service_id" validate:"required"`
	RedisDBSecrets []RedisDBSecret `yaml:"plans" validate:"required,dive,required"`
}

ElasticsearchSecret is a wrapper for all the Elasticsearch Secrets. Only contains RDS database secrets as of now.

type ElasticsearchService

type ElasticsearchService struct {
	Service `yaml:",inline" validate:"required"`
	Plans   []ElasticsearchPlan `yaml:"plans" json:"plans" validate:"required,dive,required"`
}

ElasticsearchService describes the Elasticsearch Service. It contains the basic Service details as well as a list of Elasticsearch Plans

func (ElasticsearchService) FetchPlan

FetchPlan will look for a specific ElasticsearchSecret Plan based on the plan ID.

type Plan

type Plan struct {
	ID             string       `yaml:"id" json:"id" validate:"required"`
	Name           string       `yaml:"name" json:"name" validate:"required"`
	Description    string       `yaml:"description" json:"description" validate:"required"`
	Metadata       PlanMetadata `yaml:"metadata" json:"metadata" validate:"required"`
	Free           bool         `yaml:"free" json:"free"`
	PlanUpdateable bool         `yaml:"plan_updateable" json:"plan_updateable"`
}

Plan is a generic struct for a Cloud Foundry service plan http://docs.cloudfoundry.org/services/api.html

type PlanCost

type PlanCost struct {
	Amount map[string]float64 `yaml:"amount" json:"amount" validate:"required"`
	Unit   string             `yaml:"unit" json:"unit" validate:"required"`
}

PlanCost contains an array-of-objects that describes the costs of a service, in what currency, and the unit of measure.

type PlanMetadata

type PlanMetadata struct {
	Bullets     []string   `yaml:"bullets" json:"bullets"`
	Costs       []PlanCost `yaml:"costs" json:"costs"`
	DisplayName string     `yaml:"displayName" json:"displayName"`
}

PlanMetadata contains the plan metadata fields listed in the Cloud Foundry docs: http://docs.cloudfoundry.org/services/catalog-metadata.html#plan-metadata-fields

type RDSDBSecret

type RDSDBSecret struct {
	common.DBConfig `yaml:",inline" validate:"required,dive,required"`
	PlanID          string `yaml:"plan_id" validate:"required"`
}

RDSDBSecret contains the config to connect to a database and the corresponding plan id.

type RDSPlan

type RDSPlan struct {
	Plan                  `yaml:",inline" validate:"required"`
	Adapter               string            `yaml:"adapter" json:"-" validate:"required"`
	InstanceClass         string            `yaml:"instanceClass" json:"-"`
	DbType                string            `yaml:"dbType" json:"-" validate:"required"`
	DbVersion             string            `yaml:"dbVersion" json:"-"`
	LicenseModel          string            `yaml:"licenseModel" json:"-"`
	Tags                  map[string]string `yaml:"tags" json:"-" validate:"required"`
	Redundant             bool              `yaml:"redundant" json:"-"`
	Encrypted             bool              `yaml:"encrypted" json:"-"`
	StorageType           string            `yaml:"storage_type" json:"-"`
	AllocatedStorage      int64             `yaml:"allocatedStorage" json:"-"`
	BackupRetentionPeriod int64             `yaml:"backup_retention_period" json:"-" validate:"required"`
	SubnetGroup           string            `yaml:"subnetGroup" json:"-" validate:"required"`
	SecurityGroup         string            `yaml:"securityGroup" json:"-" validate:"required"`
	ApprovedMajorVersions []string          `yaml:"approvedMajorVersions" json:"-"`
}

RDSPlan inherits from a Plan and adds fields specific to AWS. these fields are read from the catalog.yaml file, but are not rendered in the catalog API endpoint.

func (RDSPlan) CheckVersion

func (p RDSPlan) CheckVersion(version string) bool

CheckVersion verifies that a specific version chosen by the user for a new RDS instances is valid and supported in the chosen plan.

type RDSSecret

type RDSSecret struct {
	ServiceID    string        `yaml:"service_id" validate:"required"`
	RDSDBSecrets []RDSDBSecret `yaml:"plans" validate:"required,dive,required"`
}

RDSSecret is a wrapper for all the RDS Secrets. Only contains RDS database secrets as of now.

type RDSService

type RDSService struct {
	Service `yaml:",inline" validate:"required"`
	Plans   []RDSPlan `yaml:"plans" json:"plans" validate:"required,dive,required"`
}

RDSService describes the RDS Service. It contains the basic Service details as well as a list of RDS Plans

func (RDSService) FetchPlan

func (s RDSService) FetchPlan(planID string) (RDSPlan, response.Response)

FetchPlan will look for a specific RDS Plan based on the plan ID.

type RDSSetting

type RDSSetting struct {
	DB     *gorm.DB
	Config common.DBConfig
}

RDSSetting is the wrapper for

type RDSSettings

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

RDSSettings is a wrapper for all the resources loaded / instantiated.

func InitRDSSettings

func InitRDSSettings(secrets *Secrets) (*RDSSettings, error)

InitRDSSettings tries to construct all the RDSSettings based on the received secrets.

func (*RDSSettings) AddRDSSetting

func (s *RDSSettings) AddRDSSetting(rdsSetting *RDSSetting, planID string)

AddRDSSetting adds an RDSSetting to the map of RDSSettings with the planID being the key.

func (*RDSSettings) GetRDSSettingByPlan

func (s *RDSSettings) GetRDSSettingByPlan(planID string) (*RDSSetting, error)

GetRDSSettingByPlan retrieves the RDS setting based on its planID.

type RedisDBSecret

type RedisDBSecret struct {
	common.DBConfig `yaml:",inline" validate:"required,dive,required"`
	PlanID          string `yaml:"plan_id" validate:"required"`
}

RedisDBSecret contains the config to connect to a database and the corresponding plan id.

type RedisPlan

type RedisPlan struct {
	Plan                       `yaml:",inline" validate:"required"`
	Tags                       map[string]string `yaml:"tags" json:"-" validate:"required"`
	EngineVersion              string            `yaml:"engineVersion" json:"-"`
	SubnetGroup                string            `yaml:"subnetGroup" json:"-" validate:"required"`
	SecurityGroup              string            `yaml:"securityGroup" json:"-" validate:"required"`
	CacheNodeType              string            `yaml:"nodeType" json:"-" validate:"required"`
	NumCacheClusters           int               `yaml:"numberCluster" json:"-" validate:"required"`
	PreferredMaintenanceWindow string            `yaml:"preferredMaintenanceWindow" json:"-" validate:"required"`
	SnapshotWindow             string            `yaml:"snapshotWindow" json:"-" validate:"required"`
	SnapshotRetentionLimit     int               `yaml:"snapshotRetentionLimit" json:"-"`
	AutomaticFailoverEnabled   bool              `yaml:"automaticFailoverEnabled" json:"-"`
	ApprovedMajorVersions      []string          `yaml:"approvedMajorVersions" json:"-"`
}

RedisPlan inherits from a plan and adds fields needed for AWS Redis.

func (RedisPlan) CheckVersion

func (p RedisPlan) CheckVersion(version string) bool

CheckVersion verifies that a specific version chosen by the user for a new redis instances is valid and supported in the chosen plan.

type RedisSecret

type RedisSecret struct {
	ServiceID      string          `yaml:"service_id" validate:"required"`
	RedisDBSecrets []RedisDBSecret `yaml:"plans" validate:"required,dive,required"`
}

RedisSecret is a wrapper for all the Redis Secrets. Only contains RDS database secrets as of now.

type RedisService

type RedisService struct {
	Service `yaml:",inline" validate:"required"`
	Plans   []RedisPlan `yaml:"plans" json:"plans" validate:"required,dive,required"`
}

RedisService describes the Redis Service. It contains the basic Service details as well as a list of Redis Plans

func (RedisService) FetchPlan

func (s RedisService) FetchPlan(planID string) (RedisPlan, response.Response)

FetchPlan will look for a specific RedisSecret Plan based on the plan ID.

type Resources

type Resources struct {
	RdsSettings *RDSSettings
}

Resources contains all the secrets to be used for the catalog.

type Secrets

type Secrets struct {
	RdsSecret   RDSSecret   `yaml:"rds" validate:"required,dive,required"`
	RedisSecret RedisSecret `yaml:"redis" validate:"required,dive,required"`
}

Secrets contains all the secrets for all the services.

func InitSecrets

func InitSecrets(path string) *Secrets

InitSecrets initializes the secrets struct based on the yaml file.

type Service

type Service struct {
	ID          string          `yaml:"id" json:"id" validate:"required"`
	Name        string          `yaml:"name" json:"name" validate:"required"`
	Description string          `yaml:"description" json:"description" validate:"required"`
	Bindable    bool            `yaml:"bindable" json:"bindable" validate:"required"`
	Tags        []string        `yaml:"tags" json:"tags" validate:"required"`
	Metadata    ServiceMetadata `yaml:"metadata" json:"metadata" validate:"required"`
}

Service struct contains data for the Cloud Foundry service http://docs.cloudfoundry.org/services/api.html

type ServiceMetadata

type ServiceMetadata struct {
	DisplayName         string `yaml:"displayName" json:"displayName"`
	ImageURL            string `yaml:"imageUrl" json:"imageUrl"`
	LongDescription     string `yaml:"longDescription" json:"longDescription"`
	ProviderDisplayName string `yaml:"providerDisplayName" json:"providerDisplayName"`
	DocumentationURL    string `yaml:"documentationUrl" json:"documentationUrl"`
	SupportURL          string `yaml:"supportUrl" json:"supportUrl"`
	Shareable           bool   `yaml:"shareable" json:"shareable"`
}

ServiceMetadata contains the service metadata fields listed in the Cloud Foundry docs: http://docs.cloudfoundry.org/services/catalog-metadata.html#services-metadata-fields

Jump to

Keyboard shortcuts

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