Documentation
¶
Index ¶
- Constants
- Variables
- func GetApproverUserNames(approvers []model.WorkflowApprover) []string
- func GetNotificationRecipients(workflow model.Workflow, transition Transition) []string
- func NewInsufficientApproverCountError(currentCount, requiredCount int) error
- func NewInvalidEventActorError(userID string, expectedRole string) error
- func NewTransitionError(transition Transition) error
- type ActionType
- type ApprovalMechanism
- type ApprovalSummary
- type ArtifactType
- type KeyActions
- type KeyConfigurationActions
- type Lifecycle
- func (l *Lifecycle) ApplyTransition(ctx context.Context, transition Transition) error
- func (l *Lifecycle) AvailableBusinessUserTransitions(ctx context.Context) []Transition
- func (l *Lifecycle) CanTransition(transition Transition) bool
- func (l *Lifecycle) Expire(ctx context.Context) error
- func (l *Lifecycle) GetApprovalSummary(ctx context.Context) (*ApprovalSummary, error)
- func (l *Lifecycle) ValidateActor(ctx context.Context, transition Transition) error
- type ParametersResourceType
- type State
- type SystemActions
- type Transition
Constants ¶
const ( StateInitial State = "INITIAL" StateRevoked State = "REVOKED" StateRejected State = "REJECTED" StateExpired State = "EXPIRED" StateWaitApproval State = "WAIT_APPROVAL" StateWaitConfirmation State = "WAIT_CONFIRMATION" StateExecuting State = "EXECUTING" StateSuccessful State = "SUCCESSFUL" StateFailed State = "FAILED" TransitionCreate Transition = "CREATE" TransitionRevoke Transition = "REVOKE" TransitionReject Transition = "REJECT" TransitionExpire Transition = "EXPIRE" TransitionApprove Transition = "APPROVE" TransitionConfirm Transition = "CONFIRM" TransitionExecute Transition = "EXECUTE" TransitionFail Transition = "FAIL" ArtifactTypeKey ArtifactType = "KEY" ArtifactTypeKeyConfiguration ArtifactType = "KEY_CONFIGURATION" ArtifactTypeSystem ArtifactType = "SYSTEM" ParametersResourceTypeKey ParametersResourceType = "KEY" ParametersResourceTypeKeyConfiguration ParametersResourceType = "KEY_CONFIGURATION" ActionTypeUpdateState ActionType = "UPDATE_STATE" ActionTypeUpdatePrimary ActionType = "UPDATE_PRIMARY" ActionTypeLink ActionType = "LINK" ActionTypeUnlink ActionType = "UNLINK" ActionTypeSwitch ActionType = "SWITCH" ActionTypeDelete ActionType = "DELETE" )
Variables ¶
var ( ErrInvalidEventActor = errors.New("invalid event actor") ErrInsufficientApproverCount = errors.New("insufficient approvers to transition to next state") ErrTransitionExecution = errors.New("failed to execute transition") ErrWorkflowExecution = errors.New("failed to execute workflow action") ErrUpdateWorkflowState = errors.New("fialed to update workflow state") ErrCheckApprovers = errors.New("failed to check approvers") ErrAutomatedTransition = errors.New( "automated transition cannot be triggered by user input", ) ErrInvalidWorkflowState = errors.New("invalid workflow state") ErrInvalidWorkflowType = errors.New("invalid workflow type") ErrCheckApproverDecision = errors.New("failed to check approver decision") ErrListApprovers = errors.New("failed to list approvers") ErrInvalidVotingTransition = errors.New("invalid voting transition") )
var ActionTypes = []ActionType{ ActionTypeUpdateState, ActionTypeUpdatePrimary, ActionTypeLink, ActionTypeUnlink, ActionTypeSwitch, ActionTypeDelete, }
var ArtifactTypes = []ArtifactType{ArtifactTypeKey, ArtifactTypeKeyConfiguration, ArtifactTypeSystem}
var NonTerminalStates = []string{ StateInitial.String(), StateWaitApproval.String(), StateWaitConfirmation.String(), StateExecuting.String(), }
var States = []State{ StateInitial, StateRevoked, StateRejected, StateExpired, StateWaitApproval, StateWaitConfirmation, StateExecuting, StateSuccessful, StateFailed, }
var SystemUserID = SystemUserUUID.String()
var SystemUserUUID = uuid.Max
var TerminalStates = []string{ StateRevoked.String(), StateRejected.String(), StateExpired.String(), StateSuccessful.String(), StateFailed.String(), }
var Transitions = []Transition{ TransitionCreate, TransitionRevoke, TransitionReject, TransitionExpire, TransitionApprove, TransitionConfirm, TransitionExecute, TransitionFail, }
Functions ¶
func GetApproverUserNames ¶
func GetApproverUserNames(approvers []model.WorkflowApprover) []string
func GetNotificationRecipients ¶
func GetNotificationRecipients(workflow model.Workflow, transition Transition) []string
GetNotificationRecipients returns the usernames to notify for a workflow transition.
func NewInsufficientApproverCountError ¶
NewInsufficientApproverCountError creates an error when there are not enough approvers to transition to the next state.
func NewInvalidEventActorError ¶
NewInvalidEventActorError creates an error when the user is not the expected actor of the event.
func NewTransitionError ¶
func NewTransitionError(transition Transition) error
NewTransitionError creates an error when a transition fails.
Types ¶
type ActionType ¶
type ActionType string
ActionType represents the type of the action that the workflow is performing.
func (ActionType) String ¶
func (t ActionType) String() string
type ApprovalMechanism ¶
type ApprovalMechanism string
const (
ApprovalMechanismTargetScore ApprovalMechanism = "TARGET_SCORE"
)
type ApprovalSummary ¶
type ApprovalSummary struct {
Mechanism ApprovalMechanism
Approvals int
Rejections int
Pending int
TargetScore int
}
type ArtifactType ¶
type ArtifactType string
ArtifactType represents the type of the artifact that the workflow is acting on.
func (ArtifactType) String ¶
func (t ArtifactType) String() string
type KeyActions ¶
type KeyConfigurationActions ¶
type Lifecycle ¶
type Lifecycle struct {
Workflow *model.Workflow
StateMachine *fsm.FSM
ActorID string
Repository repo.Repo
KeyActions KeyActions
KeyConfigurationActions KeyConfigurationActions
SystemActions SystemActions
MinimumApproverCount int
}
func NewLifecycle ¶
func NewLifecycle(workflow *model.Workflow, keyActions KeyActions, keyConfigurationActions KeyConfigurationActions, systemActions SystemActions, repo repo.Repo, actorID string, minimumApproverCount int, ) *Lifecycle
NewLifecycle creates a new Lifecycle object for the given workflow with a state machine that defines the possible transitions.
func (*Lifecycle) ApplyTransition ¶
func (l *Lifecycle) ApplyTransition(ctx context.Context, transition Transition) error
ApplyTransition wraps the execution of a transition in the state machine triggered by user input
func (*Lifecycle) AvailableBusinessUserTransitions ¶
func (l *Lifecycle) AvailableBusinessUserTransitions(ctx context.Context) []Transition
AvailableBusinessUserTransitions returns the list of transitions that can be performed by business users (i.e., non-automated transitions) after the creation of the workflow.
func (*Lifecycle) CanTransition ¶
func (l *Lifecycle) CanTransition(transition Transition) bool
CanTransition checks if the workflow can transition to the given state
func (*Lifecycle) GetApprovalSummary ¶
func (l *Lifecycle) GetApprovalSummary(ctx context.Context) (*ApprovalSummary, error)
func (*Lifecycle) ValidateActor ¶
func (l *Lifecycle) ValidateActor(ctx context.Context, transition Transition) error
ValidateActor validates the actor of the event
type ParametersResourceType ¶
type ParametersResourceType string
ParametersResourceType represents the type of the resource that is referenced in the workflow parameters.
func (ParametersResourceType) String ¶
func (t ParametersResourceType) String() string
type SystemActions ¶
type Transition ¶
type Transition string
Transition represents the transition of a workflow in the state-machine.
func (Transition) String ¶
func (t Transition) String() string