Documentation ¶
Index ¶
- Constants
- func Docs(pack string) error
- func Info(pack string) error
- func Init(directory string) error
- func Pack(directory string) (string, error)
- func RegisterAll(registry broker.BrokerRegistry) error
- func RunExamples(pack string) error
- func Validate(pack string) error
- type BrokerPakReader
- type BrokerpakSourceConfig
- type Manifest
- type ManifestParameter
- type Platform
- type Registrar
- type ServerConfig
- type TerraformResource
Examples ¶
Constants ¶
const HashicorpUrlTemplate = "https://releases.hashicorp.com/${name}/${version}/${name}_${version}_${os}_${arch}.zip"
HashicorpUrlTemplate holds the default template for Hashicorp's terraform binary archive downloads.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init initializes a new brokerpak in the given directory with an example manifest and service definition.
func Pack ¶
Pack creates a new brokerpak from the given directory which MUST contain a manifest.yml file. If the pack was successful, the returned string will be the path to the created brokerpak.
func RegisterAll ¶
func RegisterAll(registry broker.BrokerRegistry) error
RegisterAll fetches all brokerpaks from the settings file and registers them with the given registry.
func RunExamples ¶
RunExamples executes the examples from a brokerpak.
Types ¶
type BrokerPakReader ¶
type BrokerPakReader struct {
// contains filtered or unexported fields
}
BrokerPakReader reads bundled together Terraform and service definitions.
func DownloadAndOpenBrokerpak ¶
func DownloadAndOpenBrokerpak(pakUri string) (*BrokerPakReader, error)
DownloadAndOpenBrokerpak downloads a (potentially remote) brokerpak to the local filesystem and opens it.
func OpenBrokerPak ¶
func OpenBrokerPak(pakPath string) (*BrokerPakReader, error)
Opens the file at the given path as a BrokerPakReader.
func (*BrokerPakReader) Close ¶
func (pak *BrokerPakReader) Close() error
Close closes the underlying reader for the BrokerPakReader.
func (*BrokerPakReader) ExtractPlatformBins ¶
func (pak *BrokerPakReader) ExtractPlatformBins(destination string) error
ExtractPlatformBins extracts the binaries for the current platform to the given destination.
func (*BrokerPakReader) Manifest ¶
func (pak *BrokerPakReader) Manifest() (*Manifest, error)
Manifest fetches the manifest out of the package.
func (*BrokerPakReader) Services ¶
func (pak *BrokerPakReader) Services() ([]tf.TfServiceDefinitionV1, error)
Services gets the list of services included in the pack.
func (*BrokerPakReader) Validate ¶
func (pak *BrokerPakReader) Validate() error
Validate checks the manifest and service definitions for syntactic and limited semantic errors.
type BrokerpakSourceConfig ¶
type BrokerpakSourceConfig struct { // BrokerpakUri holds the URI for loading the Brokerpak. BrokerpakUri string `json:"uri" validate:"required,uri"` // ServicePrefix holds an optional prefix that will be prepended to every service name. ServicePrefix string `json:"service_prefix" validate:"omitempty,osbname"` // ExcludedServices holds a newline delimited list of service UUIDs that will be excluded at registration time. ExcludedServices string `json:"excluded_services"` // Config holds the configuration options for the Brokerpak as a JSON object. Config string `json:"config" validate:"required,json"` // Notes holds user-defined notes about the Brokerpak and shouldn't be used programatically. Notes string `json:"notes"` }
BrokerpakSourceConfig represents a single configuration of a brokerpak.
func NewBrokerpakSourceConfigFromPath ¶
func NewBrokerpakSourceConfigFromPath(path string) BrokerpakSourceConfig
NewBrokerpakSourceConfigFromPath creates a new BrokerpakSourceConfig from a path.
func (*BrokerpakSourceConfig) ExcludedServicesSlice ¶
func (b *BrokerpakSourceConfig) ExcludedServicesSlice() []string
ExcludedServicesSlice gets the ExcludedServices as a slice of UUIDs.
Example ¶
cfg := BrokerpakSourceConfig{ExcludedServices: "FOO\nBAR"} fmt.Println(cfg.ExcludedServicesSlice())
Output: [FOO BAR]
func (*BrokerpakSourceConfig) SetExcludedServices ¶
func (b *BrokerpakSourceConfig) SetExcludedServices(services []string)
SetExcludedServices sets the ExcludedServices from a slice of UUIDs.
Example ¶
cfg := BrokerpakSourceConfig{} cfg.SetExcludedServices([]string{"plan1", "plan2"}) fmt.Println("slice:", cfg.ExcludedServicesSlice()) fmt.Println("text:", cfg.ExcludedServices)
Output: slice: [plan1 plan2] text: plan1 plan2
type Manifest ¶
type Manifest struct { // Package metadata PackVersion int `yaml:"packversion" validate:"required,eq=1"` // User modifiable values Name string `yaml:"name" validate:"required"` Version string `yaml:"version" validate:"required"` Metadata map[string]string `yaml:"metadata"` Platforms []Platform `yaml:"platforms" validate:"required,dive"` TerraformResources []TerraformResource `yaml:"terraform_binaries" validate:"required,dive"` ServiceDefinitions []string `yaml:"service_definitions" validate:"required"` Parameters []ManifestParameter `yaml:"parameters" validate:"dive"` }
func NewExampleManifest ¶
func NewExampleManifest() Manifest
NewExampleManifest creates a new manifest with sample values for the service broker suitable for giving a user a template to manually edit.
func (*Manifest) AppliesToCurrentPlatform ¶
AppliesToCurrentPlatform returns true if the one of the platforms in the manifest match the current GOOS and GOARCH.
type ManifestParameter ¶
type ManifestParameter struct { // NOTE: Future fields should take inspiration from the CNAB spec because they // solve a similar problem. https://github.com/deislabs/cnab-spec Name string `yaml:"name" validate:"required"` Description string `yaml:"description" validate:"required"` }
ManifestParameter holds environment variables that will be looked up and passed to the executed Terraform instance.
type Platform ¶
type Platform struct { Os string `yaml:"os" validate:"required"` Arch string `yaml:"arch" validate:"required"` }
Platform holds an os/architecture pair.
func CurrentPlatform ¶
func CurrentPlatform() Platform
CurrentPlatform returns the platform defined by GOOS and GOARCH.
func (Platform) Equals ¶
Equals is an equality test between this platform and the other.
Example ¶
p := Platform{Os: "beos", Arch: "webasm"} fmt.Println(p.Equals(p)) fmt.Println(p.Equals(CurrentPlatform()))
Output: true false
func (Platform) MatchesCurrent ¶
MatchesCurrent returns true if the platform matches this binary's GOOS/GOARCH combination.
Example ¶
fmt.Println(CurrentPlatform().MatchesCurrent())
Output: true
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar is responsible for registering brokerpaks with BrokerRegistries subject to the settings provided by a ServerConfig like injecting environment variables and skipping certain services.
func NewRegistrar ¶
func NewRegistrar(sc *ServerConfig) *Registrar
NewRegistrar constructs a new registrar with the given configuration. Registrar expects to become the owner of the configuration afterwards.
type ServerConfig ¶
type ServerConfig struct { // Config holds global configuration options for the Brokerpak as a JSON object. Config string `validate:"required,json"` // Brokerpaks holds list of brokerpaks to load. Brokerpaks map[string]BrokerpakSourceConfig `validate:"dive,keys,osbname,endkeys,dive"` }
ServerConfig holds the Brokerpak configuration for the server.
func NewServerConfigFromEnv ¶
func NewServerConfigFromEnv() (*ServerConfig, error)
NewServerConfigFromEnv loads the global Brokerpak config from Viper.
Example ¶
viper.Set("brokerpak.sources", `{"good-key":{"uri":"file://path/to/brokerpak", "config":"{}"}}`) viper.Set("brokerpak.config", `{}`) defer viper.Reset() // cleanup cfg, err := NewServerConfigFromEnv() if err != nil { panic(err) } fmt.Println("global config:", cfg.Config) fmt.Println("num services:", len(cfg.Brokerpaks))
Output: global config: {} num services: 1
func (*ServerConfig) Validate ¶
func (cfg *ServerConfig) Validate() error
Validate returns an error if the configuration is invalid.
type TerraformResource ¶
type TerraformResource struct { // Name holds the name of this resource. e.g. terraform-provider-google-beta Name string `yaml:"name" validate:"required"` // Version holds the version of the resource e.g. 1.19.0 Version string `yaml:"version" validate:"required"` // Source holds the URI of an archive that contains the source code for this release. Source string `yaml:"source" validate:"required"` // UrlTemplate holds a custom URL template to get the release of the given tool. // Paramaters available are ${name}, ${version}, ${os}, and ${arch}. // If non is specified HashicorpUrlTemplate is used. UrlTemplate string `yaml:"url_template,omitempty"` }
TerraformResource represents a downloadable binary dependency (Terraform version or Provider).
func (*TerraformResource) Url ¶
func (tr *TerraformResource) Url(platform Platform) string
Url constructs a download URL based on a platform.