Documentation ¶
Index ¶
- Constants
- func Docs(pack string) error
- func Info(pack string) error
- func Init(directory string) error
- func ListBrokerpaks(directory string) ([]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 ( // BuiltinPakLocation is the file-system location to load brokerpaks from to // make them look builtin. BuiltinPakLocation = "/usr/share/gcp-service-broker/builtin-brokerpaks" )
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 ListBrokerpaks ¶
ListBrokerpaks gets all brokerpaks in a given directory.
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"` // ServicePrefix holds an optional prefix that will be prepended to every service name. ServicePrefix string `json:"service_prefix"` // 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"` // 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
func (*BrokerpakSourceConfig) Validate ¶
func (b *BrokerpakSourceConfig) Validate() (errs *validation.FieldError)
Validate implements validation.Validatable.
type Manifest ¶
type Manifest struct { // Package metadata PackVersion int `yaml:"packversion"` // User modifiable values Name string `yaml:"name"` Version string `yaml:"version"` Metadata map[string]string `yaml:"metadata"` Platforms []Platform `yaml:"platforms"` TerraformResources []TerraformResource `yaml:"terraform_binaries"` ServiceDefinitions []string `yaml:"service_definitions"` Parameters []ManifestParameter `yaml:"parameters"` }
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.
func (*Manifest) Validate ¶
func (m *Manifest) Validate() (errs *validation.FieldError)
Validate will run struct validation on the fields of this manifest.
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"` Description string `yaml:"description"` }
ManifestParameter holds environment variables that will be looked up and passed to the executed Terraform instance.
func (*ManifestParameter) Validate ¶
func (param *ManifestParameter) Validate() (errs *validation.FieldError)
Validate implements validation.Validatable.
type Platform ¶
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
func (Platform) String ¶
String formats the platform as an os/arch pair.
Example ¶
p := Platform{Os: "bsd", Arch: "amd64"} fmt.Println(p.String())
Output: bsd/amd64
func (Platform) Validate ¶
func (p Platform) Validate() (errs *validation.FieldError)
Validate implements validation.Validatable.
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 // Brokerpaks holds list of brokerpaks to load. Brokerpaks map[string]BrokerpakSourceConfig }
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
Example (CustomBuiltin) ¶
viper.Set("brokerpak.sources", `{}`) viper.Set("brokerpak.config", `{}`) viper.Set(brokerpakBuiltinPathKey, "testdata/dummy-brokerpaks") viper.Set("compatibility.enable-builtin-brokerpaks", "true") defer viper.Reset() // cleanup cfg, err := NewServerConfigFromEnv() if err != nil { panic(err) } fmt.Println("num services:", len(cfg.Brokerpaks))
Output: num services: 2
func (*ServerConfig) Validate ¶
func (cfg *ServerConfig) Validate() (errs *validation.FieldError)
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"` // Version holds the version of the resource e.g. 1.19.0 Version string `yaml:"version"` // Source holds the URI of an archive that contains the source code for this release. Source string `yaml:"source"` // 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.
func (*TerraformResource) Validate ¶
func (tr *TerraformResource) Validate() (errs *validation.FieldError)
Validate implements validation.Validatable.