Documentation ¶
Index ¶
- func AddServiceToRuntime(c Runtime, r recipe.Service) error
- func ApplyRecipeToRuntime(c Runtime, r recipe.Recipe) error
- func ApplyRecipes(st recipe.Stack, rt Runtime, selector []string) error
- func InitFromRecipe(service Service, recipe recipe.Service) error
- func Match(service Service, matcher recipe.Matcher) bool
- func ModifyFromRecipe(service Service, mod recipe.Modification) error
- func ModifyService(stack recipe.Stack, rt Runtime, selectors []string, ...) error
- func PortConvention(instance ServiceInstance, portType string) (int, error)
- func RemoveFlag(command []string, s string) []string
- func Render(r Runtime, serviceInstance ServiceInstance, original string) (string, error)
- func SetFlag(command []string, s string) []string
- type HostResolver
- type MockRuntime
- func (m *MockRuntime) AddService(service recipe.Service) (Service, error)
- func (m *MockRuntime) Get(serviceInstance ServiceInstance, name string) string
- func (m *MockRuntime) GetHost(serviceInstance ServiceInstance, hostType string) string
- func (m *MockRuntime) GetPort(serviceInstance ServiceInstance, portType string) PortMap
- func (m *MockRuntime) GetServices() []Service
- func (m *MockRuntime) Reload(stack recipe.Stack) error
- func (m *MockRuntime) Write() error
- type MockService
- func (m *MockService) AddConfig(key string, value string) error
- func (m *MockService) AddEnvironment(key string, value string) error
- func (m *MockService) AddFlag(flag string) error
- func (m *MockService) AddPortForward(portMap PortMap) error
- func (m *MockService) ChangeImage(f func(string) string) error
- func (m *MockService) GetENV() map[string]*string
- func (m *MockService) GetVolumes() []VolumeMount
- func (m *MockService) ID() ServiceInstance
- func (m *MockService) Labels() []string
- func (m *MockService) Persist(dir string) error
- func (m *MockService) RemoveFlag(flag string) error
- func (m *MockService) RemovePortForward(portMap PortMap) error
- func (m *MockService) UseFile(path string, name string, data string) error
- func (m *MockService) UseFolder(path string, name string) error
- type PortMap
- type PortResolver
- type Runtime
- type Service
- type ServiceInstance
- type VariableGetter
- type VolumeMount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddServiceToRuntime ¶
AddServiceToRuntime helps to create new service in runtime based on a recipe.
func ApplyRecipeToRuntime ¶
ApplyRecipeToRuntime can add all services from recipe and modifies existing ones based on rules.
func ApplyRecipes ¶
ApplyRecipes can apply full recipes and other services (partial recipes) based on the selectors.
func InitFromRecipe ¶
InitFromRecipe can fill standard fields of the service (flags, configs, ...) based on the recipe.
func ModifyFromRecipe ¶
func ModifyFromRecipe(service Service, mod recipe.Modification) error
ModifyFromRecipe applies the modification defined by a recipe to a service.
func ModifyService ¶
func ModifyService(stack recipe.Stack, rt Runtime, selectors []string, f func(service Service) error) error
ModifyService applies a function to all services based on selector.
func PortConvention ¶
func PortConvention(instance ServiceInstance, portType string) (int, error)
PortConvention defines port numbers for any services.
func RemoveFlag ¶
RemoveFlag remove flags based on prefix.
Types ¶
type HostResolver ¶
type HostResolver interface {
GetHost(serviceInstance ServiceInstance, hostType string) string
}
HostResolver helps to find the right hostname (or ip) for a specific service.
type MockRuntime ¶
type MockRuntime struct {
Services []Service
}
MockRuntime is a runtime `implementation` for testing.
func NewMockRuntime ¶
func NewMockRuntime() *MockRuntime
NewMockRuntime creates a runtime for testing.
func (*MockRuntime) AddService ¶
func (m *MockRuntime) AddService(service recipe.Service) (Service, error)
AddService implements runtime.Runtime.
func (*MockRuntime) Get ¶
func (m *MockRuntime) Get(serviceInstance ServiceInstance, name string) string
Get implements runtime.Runtime.
func (*MockRuntime) GetHost ¶
func (m *MockRuntime) GetHost(serviceInstance ServiceInstance, hostType string) string
GetHost implements runtime.Runtime.
func (*MockRuntime) GetPort ¶
func (m *MockRuntime) GetPort(serviceInstance ServiceInstance, portType string) PortMap
GetPort implements runtime.Runtime.
func (*MockRuntime) GetServices ¶
func (m *MockRuntime) GetServices() []Service
GetServices implements runtime.Runtime.
type MockService ¶
type MockService struct { Identifier ServiceInstance Image string Persisted []string Config map[string]string Environment map[string]string Flag []string Ports map[int]int Label []string }
MockService is a service implementation for MockRuntime.
func NewMockService ¶
func NewMockService(name string) *MockService
NewMockService can create a new mock service.
func (*MockService) AddConfig ¶
func (m *MockService) AddConfig(key string, value string) error
AddConfig implements runtime.Service.
func (*MockService) AddEnvironment ¶
func (m *MockService) AddEnvironment(key string, value string) error
AddEnvironment implements runtime.Service.
func (*MockService) AddFlag ¶
func (m *MockService) AddFlag(flag string) error
AddFlag implements runtime.Service.
func (*MockService) AddPortForward ¶
func (m *MockService) AddPortForward(portMap PortMap) error
AddPortForward implements runtime.Service.
func (*MockService) ChangeImage ¶
func (m *MockService) ChangeImage(f func(string) string) error
ChangeImage implements runtime.Service.
func (*MockService) GetENV ¶
func (m *MockService) GetENV() map[string]*string
GetENV implements runtime.Service.
func (*MockService) GetVolumes ¶
func (m *MockService) GetVolumes() []VolumeMount
GetVolumes implements runtime.Service.
func (*MockService) Labels ¶
func (m *MockService) Labels() []string
Labels implements runtime.Service.
func (*MockService) Persist ¶
func (m *MockService) Persist(dir string) error
Persist implements runtime.Service.
func (*MockService) RemoveFlag ¶
func (m *MockService) RemoveFlag(flag string) error
RemoveFlag implements runtime.Service.
func (*MockService) RemovePortForward ¶ added in v1.2.0
func (m *MockService) RemovePortForward(portMap PortMap) error
RemovePortForward implements runtime.Service.
type PortResolver ¶
type PortResolver interface {
GetPort(serviceInstance ServiceInstance, portType string) PortMap
}
PortResolver helps to find the right port number for a specific service.
type Runtime ¶
type Runtime interface { HostResolver PortResolver VariableGetter // AddService creates and adds new service instance based on the recipe. AddService(recipe.Service) (Service, error) Write() error GetServices() []Service Reload(stack recipe.Stack) error }
Runtime provides methods to read/write/modify any existing runtime definition (like compose/nomad/...)
type Service ¶
type Service interface { // ID returns with the unique identifier (including index in case of multiple instances are added from a service) ID() ServiceInstance GetENV() map[string]*string GetVolumes() []VolumeMount // ChangeImage applies transformation to the container image ChangeImage(func(string) string) error // AddConfig adds / changes existing configuration. Use it instead of AddEnvironment to be more generic. AddConfig(key string, value string) error AddFlag(flag string) error RemoveFlag(flag string) error // AddEnvironment registers new environment variable to be used. For normal configs, use AddConfig to be more general. AddEnvironment(key string, value string) error AddPortForward(PortMap) error RemovePortForward(PortMap) error Persist(dir string) error Labels() []string UseFile(path string, name string, data string) error UseFolder(path string, name string) error }
Service is the interface to modify any service.
type ServiceInstance ¶
ServiceInstance is a unique identifier of a service instance.
func NewServiceInstance ¶
func NewServiceInstance(name string, i int) ServiceInstance
NewServiceInstance creates the ID from name and instance identifier (number).
func ServiceInstanceFromIndexedName ¶
func ServiceInstanceFromIndexedName(service string) ServiceInstance
ServiceInstanceFromIndexedName creates ID from string like 'storagenode0'.
func ServiceInstanceFromStr ¶
func ServiceInstanceFromStr(service string) ServiceInstance
ServiceInstanceFromStr parses ServiceInstance from 'storagenode/2' like string expression.
func (ServiceInstance) String ¶
func (i ServiceInstance) String() string
type VariableGetter ¶
type VariableGetter interface {
Get(serviceInstance ServiceInstance, name string) string
}
VariableGetter returns with any custom template variable.
type VolumeMount ¶
VolumeMount defines the type source and target fields when mounting a volume to the container.