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 ¶
const ( KindWorkflow = "workflow" KindWorkflowStep = "workflow_step" KindWorkflowStepApproval = "workflow_step_approval" )
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" )
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
}
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 as a clickable mrkdwn chip in the trailing context block.
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 structured blocks posted as the message body.
func BuildChildMessage ¶
BuildChildMessage renders the per-event threaded reply.
func BuildDriftDetectedMessage ¶
BuildDriftDetectedMessage renders a standalone (non-threaded) drift notification.
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 message that links directly to the affected component or sandbox.
Headline: "🌊 Drift detected — <component name>" for component drift, "🌊 Drift detected on sandbox" for sandbox drift. Footer carries the org / install chips. The link chip points at the most specific resource available (component → sandbox → install).
func BuildFlatMessage ¶
BuildFlatMessage renders a defensive single-block fallback for events without a workflow id (e.g. install-created). Same shape as the child.
func BuildParentMessage ¶
BuildParentMessage renders the workflow's parent post — emitted on the first event for a workflow. The parent's shape (headline + status + footer + links) is identical to BuildParentRollup so the post never visually grows or rearranges across edits.
startedAt is the workflow's first-event timestamp. When zero, the "running 5m" / "ran 5m" line is omitted.
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).