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 pubsub.Subscriber workspace.WorkspaceService // for retrieving workspace name internal.HostnameService // for including a link in the notification // 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 pubsub.Subscriber workspace.WorkspaceService // for retrieving workspace name internal.HostnameService // for including a link in the notification *sql.DB }
type Options ¶
type Options struct { *sql.DB *pubsub.Broker 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 }
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.