Documentation
¶
Index ¶
- func Contains(slice []string, item string) bool
- func DryRunActions[B any, R any](actions []Action[B, R], nilResultFactory func(action Action[B, R]) R, ...) []R
- func ExecuteActions[B any, R any](ctx context.Context, actions []Action[B, R], ...) []R
- func UniqueNonEmpty(refs []string) []string
- type Action
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DryRunActions ¶
func DryRunActions[B any, R any]( actions []Action[B, R], nilResultFactory func(action Action[B, R]) R, logFunc func(result *R), ) []R
DryRunActions returns pre-computed results without executing actions. This is used in dry-run mode to show what would happen without making actual changes. For each action, it uses the pre-computed action.Result, handles nil results by calling nilResultFactory, logs the result, and collects all results.
func ExecuteActions ¶
func ExecuteActions[B any, R any]( ctx context.Context, actions []Action[B, R], nilResultFactory func(action Action[B, R]) R, logFunc func(result *R), ) []R
ExecuteActions runs all actions and collects results. For each action, it calls action.Run to execute the operation, handles nil results by calling nilResultFactory, logs the result, and collects all results.
func UniqueNonEmpty ¶
UniqueNonEmpty returns a deduplicated slice of non-empty, trimmed strings preserving the order of first occurrence. Empty and whitespace-only strings are filtered out.
Types ¶
type Action ¶
Action represents a planned operation with deferred execution B is the body type containing the request data R is the result type representing the outcome
func PlanActions ¶
func PlanActions[B any, R any]( ctx context.Context, bodies []B, planner func(ctx context.Context, body *B) Action[B, R], ) []Action[B, R]
PlanActions transforms bodies into actions using the provided planner function. The planner function is called for each body to determine what action should be taken.
func StaticAction ¶
StaticAction creates an action that always returns a pre-computed result This is used for operations that don't need actual execution, such as: - Resources that already exist - Validation errors detected during planning - Operations blocked by previous failures
type Status ¶
type Status string
Status represents the state of a creation operation.
const ( // StatusCreated indicates the resource was successfully created. StatusCreated Status = "Created" // StatusWouldCreate indicates the resource would be created in a real run (dry-run mode). StatusWouldCreate Status = "WouldCreate" // StatusAlreadyExists indicates the resource already exists and no action was taken. StatusAlreadyExists Status = "AlreadyExists" // StatusFailed indicates the operation failed with an error. StatusFailed Status = "Failed" // StatusMembersEnsured indicates members were successfully added to an existing resource. StatusMembersEnsured Status = "MembersEnsured" // StatusWouldEnsureMembers indicates members would be added in a real run (dry-run mode). StatusWouldEnsureMembers Status = "WouldEnsureMembers" // StatusPartiallyEnsured indicates some but not all members were successfully added. StatusPartiallyEnsured Status = "PartiallyEnsured" )