Documentation ¶
Overview ¶
Package notifications sends notifications for run state transitions and workspace events.
Index ¶
Constants ¶
View Source
const ( DestinationGeneric Destination = "generic" DestinationSlack Destination = "slack" DestinationGCPPubSub Destination = "gcppubsub" // Email type is only accepted in order to pass the `go-tfe` API tests, // which create configs with this type. It otherwise is entirely // unfunctional; no emails are sent. DestinationEmail Destination = "email" TriggerCreated Trigger = "run:created" TriggerPlanning Trigger = "run:planning" TriggerNeedsAttention Trigger = "run:needs_attention" TriggerApplying Trigger = "run:applying" TriggerCompleted Trigger = "run:completed" TriggerErrored Trigger = "run:errored" )
View Source
const LockID int64 = 5577006791947779411
LockID guarantees only one notifier on a cluster is running at any time.
Variables ¶
Functions ¶
func NewService ¶
func NewService(opts Options) *service
Types ¶
type Config ¶
type Config struct { ID string CreatedAt time.Time UpdatedAt time.Time DestinationType Destination Enabled bool Name string Token string Triggers []Trigger URL *string WorkspaceID string }
Config represents a Notification Configuration.
type CreateConfigOptions ¶
type CreateConfigOptions struct { // Required: The destination type of the notification configuration DestinationType Destination // Required: Whether the notification configuration should be enabled or not Enabled *bool // Required: The name of the notification configuration Name *string // Optional: The token of the notification configuration Token *string // Optional: The list of run events that will trigger notifications. Triggers []Trigger // Optional: The url of the notification configuration URL *string }
type GenericPayload ¶
type GenericPayload struct { PayloadVersion int NotificationConfigurationID string RunURL string RunID string RunMessage string RunCreatedAt time.Time RunCreatedBy string WorkspaceID string WorkspaceName string OrganizationName string Notifications []genericNotificationPayload }
GenericPayload is the information sent in generic notifications, as documented here:
type NotificationService ¶
type NotificationService = Service
type Notifier ¶
type Notifier struct { logr.Logger workspace.WorkspaceService // for retrieving workspace name internal.HostnameService // for including a link in the notification run.RunService NotificationService // contains filtered or unexported fields }
Notifier relays run events onto interested parties
func NewNotifier ¶
func NewNotifier(opts NotifierOptions) *Notifier
type NotifierOptions ¶
type NotifierOptions struct { logr.Logger workspace.WorkspaceService // for retrieving workspace name internal.HostnameService // for including a link in the notification run.RunService NotificationService *sql.DB }
type Options ¶
type Options struct { *sql.DB *sql.Listener *tfeapi.Responder logr.Logger WorkspaceAuthorizer internal.Authorizer workspace.WorkspaceService internal.HostnameService // for including a link in the notification }
type Service ¶
type Service interface { CreateNotificationConfiguration(ctx context.Context, workspaceID string, opts CreateConfigOptions) (*Config, error) UpdateNotificationConfiguration(ctx context.Context, id string, opts UpdateConfigOptions) (*Config, error) GetNotificationConfiguration(ctx context.Context, id string) (*Config, error) ListNotificationConfigurations(ctx context.Context, workspaceID string) ([]*Config, error) DeleteNotificationConfiguration(ctx context.Context, id string) error WatchNotificationConfigurations(context.Context) (<-chan pubsub.Event[*Config], func()) }
type UpdateConfigOptions ¶
type UpdateConfigOptions struct { // Optional: Whether the notification configuration should be enabled or not Enabled *bool // Optional: The name of the notification configuration Name *string // Optional: The token of the notification configuration Token *string // Optional: The list of run events that will trigger notifications. Triggers []Trigger // Optional: The url of the notification configuration URL *string }
UpdateConfigOptions represents the options for updating a existing notification configuration.
Click to show internal directories.
Click to hide internal directories.