Documentation ¶
Overview ¶
Package brokerpak implements the "pak" command and other things
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, cachePath string, includeSource, compress bool, ...) (string, error)
- func RegisterAll(registry broker.BrokerRegistry) error
- func RunExamples(pack string)
- func Validate(pack string) error
- type BrokerpakSourceConfig
- type Registrar
- type ServerConfig
Examples ¶
Constants ¶
const ( // BuiltinPakLocation is the file-system location to load brokerpaks from to // make them look builtin. BuiltinPakLocation = "./" )
const ManifestName = "manifest.yml"
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 ¶
func Pack(directory string, cachePath string, includeSource, compress bool, target platform.Platform) (string, error)
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 ¶
func RunExamples(pack string)
RunExamples executes the examples from a brokerpak.
Types ¶
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 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.