diff options
Diffstat (limited to 'action.go')
-rw-r--r-- | action.go | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -6,6 +6,14 @@ import ( "log" ) +type DebosState int + +// Represent the current state of Debos +const ( + Success DebosState = iota + Failed +) + // Mapping from partition name as configured in the image-partition action to // device path for usage by other actions type Partition struct { @@ -27,6 +35,7 @@ type DebosContext struct { Architecture string DebugShell string Origins map[string]string + State DebosState } type Action interface { @@ -35,8 +44,13 @@ type Action interface { PreMachine(context *DebosContext, m *fakemachine.Machine, args *[]string) error PreNoMachine(context *DebosContext) error Run(context *DebosContext) error - Cleanup(context DebosContext) error - PostMachine(context DebosContext) error + // Cleanup() method gets called only if the Run for an action + // was started and in the same machine (host or fake) as Run has run + Cleanup(context *DebosContext) error + PostMachine(context *DebosContext) error + // PostMachineCleanup() gets called for all actions if Pre*Machine() method + // has run for Action. This method is always executed on the host with user's permissions. + PostMachineCleanup(context *DebosContext) error String() string } @@ -55,10 +69,11 @@ func (b *BaseAction) PreMachine(context *DebosContext, args *[]string) error { return nil } -func (b *BaseAction) PreNoMachine(context *DebosContext) error { return nil } -func (b *BaseAction) Run(context *DebosContext) error { return nil } -func (b *BaseAction) Cleanup(context DebosContext) error { return nil } -func (b *BaseAction) PostMachine(context DebosContext) error { return nil } +func (b *BaseAction) PreNoMachine(context *DebosContext) error { return nil } +func (b *BaseAction) Run(context *DebosContext) error { return nil } +func (b *BaseAction) Cleanup(context *DebosContext) error { return nil } +func (b *BaseAction) PostMachine(context *DebosContext) error { return nil } +func (b *BaseAction) PostMachineCleanup(context *DebosContext) error { return nil } func (b *BaseAction) String() string { if b.Description == "" { return b.Action |