Documentation
¶
Overview ¶
Package slackrender renders Slack message text and blocks for Nuon workflow / workflow_step / workflow_step_approval lifecycle events.
The renderer is purely a pure function of its input Event — it never calls back into ctl-api. Producers (the slack lifecycle hook) are expected to enrich the Event from the same canonical sources the webhook hook uses.
This package mirrors the input shape used by slackbot's notify package (lifecycle.WebhookPayload / EventData / WorkflowRef / StepRef / etc.) so the rendering logic can be ported with minimal adaptation. The difference from slackbot is the OUTPUT contract: slackbot emits one inlined line; we keep the existing two-block shape — a SECTION block (bold headline + optional status sub-line) plus a CONTEXT block (small grey footer with org/install/workflow chips and an Open in Nuon link).
Index ¶
- Constants
- type ApprovalRef
- type ContextLinks
- type Event
- type LinkChip
- type Message
- func BuildAppConfigSyncedMessage(e Event) Message
- func BuildChildMessage(e Event) Message
- func BuildDriftDetectedMessage(e Event) Message
- func BuildFlatMessage(e Event) Message
- func BuildParentMessage(e Event, startedAt time.Time) Message
- func BuildParentRollup(e Event, startedAt time.Time) Message
- func BuildRoleChangeMessage(e Event) Message
- func BuildUpdateAppConfigMessage(e Event) Message
- type Outcome
- type ParentRef
- type StepRef
- type WorkflowRef
Constants ¶
const ( KindWorkflow = "workflow" KindWorkflowStep = "workflow_step" KindWorkflowStepApproval = "workflow_step_approval" KindRoleChange = "role_change" KindInputsUpdated = "inputs_updated" KindStackRun = "stack_run" KindAppConfigSynced = "app_config_synced" )
Kind values for Event.Kind. Matches the wire vocabulary in services/ctl-api/internal/pkg/queue/signal/hooks/webhook.go.
const ( TransitionStarted = "started" TransitionSucceeded = "succeeded" TransitionFailed = "failed" TransitionCancelled = "cancelled" TransitionRequested = "requested" TransitionApproved = "approved" TransitionRejected = "rejected" )
Transition values for Event.Transition. British "cancelled" is the canonical wire value (matches webhook.go's transitionCanceled).
const ( OwnerTypeInstalls = "installs" OwnerTypeApps = "apps" OwnerTypeAppBranches = "app_branches" )
OwnerType values for WorkflowRef.OwnerType.
const ( WorkflowTypeProvision = "provision" WorkflowTypeReprovision = "reprovision" WorkflowTypeManualDeploy = "manual_deploy" WorkflowTypeActionWorkflowRun = "action_workflow_run" WorkflowTypeDriftRun = "drift_run" WorkflowTypeDeployComponents = "deploy_components" WorkflowTypeTeardownComponent = "teardown_component" WorkflowTypeTeardownComponents = "teardown_components" WorkflowTypeInputUpdate = "input_update" WorkflowTypeSyncSecrets = "sync_secrets" WorkflowTypeDeprovision = "deprovision" WorkflowTypeDeprovisionSandbox = "deprovision_sandbox" WorkflowTypeReprovisionSandbox = "reprovision_sandbox" WorkflowTypeAppConfigBuild = "app_config_build" WorkflowTypeAppBranchesRun = "app_branches_manual_update" WorkflowTypeAppBranchesConfigRepoUpdate = "app_branches_config_repo_update" WorkflowTypeAppBranchesComponentRepoUpdate = "app_branches_component_repo_update" WorkflowTypeRunbookRun = "runbook_run" WorkflowTypeComponentEnabled = "component_enabled" WorkflowTypeComponentDisabled = "component_disabled" )
WorkflowType values for WorkflowRef.Type.
const ( TargetTypeInstallDeploys = "install_deploys" TargetTypeInstallSandboxRuns = "install_sandbox_runs" TargetTypeInstallActionWorkflowRuns = "install_action_workflow_runs" TargetTypeInstallCloudFormationStack = "install_cloudformation_stack" TargetTypeInstallRunnerUpdate = "install_runner_update" )
TargetType values for StepRef.TargetType. Matches the actual string values stored in install_workflow_steps.step_target_type, which is the plural form of the app.WorkflowStepTargetType* constants — the singular constants exist but are not what the DB carries.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalRef ¶
ApprovalRef carries the structured approval block on workflow_step_approval events.
type ContextLinks ¶
type ContextLinks struct {
Org string
Install string
Workflow string
Sandbox string
Component string
Approval string
RespondAPI string
}
ContextLinks contains dashboard / API URLs for the entities referenced in the event. Any field may be empty.
type Event ¶
type Event struct {
Kind string
Transition string
OrgID string
OrgName string
Workflow WorkflowRef
Step *StepRef
Parent *ParentRef
Outcome *Outcome
Approval *ApprovalRef
Links *ContextLinks
// Metadata carries domain-specific key-value data from the originating
// signal. Used by notification-only events (e.g. role-change) to pass
// fields like role_name, change_type, etc. to the renderer.
Metadata map[string]any
}
Event is the input to every Build* renderer function. It mirrors the ctl-api webhook payload shape (lifecycleEventData) one-to-one so the slack lifecycle hook can build it from the same enrichment sources.
func (Event) IsTerminal ¶
IsTerminal reports whether the event represents a terminal transition.
type LinkChip ¶
LinkChip is a (label, url) pair rendered either as a context link or an actions button.
type Message ¶
Message is the rendered output of a Build* call: a fallback text string (used by Slack when blocks aren't supported) and the typed Block Kit blocks posted as the message body. Blocks are built with the slack-go SDK so their shape is validated by the type system rather than hand-assembled maps.
func BuildAppConfigSyncedMessage ¶ added in v0.19.1020
BuildAppConfigSyncedMessage renders a standalone notification card for app config sync events. Metadata fields: actor_email, app_name, branch_name.
func BuildChildMessage ¶
BuildChildMessage renders the per-event threaded reply: a tight two-line block. Org / install are intentionally omitted — every reply in the thread is the same install, so repeating them is noise; the parent card already carries them.
func BuildDriftDetectedMessage ¶
BuildDriftDetectedMessage renders a standalone (non-threaded) drift card.
Drift workflows produce no useful "running drift check" signal for subscribers — the only event that matters is "drift was actually detected on resource X". So drift events are deliberately NOT anchored under a parent post; each detection is its own top-level card that links directly to the affected component or sandbox.
func BuildFlatMessage ¶
BuildFlatMessage renders a self-contained top-level message for events without a workflow id (e.g. install-created). Unlike a thread reply it keeps the org / install context, since it stands alone.
func BuildParentMessage ¶
BuildParentMessage renders the workflow's parent post — a fielded "card" emitted on the first event for a workflow. Its shape is identical to BuildParentRollup so the post never visually rearranges across edits.
startedAt is the workflow's first-event timestamp. When zero, the Duration field is omitted.
func BuildParentRollup ¶
BuildParentRollup renders the parent card on every subsequent edit. Identical layout to BuildParentMessage by design.
func BuildRoleChangeMessage ¶ added in v0.19.1013
BuildRoleChangeMessage renders a standalone role-change notification card. Role-change events are notification-only signals (like drift) — each lands as its own top-level message indicating that a role was enabled or disabled.
func BuildUpdateAppConfigMessage ¶ added in v0.19.1038
type ParentRef ¶
ParentRef is set when this workflow was launched from another workflow's step (e.g. an action workflow run launched from a deploy step).
type StepRef ¶
type StepRef struct {
ID string
Name string
Idx int
TargetType string
TargetID string
ComponentID string
ComponentName string
SandboxID string
ExecutionType string
}
StepRef identifies a workflow step. Present only on workflow_step / workflow_step_approval events.
type WorkflowRef ¶
type WorkflowRef struct {
ID string
Type string
OwnerID string
OwnerType string
OwnerName string
// CreatedByEmail labels who started the workflow. Falls back to the
// raw account id for accounts without an email; empty when the
// workflow has no creator.
CreatedByEmail string
// CreatedAt is the workflow's start time. Zero when unknown.
CreatedAt time.Time
// RunbookName labels the runbook this workflow is executing. Populated
// only for runbook_run workflows.
RunbookName string
}
WorkflowRef identifies the workflow this event is about.