effects¶
Package effects provides the default implementation of actions.Performer — mode-aware filesystem and command primitives used by action handlers.
Spec 16 (docs-working/specs/done/spec-16-unify-dryrun-execute.md) collapses each handler's parallel Execute / DryRun / Check methods into a single Run(ctx, step) method. Inside Run, handlers call Performer methods instead of os.* directly. The Performer consults the current mode and either performs the side effect (ModeApply) or returns a prediction (ModePlan).
Index¶
- func NewPerformer(modeFn ModeFunc, sudoPass string, passwordlessSudo bool, asUser string) actions.Performer
- func ShellQuote(s string) string
- type ContentDiff
- type ModeFunc
func NewPerformer¶
func NewPerformer(modeFn ModeFunc, sudoPass string, passwordlessSudo bool, asUser string) actions.Performer
NewPerformer constructs an actions.Performer that performs real filesystem operations in ModeApply and inspects state in ModePlan. modeFn is called once per primitive to decide the path; sudoPass is consulted when escalation is needed; passwordlessSudo lets a NOPASSWD operator skip configuring a password — runSudo then uses `sudo -n`. asUser is the step's bound AsUser (spec-72 Layer C): empty → no escalation, "root"/"0" → sudo to root, "\<name>" → sudo to root + post-write chown to \<name>.
func ShellQuote¶
ShellQuote single-quotes a string for safe POSIX-shell interpolation. Embedded single quotes are escaped via the standard `'\”` idiom. Exported so handlers reaching for `sudo sh -c \<cmd>` can construct safe commands without re-implementing the quoting (F032).
Go's `%q` verb is NOT a substitute — it escapes for Go-string syntax, not POSIX-shell syntax, and leaves $(...) / backtick substitution active inside double quotes.
type ContentDiff¶
ContentDiff is a small structured summary attached to Effect.Detail for WriteFile when content would change.
type ContentDiff struct {
OldSize int `json:"old_size"`
NewSize int `json:"new_size"`
OldHash string `json:"old_hash"`
NewHash string `json:"new_hash"`
// UnifiedDiff is the unified diff text. Empty for binary files or new files.
UnifiedDiff string `json:"unified_diff,omitempty"`
}
type ModeFunc¶
ModeFunc returns the current actions.Mode. The Performer calls it on each operation so callers can swap modes between calls (rare; typically pinned per execution context).
Generated by gomarkdoc