Documentation ¶
Index ¶
- Constants
- Variables
- func CalledAs() (executable string, wrapped bool)
- func ServeLifecyclePlugin(impl Lifecycler)
- func ServeVersionsPlugin(impl Versioner)
- type ContainerPort
- type ContainerPorts
- type DockerConfig
- type DockerConfigEntry
- type HostOpts
- type ISCInstance
- type ISCInstances
- func (is ISCInstances) ByPortOffsets() (map[int64]*ISCInstance, error)
- func (is ISCInstances) CalculatePortOffset(start int64) (int64, error)
- func (is ISCInstances) Exists(name string) bool
- func (is ISCInstances) Find(name string) *ISCInstance
- func (is ISCInstances) UsedPortOffset(offset int64) (bool, error)
- type ISCVersion
- type ISCVersions
- func (evs *ISCVersions) AddIfMissing(ev *ISCVersion) bool
- func (evs ISCVersions) Exists(versionString string) bool
- func (evs ISCVersions) Find(versionString string) *ISCVersion
- func (evs ISCVersions) Latest() *ISCVersion
- func (evs ISCVersions) Len() int
- func (evs ISCVersions) Less(i, j int) bool
- func (evs *ISCVersions) Sort()
- func (evs ISCVersions) Swap(i, j int)
- type Lifecycler
- type LifecyclerPlugin
- type LifecyclerRPC
- func (s LifecyclerRPC) AfterInstance(state *isclib.Instance) error
- func (s LifecyclerRPC) AfterStart(instance *ISCInstance) error
- func (s LifecyclerRPC) AfterStop(instance *ISCInstance) error
- func (s LifecyclerRPC) BeforeInstance(state *isclib.Instance) error
- func (s LifecyclerRPC) BeforeRemove(instance *ISCInstance) error
- func (s LifecyclerRPC) Copies(version string, flagValues map[string]interface{}) ([]string, error)
- func (s LifecyclerRPC) Environment(version string, flagValues map[string]interface{}) ([]string, error)
- func (s LifecyclerRPC) Flags() (PluginFlags, error)
- func (s LifecyclerRPC) Ports(version string, flagValues map[string]interface{}) ([]string, error)
- func (s LifecyclerRPC) Volumes(version string, flagValues map[string]interface{}) ([]string, error)
- func (s LifecyclerRPC) WithInstance(state *isclib.Instance) error
- type LifecyclerRPCServer
- func (s *LifecyclerRPCServer) AfterInstance(state *isclib.Instance, resp *struct{}) (err error)
- func (s *LifecyclerRPCServer) AfterStart(instance *ISCInstance, resp *struct{}) (err error)
- func (s *LifecyclerRPCServer) AfterStop(instance *ISCInstance, resp *struct{}) (err error)
- func (s *LifecyclerRPCServer) BeforeInstance(state *isclib.Instance, resp *struct{}) (err error)
- func (s *LifecyclerRPCServer) BeforeRemove(instance *ISCInstance, resp *struct{}) (err error)
- func (s *LifecyclerRPCServer) Copies(opts HostOpts, resp *[]string) (err error)
- func (s *LifecyclerRPCServer) Environment(opts HostOpts, resp *[]string) (err error)
- func (s *LifecyclerRPCServer) Flags(args interface{}, resp *PluginFlags) (err error)
- func (s *LifecyclerRPCServer) Ports(opts HostOpts, resp *[]string) (err error)
- func (s *LifecyclerRPCServer) Volumes(opts HostOpts, resp *[]string) (err error)
- func (s *LifecyclerRPCServer) WithInstance(state *isclib.Instance, resp *struct{}) (err error)
- type PluginFlag
- type PluginFlags
- type PluginFlagsBuilder
- type Versioner
- type VersionerPlugin
- type VersionerRPC
- type VersionerRPCServer
Constants ¶
const ( ApplicationName = "iscenv" PortInternalSS = 1972 PortExternalSS = 56772 EnvInternalSS = "ISC_SUPERSERVER_PORT" PortInternalWeb = 57772 PortExternalWeb = 57772 EnvInternalWeb = "ISC_HTTP_PORT" PortInternalHC = 59772 PortExternalHC = 59772 EnvInternalHC = "ISCENV_HEALTHCHECK_PORT" // TODO: These should be defaults and should be configurable with viper DockerSocket = "unix:///var/run/docker.sock" ContainerPrefix = ApplicationName + "-" InternalISCEnvBinaryDir = "/bin" InternalISCEnvPath = InternalISCEnvBinaryDir + "/iscenv" // EnvInternalContainer is the environment variable we set for every container we start. // Later we can check if it has a value to know if we started with iscenv. EnvInternalContainer = "ISCENV_CONTAINER" )
Constants for use with the iscenv application
const (
LifecyclerKey = "lifecycle"
)
Constants for lifecycler plugins
const (
VersionerKey = "versions"
)
Constants for versioner plugins
Variables ¶
var PluginHandshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "ISCENV_PLUGIN",
MagicCookieValue: "activate",
}
PluginHandshake is the handshake config used with plugins
var Version string
Version This version number will be injected by the build system based on the Mercurial tags on the repository
var ( // WrappedCommands are commands that when iscenv is called but renamed (or linked) to one of these names it will attempt to mimic // the command inside the container as closely as possible. WrappedCommands = []string{"ccontrol", "csession", "iris"} )
Functions ¶
func ServeLifecyclePlugin ¶
func ServeLifecyclePlugin(impl Lifecycler)
ServeLifecyclePlugin serves a life cycle plugin
func ServeVersionsPlugin ¶
func ServeVersionsPlugin(impl Versioner)
ServeVersionsPlugin serves a versioner plugin
Types ¶
type ContainerPort ¶
type ContainerPort int64
ContainerPort is a int64 representation of a port in a container
func (ContainerPort) String ¶
func (p ContainerPort) String() string
String returns a string representing the ContainerPort
type ContainerPorts ¶
type ContainerPorts struct { SuperServer ContainerPort Web ContainerPort HealthCheck ContainerPort }
ContainerPorts is a listing of the ContainerPorts of the container
type DockerConfig ¶
type DockerConfig struct { Path string Entries map[string]DockerConfigEntry }
DockerConfig is the contents of a docker ocnfiguration file
type DockerConfigEntry ¶
DockerConfigEntry is a single entry from a docker configuration file
func (DockerConfigEntry) Credentials ¶
func (dce DockerConfigEntry) Credentials() (user string, pass string, err error)
Credentials parses the credentials from this entry
type HostOpts ¶
HostOpts represents information that is needed to be passed by the client to a plugin for container management
type ISCInstance ¶
type ISCInstance struct { ID string Name string Version string Created int64 Status string Ports ContainerPorts }
ISCInstance represents information about an instance of an ISC product instance
func (ISCInstance) PortOffset ¶
func (i ISCInstance) PortOffset() (offset int64, err error)
PortOffset finds and returns the port offset for the instance
type ISCInstances ¶
type ISCInstances []*ISCInstance
ISCInstances is a slice of ISCInstance
func (ISCInstances) ByPortOffsets ¶
func (is ISCInstances) ByPortOffsets() (map[int64]*ISCInstance, error)
ByPortOffsets returns a map of ISCInstance indexed by their port offsets
func (ISCInstances) CalculatePortOffset ¶
func (is ISCInstances) CalculatePortOffset(start int64) (int64, error)
CalculatePortOffset returns the next available port offset
func (ISCInstances) Exists ¶
func (is ISCInstances) Exists(name string) bool
Exists returns whether an instance exists with the provided name
func (ISCInstances) Find ¶
func (is ISCInstances) Find(name string) *ISCInstance
Find returns the corresponding ISCInstance for the name string provided
func (ISCInstances) UsedPortOffset ¶
func (is ISCInstances) UsedPortOffset(offset int64) (bool, error)
UsedPortOffset returns whether a port offset is currently in use
type ISCVersion ¶
ISCVersion represent data related to a version of an ISC product
type ISCVersions ¶
type ISCVersions []*ISCVersion
ISCVersions is a slice of ISCVersion
func (*ISCVersions) AddIfMissing ¶
func (evs *ISCVersions) AddIfMissing(ev *ISCVersion) bool
AddIfMissing adds a version to the list if it isn't already included
func (ISCVersions) Exists ¶
func (evs ISCVersions) Exists(versionString string) bool
Exists returns whether the provided version exists in the list
func (ISCVersions) Find ¶
func (evs ISCVersions) Find(versionString string) *ISCVersion
Find finds and returns the ISCVersion for the provided version string
func (ISCVersions) Latest ¶
func (evs ISCVersions) Latest() *ISCVersion
Latest finds and returns the last version in the list
func (ISCVersions) Less ¶
func (evs ISCVersions) Less(i, j int) bool
Less returns whether version in one index is less than the version in the other index
func (ISCVersions) Swap ¶
func (evs ISCVersions) Swap(i, j int)
Swap interchanges two versions in the list
type Lifecycler ¶
type Lifecycler interface { // Runs on host - Returns an array of additional flags to add to the start command. These flags will be passed to the remaining *external* plugin hooks. Plugin hooks within the container are expected to depend upon environment variables or volumes configured by the host hooks. Flags() (PluginFlags, error) // Returns an array of docker API formatted environment variables (ENV_VAR=value) which will be added to the instance Environment(version string, flagValues map[string]interface{}) ([]string, error) // Returns an array of items to copy to the container in the format "src:dest" Copies(version string, flagValues map[string]interface{}) ([]string, error) // Returns an array of volumes to add where the string is a standard docker volume format "src:dest:flag" Volumes(version string, flagValues map[string]interface{}) ([]string, error) // Additional ports to map in the format <optional hostIP>:hostPort:containerPort. You may also prefix the host port with a + to indicate it should be shifted by the port offset Ports(version string, flagValues map[string]interface{}) ([]string, error) // Will run on the host after the container instance starts, receives the same flag values as start AfterStart(instance *ISCInstance) error // Will run within the container before the instance successfully starts BeforeInstance(state *isclib.Instance) error // Will run within the container after the instance starts WithInstance(state *isclib.Instance) error // Will run within the container after the instance stops AfterInstance(state *isclib.Instance) error // Will run on the host after the instance stops AfterStop(instance *ISCInstance) error // Will run on the host before the instance is removed BeforeRemove(instance *ISCInstance) error }
Lifecycler is an interface for plugins that is executed during instance starts
type LifecyclerPlugin ¶
type LifecyclerPlugin struct { // The actual implementation of the plugin. This will be unset on the client side Plugin Lifecycler }
LifecyclerPlugin is the actual plugin interface needed by go-plugin. It's a little strange in that it has both the client and server sides in the same interface.
func (LifecyclerPlugin) Client ¶
func (LifecyclerPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
Client is the client side of the plugin RPC
func (LifecyclerPlugin) Server ¶
func (s LifecyclerPlugin) Server(*plugin.MuxBroker) (interface{}, error)
Server is the server side of the plugin RPC
type LifecyclerRPC ¶
type LifecyclerRPC struct {
// contains filtered or unexported fields
}
LifecyclerRPC is the client (primary executable) RPC-based implementation of the interface
func (LifecyclerRPC) AfterInstance ¶
func (s LifecyclerRPC) AfterInstance(state *isclib.Instance) error
AfterInstance is the client side of the plugin interface
func (LifecyclerRPC) AfterStart ¶
func (s LifecyclerRPC) AfterStart(instance *ISCInstance) error
AfterStart is the client side of the plugin interface
func (LifecyclerRPC) AfterStop ¶
func (s LifecyclerRPC) AfterStop(instance *ISCInstance) error
AfterStop is the client side of the plugin interface
func (LifecyclerRPC) BeforeInstance ¶
func (s LifecyclerRPC) BeforeInstance(state *isclib.Instance) error
BeforeInstance is the client side of the plugin interface
func (LifecyclerRPC) BeforeRemove ¶
func (s LifecyclerRPC) BeforeRemove(instance *ISCInstance) error
BeforeRemove is the client side of the plugin interface
func (LifecyclerRPC) Copies ¶
func (s LifecyclerRPC) Copies(version string, flagValues map[string]interface{}) ([]string, error)
Copies is the client side of the plugin interface
func (LifecyclerRPC) Environment ¶
func (s LifecyclerRPC) Environment(version string, flagValues map[string]interface{}) ([]string, error)
Environment is the client side of the plugin interface
func (LifecyclerRPC) Flags ¶
func (s LifecyclerRPC) Flags() (PluginFlags, error)
Flags returns an array of additional flags to add to the start command The logger is intentionally not passed to this method as logging cannot yet be configured during the flag setup...
func (LifecyclerRPC) Ports ¶
func (s LifecyclerRPC) Ports(version string, flagValues map[string]interface{}) ([]string, error)
Ports is the client side of the plugin interface
func (LifecyclerRPC) Volumes ¶
func (s LifecyclerRPC) Volumes(version string, flagValues map[string]interface{}) ([]string, error)
Volumes is the client side of the plugin interface
func (LifecyclerRPC) WithInstance ¶
func (s LifecyclerRPC) WithInstance(state *isclib.Instance) error
WithInstance is the client side of the plugin interface
type LifecyclerRPCServer ¶
type LifecyclerRPCServer struct{ Plugin Lifecycler }
LifecyclerRPCServer is the server (plugin side) RPC wrapper around the concrete plugin implementation
func (*LifecyclerRPCServer) AfterInstance ¶
func (s *LifecyclerRPCServer) AfterInstance(state *isclib.Instance, resp *struct{}) (err error)
AfterInstance is the server side of the plugin interface
func (*LifecyclerRPCServer) AfterStart ¶
func (s *LifecyclerRPCServer) AfterStart(instance *ISCInstance, resp *struct{}) (err error)
AfterStart is the server side of the plugin interface
func (*LifecyclerRPCServer) AfterStop ¶
func (s *LifecyclerRPCServer) AfterStop(instance *ISCInstance, resp *struct{}) (err error)
AfterStop is the server side of the plugin interface
func (*LifecyclerRPCServer) BeforeInstance ¶
func (s *LifecyclerRPCServer) BeforeInstance(state *isclib.Instance, resp *struct{}) (err error)
BeforeInstance is the server side of the plugin interface
func (*LifecyclerRPCServer) BeforeRemove ¶
func (s *LifecyclerRPCServer) BeforeRemove(instance *ISCInstance, resp *struct{}) (err error)
BeforeRemove is the server side of the plugin interface
func (*LifecyclerRPCServer) Copies ¶
func (s *LifecyclerRPCServer) Copies(opts HostOpts, resp *[]string) (err error)
Copies is the server side of the plugin interface
func (*LifecyclerRPCServer) Environment ¶
func (s *LifecyclerRPCServer) Environment(opts HostOpts, resp *[]string) (err error)
Environment is the server side of the plugin interface
func (*LifecyclerRPCServer) Flags ¶
func (s *LifecyclerRPCServer) Flags(args interface{}, resp *PluginFlags) (err error)
Flags is the server side of the plugin interface
func (*LifecyclerRPCServer) Ports ¶
func (s *LifecyclerRPCServer) Ports(opts HostOpts, resp *[]string) (err error)
Ports is the server side of the plugin interface
func (*LifecyclerRPCServer) Volumes ¶
func (s *LifecyclerRPCServer) Volumes(opts HostOpts, resp *[]string) (err error)
Volumes is the server side of the plugin interface
func (*LifecyclerRPCServer) WithInstance ¶
func (s *LifecyclerRPCServer) WithInstance(state *isclib.Instance, resp *struct{}) (err error)
WithInstance is the server side of the plugin interface
type PluginFlag ¶
PluginFlag represents information about a flag that is for use with a plugin
func NewPluginFlag ¶
func NewPluginFlag(flag string, hasConfig bool, defaultValue interface{}, usage string) *PluginFlag
NewPluginFlag creates and returns an initialized PluginFlag
type PluginFlags ¶
type PluginFlags struct {
Flags map[string]*PluginFlag
}
PluginFlags is a slice of PluginFlag
func NewPluginFlags ¶
func NewPluginFlags() PluginFlags
NewPluginFlags creates and returns an empty map of PluginFlag
type PluginFlagsBuilder ¶
type PluginFlagsBuilder struct {
// contains filtered or unexported fields
}
PluginFlagsBuilder holds the flags for a plugin and any errors that have occurred
func NewPluginFlagsBuilder ¶
func NewPluginFlagsBuilder() *PluginFlagsBuilder
NewPluginFlagsBuilder creates a new instance of object meant to assist plugins in building flags
func (*PluginFlagsBuilder) AddFlag ¶
func (builder *PluginFlagsBuilder) AddFlag(flag string, hasConfig bool, defaultValue interface{}, usage string)
AddFlag adds a flag to list of flags on the PluginFlagsBuilder
func (*PluginFlagsBuilder) Flags ¶
func (builder *PluginFlagsBuilder) Flags() (PluginFlags, error)
Flags returns the list of flags and any errors that were encountered
type Versioner ¶
type Versioner interface { // Find the versions available for the provided image Versions(image string) (ISCVersions, error) }
Versioner is an interface that describes a plugin which can find versions for iscenv
type VersionerPlugin ¶
type VersionerPlugin struct { // The actual implementation of the plugin. This will be unset on the client side Plugin Versioner }
VersionerPlugin is the actual plugin interface needed by go-plugin. It's a little strange in that it has both the client and server sides in the same interface.
func (VersionerPlugin) Client ¶
func (VersionerPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
Client is the client side of the plugin RPC
func (VersionerPlugin) Server ¶
func (v VersionerPlugin) Server(*plugin.MuxBroker) (interface{}, error)
Server is the server side of the plugin RPC
type VersionerRPC ¶
type VersionerRPC struct {
// contains filtered or unexported fields
}
VersionerRPC is the client (primary executable) RPC-based implementation of the interface
func (VersionerRPC) Versions ¶
func (v VersionerRPC) Versions(image string) (ISCVersions, error)
Versions is the client side of the plugin interface
type VersionerRPCServer ¶
type VersionerRPCServer struct{ Plugin Versioner }
VersionerRPCServer is the server (plugin side) RPC wrapper around the concrete plugin implementation
func (*VersionerRPCServer) Versions ¶
func (v *VersionerRPCServer) Versions(image string, resp *ISCVersions) (err error)
Versions is the server side of the plugin interface