Documentation
¶
Index ¶
- Constants
- Variables
- func DoneHandler(ctx *RunContext, notifier Notifier) error
- func Iif(value string, orValue string) string
- func LoadEvent(eventS string) (*cloudevents.Event, error)
- func NoopHandler(ctx *RunContext, notifier Notifier) error
- func NoopHookCmd(ctx *RunContext) error
- func WriteEvent(event *cloudevents.Event, out io.Writer) error
- type ApiVersion
- type AtkContextKey
- type CliModuleRunner
- type CliParts
- type CmdItr
- type DeployableModule
- func (m *DeployableModule) AddCmd(status State, handler StateCmd) error
- func (m *DeployableModule) GetCmdFor(status State) StateCmd
- func (m *DeployableModule) GetHook(name Hook) HookCmd
- func (m *DeployableModule) IsErrored() bool
- func (m *DeployableModule) Itr() (NextFunc, bool)
- func (m *DeployableModule) Notify(state State) error
- func (m *DeployableModule) NotifyErr(state State, err error)
- func (m *DeployableModule) State() State
- type EnvVarInfo
- type EventData
- type EventDataVarInfo
- type Hook
- type HookCmd
- type HookInfo
- type ImageInfo
- type LifecycleInfo
- type ManifestFileLoader
- type MetadataInfo
- type ModuleEventType
- type ModuleInfo
- type ModuleLoader
- type NextFunc
- type Notifier
- type PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) Build() (string, error)
- func (b *PodmanCliCommandBuilder) BuildFrom(info ImageInfo) (string, error)
- func (b *PodmanCliCommandBuilder) WithEnvvar(name string, value string) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithImage(imageName string) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithPath(path string) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithPort(localport string, containerport string) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithUserMap(localUser int, containerUser int, number int) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithVolume(localdir string, containerdir string) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithVolumeOpt(localdir string, containerdir string, option string) *PodmanCliCommandBuilder
- func (b *PodmanCliCommandBuilder) WithWorkspace(localdir string) *PodmanCliCommandBuilder
- type RunContext
- type SpecInfo
- type State
- type StateCmd
- type StateCmder
- type VolumeInfo
Constants ¶
const ( ListHookResponseEvent ModuleEventType = "com.ibm.techzone.cli.hook.list.response" ValidateHookResponseEvent ModuleEventType = "com.ibm.techzone.cli.hook.validate.response" ValidateHookRequestEvent ModuleEventType = "com.ibm.techzone.cli.hook.validate.request" GetStateHookResponseEvent ModuleEventType = "com.ibm.techzone.cli.hook.get_state.response" GetStateHookRequestEvent ModuleEventType = "com.ibm.techzone.cli.hook.get_state.request" PreDeployLifecycleRequestEvent ModuleEventType = "com.ibm.techzone.cli.lifecycle.pre_deploy.request" DeployLifecycleRequestEvent ModuleEventType = "com.ibm.techzone.cli.lifecycle.deploy.request" PostDeployLifecycleRequestEvent ModuleEventType = "com.ibm.techzone.cli.lifecycle.post_deploy.request" LoggerContextKey AtkContextKey = "atk.logger" StdOutContextKey AtkContextKey = "atk.stdout" StdErrContextKey AtkContextKey = "atk.stderr" BaseDirectory AtkContextKey = "atk.basedir" ListHook Hook = "list" ValidateHook Hook = "validate" GetStateHook Hook = "get_state" )
Variables ¶
var DefaultOrder = []State{ Invalid, Initializing, Configured, Validated, PreDeploying, PreDeployed, Deploying, Deployed, PostDeploying, PostDeployed, Done, }
Functions ¶
func DoneHandler ¶
func DoneHandler(ctx *RunContext, notifier Notifier) error
func NoopHandler ¶
func NoopHandler(ctx *RunContext, notifier Notifier) error
NoopHandler is an implementation of the Null Object pattern. It does nothing except to insure we don't return a nil.
func NoopHookCmd ¶
func NoopHookCmd(ctx *RunContext) error
func WriteEvent ¶ added in v0.1.1
func WriteEvent(event *cloudevents.Event, out io.Writer) error
Types ¶
type ApiVersion ¶
func ParseApiVersion ¶
func ParseApiVersion(val string) (*ApiVersion, error)
ParseApiVersion parses the version of the apiVersion
func (ApiVersion) String ¶
func (a ApiVersion) String() string
type AtkContextKey ¶
type AtkContextKey string
type CliModuleRunner ¶
type CliModuleRunner struct {
PodmanCliCommandBuilder
}
func (*CliModuleRunner) Run ¶
func (r *CliModuleRunner) Run(ctx *RunContext) error
Run runs the container that has been defined in the builder setup.
func (*CliModuleRunner) RunImage ¶
func (r *CliModuleRunner) RunImage(ctx *RunContext, info ImageInfo) error
RunImage runs the container that is defined in the provided ImageInfo
type CliParts ¶
type CliParts struct { Path string Cmd string Image string Flags []string Workdir string VolumeMaps []string DefaultVolumeOpt string Ports map[string]string UidMaps []string Envvars []EnvVarInfo // TODO: Add command support that will be used instead of an entrypoint Commands []string }
CliParts represents the parts of the entire podman command line.
type DeployableModule ¶
type DeployableModule struct {
// contains filtered or unexported fields
}
func NewDeployableModule ¶
func NewDeployableModule(runCtx *RunContext, module *ModuleInfo) *DeployableModule
func (*DeployableModule) AddCmd ¶
func (m *DeployableModule) AddCmd(status State, handler StateCmd) error
func (*DeployableModule) GetCmdFor ¶
func (m *DeployableModule) GetCmdFor(status State) StateCmd
func (*DeployableModule) GetHook ¶
func (m *DeployableModule) GetHook(name Hook) HookCmd
func (*DeployableModule) IsErrored ¶
func (m *DeployableModule) IsErrored() bool
func (*DeployableModule) Itr ¶
func (m *DeployableModule) Itr() (NextFunc, bool)
func (*DeployableModule) Notify ¶
func (m *DeployableModule) Notify(state State) error
func (*DeployableModule) NotifyErr ¶
func (m *DeployableModule) NotifyErr(state State, err error)
func (*DeployableModule) State ¶
func (m *DeployableModule) State() State
type EnvVarInfo ¶
type EnvVarInfo struct { Name string `json:"name" yaml:"name"` Value string `json:"value" yaml:"value"` }
func (*EnvVarInfo) String ¶
func (e *EnvVarInfo) String() string
type EventData ¶ added in v0.1.1
type EventData struct {
Variables []EventDataVarInfo `json:"variables,omitempty" yaml:"variables,omitempty"`
}
func LoadEventData ¶ added in v0.1.1
func LoadEventData(event *cloudevents.Event) (*EventData, error)
type EventDataVarInfo ¶ added in v0.1.1
type HookCmd ¶
type HookCmd func(ctx *RunContext) error
type ImageInfo ¶
type ImageInfo struct { Image string `json:"image" yaml:"image"` Script string `json:"script" yaml:"script"` Command []string `json:"command" yaml:"command"` Args []string `json:"args" yaml:"args"` EnvVars []EnvVarInfo `json:"env" yaml:"env"` Volumes []VolumeInfo `json:"volumeMounts" yaml:"volumeMounts"` }
type LifecycleInfo ¶
type ManifestFileLoader ¶
type ManifestFileLoader struct {
// contains filtered or unexported fields
}
func NewAtkManifestFileLoader ¶
func NewAtkManifestFileLoader() *ManifestFileLoader
func (*ManifestFileLoader) Load ¶
func (l *ManifestFileLoader) Load(uri string) (*ModuleInfo, error)
type MetadataInfo ¶
type ModuleEventType ¶ added in v0.1.1
type ModuleEventType string
type ModuleInfo ¶
type ModuleInfo struct { ApiVersion string `json:"apiVersion" yaml:"apiVersion"` Kind string `json:"kind" yaml:"kind"` Metadata MetadataInfo `json:"metadata" yaml:"metadata"` Specifications SpecInfo `json:"spec" yaml:"spec"` }
func (*ModuleInfo) IsSupported ¶
func (m *ModuleInfo) IsSupported() bool
IsSupported returns true if the manifest file is supported.
func (*ModuleInfo) IsSupportedKind ¶
func (m *ModuleInfo) IsSupportedKind() bool
IsSupportedKind returns true if the kind is supported.
func (*ModuleInfo) IsSupportedVersion ¶
func (m *ModuleInfo) IsSupportedVersion() bool
IsSupportedVersion returns true if apiVersion is supported.
type ModuleLoader ¶
type ModuleLoader interface {
Load(uri string) (ModuleInfo, error)
}
type PodmanCliCommandBuilder ¶
type PodmanCliCommandBuilder struct {
// contains filtered or unexported fields
}
PodmanCliCommandBuilder allows you to build the podman command in a way that is already unit tested and verified so that you do not have to append your own strings or do variable interpolation.
func NewPodmanCliCommandBuilder ¶
func NewPodmanCliCommandBuilder(cli *CliParts) *PodmanCliCommandBuilder
NewPodmanCliCommandBuilder creates a new PodmanCliCommandBuilder with the given configuration. If there is no configuration provided (nil), or if certain values are not defined, then the constructor will provide reasonable defaults.
func (*PodmanCliCommandBuilder) Build ¶
func (b *PodmanCliCommandBuilder) Build() (string, error)
Build builds the command line for the container command
func (*PodmanCliCommandBuilder) BuildFrom ¶
func (b *PodmanCliCommandBuilder) BuildFrom(info ImageInfo) (string, error)
func (*PodmanCliCommandBuilder) WithEnvvar ¶
func (b *PodmanCliCommandBuilder) WithEnvvar(name string, value string) *PodmanCliCommandBuilder
WithEnvvar adds the given environment variable and value to the command. It is the same thing as adding -e ENVAR=value as a parameter to the container command.
func (*PodmanCliCommandBuilder) WithImage ¶
func (b *PodmanCliCommandBuilder) WithImage(imageName string) *PodmanCliCommandBuilder
WithImage specifies the container image used in the command.
func (*PodmanCliCommandBuilder) WithPath ¶
func (b *PodmanCliCommandBuilder) WithPath(path string) *PodmanCliCommandBuilder
WithPath allows you to override the default path of /usr/local/bin/podman for podman.
func (*PodmanCliCommandBuilder) WithPort ¶
func (b *PodmanCliCommandBuilder) WithPort(localport string, containerport string) *PodmanCliCommandBuilder
WithPort adds a port mapping to the command
func (*PodmanCliCommandBuilder) WithUserMap ¶
func (b *PodmanCliCommandBuilder) WithUserMap(localUser int, containerUser int, number int) *PodmanCliCommandBuilder
func (*PodmanCliCommandBuilder) WithVolume ¶
func (b *PodmanCliCommandBuilder) WithVolume(localdir string, containerdir string) *PodmanCliCommandBuilder
WithVolume adds a volume mapping to the command.
func (*PodmanCliCommandBuilder) WithVolumeOpt ¶
func (b *PodmanCliCommandBuilder) WithVolumeOpt(localdir string, containerdir string, option string) *PodmanCliCommandBuilder
WithVolume adds a volume mapping to the command.
func (*PodmanCliCommandBuilder) WithWorkspace ¶
func (b *PodmanCliCommandBuilder) WithWorkspace(localdir string) *PodmanCliCommandBuilder
WithWorkspace is a shortcut to adding a local path to the "workspace" on the container.
type RunContext ¶
type RunContext struct { Context context.Context In io.Reader Out io.Writer Log logger.Logger Err io.Writer Errors []error LastErrCode int }
func (*RunContext) AddError ¶
func (c *RunContext) AddError(err error)
AddError adds an error to the context
func (*RunContext) IsErrored ¶
func (c *RunContext) IsErrored() bool
IsErrored returns true if there are errors in the context
func (*RunContext) Reset ¶
func (c *RunContext) Reset()
func (*RunContext) SetLastErrCode ¶
func (c *RunContext) SetLastErrCode(errCode int)
type SpecInfo ¶
type SpecInfo struct { Hooks HookInfo `json:"hooks" yaml:"hooks"` Lifecycle LifecycleInfo `json:"lifecycle" yaml:"lifecycle"` }
type State ¶
type State string
const ( None State = "none" Invalid State = "invalid" Initializing State = "initializing" Configured State = "configured" Validated State = "validated" PreDeploying State = "predeploying" PreDeployed State = "predeployed" Deploying State = "deploying" Deployed State = "deployed" PostDeploying State = "postdeploying" PostDeployed State = "postdeployed" Done = PostDeployed Errored State = "errored" )
type StateCmd ¶
type StateCmd func(ctx *RunContext, notifier Notifier) error
StateCmd is an implementation of a Command pattern