Skip to content

Commit

Permalink
Added documentation for the skipping actions due non-supported context
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <[email protected]>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 11, 2024
1 parent 692bafe commit 5f70ab6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ var _ = events.Register(
)
```

### Handling Unsupported Contexts/Prerequisites

When developing actions for the event-generator, it's essential to consider whether the action is applicable to the current execution context. For example, certain actions might be intended to run exclusively within containers or specific environments. Actions that require a specific context or prerequisite to execute successfully should skip the action by return events.ErrSkipped when the necessary conditions are not met For example:

```golang
func UserMgmtBinaries(h events.Helper) error {
if h.InContainer() {
return &events.ErrSkipped{
Reason: "'User mgmt binaries' is excluded in containers",
}
}
return h.SpawnAsWithSymlink("vipw", "helper.ExecLs")
}
```

### Behavior
Running an *action* should be an idempotent operation in the sense that it should not have additional effects if it is called more than once.
For this reason, *actions* should revert any operation that changed the state of the system (eg. if a file is created, then it has to be removed). For example:
Expand Down

0 comments on commit 5f70ab6

Please sign in to comment.