handler

package
v0.0.0-...-1598195 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type      string                 `json:"type"`      // defines the action type
	EventType string                 `json:"eventType"` // defines the eventtype field in the event notification
	Data      map[string]interface{} `json:"data"`      // contains the payload for the action, this could be any json so using a map
}

Action is the structure of an action that is received via the message queue.

type EventMap

type EventMap struct {
	Emoji    string `json:"emoji"`
	Color    string `json:"color"`
	Template string `json:"template"`
}

EventMap .

type LagoonAPI

type LagoonAPI struct {
	Endpoint        string `json:"endpoint"`
	JWTAudience     string `json:"audience"`
	TokenSigningKey string `json:"tokenSigningKey"`
	JWTSubject      string `json:"subject"`
	JWTIssuer       string `json:"issuer"`
	Version         string `json:"version"`
}

LagoonAPI .

type MessageType

type MessageType string

MessageType .

type Messaging

type Messaging struct {
	Config                  mq.Config
	LagoonAPI               LagoonAPI
	ConnectionAttempts      int
	ConnectionRetryInterval int
	EnableDebug             bool
	LagoonAppID             string
	DisableSlack            bool
	DisableRocketChat       bool
	DisableMicrosoftTeams   bool
	DisableEmail            bool
	DisableWebhooks         bool
	DisableS3               bool
	EmailSender             string
	EmailSenderPassword     string
	EmailHost               string
	EmailPort               string
	EmailSSL                bool
	EmailInsecureSkipVerify bool
	S3FilesAccessKeyID      string
	S3FilesSecretAccessKey  string
	S3FilesBucket           string
	S3FilesRegion           string
	S3FilesOrigin           string
	S3IsGCS                 bool
}

Messaging is used for the config and client information for the messaging queue.

func NewMessaging

func NewMessaging(config mq.Config,
	lagoonAPI LagoonAPI,
	startupAttempts int,
	startupInterval int,
	enableDebug bool,
	appID string,
	disableSlack, disableRocketChat, disableMicrosoftTeams, disableEmail, disableWebhooks, disableS3 bool,
	emailSender, emailSenderPassword, emailHost, emailPort string, emailSSL, emailInsecureSkipVerify bool,
	s3FilesAccessKeyID, s3FilesSecretAccessKey, s3FilesBucket, s3FilesRegion, s3FilesOrigin string, s3isGCS bool) *Messaging

NewMessaging returns a messaging with config

func (*Messaging) Consumer

func (h *Messaging) Consumer()

Consumer handles consuming messages sent to the queue that this action handler is connected to and processes them accordingly

func (*Messaging) SendToEmail

func (h *Messaging) SendToEmail(notification *Notification, emailAddress string)

SendToEmail .

func (*Messaging) SendToMicrosoftTeams

func (h *Messaging) SendToMicrosoftTeams(notification *Notification, webhook string)

SendToMicrosoftTeams .

func (*Messaging) SendToRocketChat

func (h *Messaging) SendToRocketChat(notification *Notification, channel, webhook, appID string)

SendToRocketChat .

func (*Messaging) SendToS3

func (h *Messaging) SendToS3(notification *Notification, msgType MessageType)

SendToS3 .

func (*Messaging) SendToSlack

func (h *Messaging) SendToSlack(notification *Notification, channel, webhook, appID string)

SendToSlack .

func (*Messaging) SendToWebhook

func (h *Messaging) SendToWebhook(notification *Notification, webhook schema.AddNotificationWebhookInput)

SendToWebhook .

type MicrosoftTeamsData

type MicrosoftTeamsData struct {
	Type       string                  `json:"@type"`
	Context    string                  `json:"@context"`
	Summary    string                  `json:"summary"`
	Title      string                  `json:"title"`
	ThemeColor string                  `json:"themeColor"`
	Sections   []MicrosoftTeamsSection `json:"sections"`
}

MicrosoftTeamsData .

type MicrosoftTeamsSection

type MicrosoftTeamsSection struct {
	ActivityText  string `json:"activityText"`
	ActivityImage string `json:"activityImage"`
}

MicrosoftTeamsSection .

type Notification

type Notification struct {
	Severity string `json:"severity"`
	Project  string `json:"project"`
	UUID     string `json:"uuid"`
	Event    string `json:"event"`
	Meta     struct {
		User struct {
			ID                string `json:"id"`
			PreferredUsername string `json:"preferred_username"`
			Email             string `json:"email"`
		} `json:"user"`
		Headers struct {
			UserAgent     string `json:"user-agent"`
			ContentType   string `json:"content-type"`
			ContentLength string `json:"content-length"`
			Host          string `json:"host"`
			IPAddress     string `json:"ipAddress"`
		} `json:"headers"`
		Project                  string   `json:"project"`
		ProjectName              string   `json:"projectName"`
		BranchName               string   `json:"branchName"`
		Event                    string   `json:"event"`
		Level                    string   `json:"level"`
		Message                  string   `json:"message"`
		Timestamp                string   `json:"timestamp"`
		ShortSha                 string   `json:"shortSha"`
		BuildName                string   `json:"buildName"`
		BuildPhase               string   `json:"buildPhase"`
		BuildStep                string   `json:"buildStep"`
		CommitURL                string   `json:"commitUrl"`
		Environment              string   `json:"environment"`
		EnvironmentID            string   `json:"environmentId"`
		EnvironmentName          string   `json:"environmentName"`
		ServiceName              string   `json:"serviceName"`
		Severity                 string   `json:"severity"`
		Description              string   `json:"description"`
		Error                    string   `json:"error"`
		JobName                  string   `json:"jobName"`
		LogLink                  string   `json:"logLink"`
		Name                     string   `json:"name"`
		OpenshiftProject         string   `json:"openshiftProject"`
		PromoteSourceEnvironment string   `json:"promoteSourceEnvironment"`
		PullrequestNumber        int      `json:"pullrequestNumber"`
		PullrequestTitle         string   `json:"pullrequestTitle"`
		PullrequestURL           string   `json:"pullrequestUrl"`
		RemoteID                 string   `json:"remoteId"`
		RepoFullName             string   `json:"repoFullName"`
		RepoName                 string   `json:"repoName"`
		RepoURL                  string   `json:"repoUrl"`
		Route                    string   `json:"route"`
		Routes                   []string `json:"routes"`
		Task                     struct {
			ID string `json:"id"`
		} `json:"task"`
	} `json:"meta"`
	Message string `json:"message"`
}

Notification .

type RabbitBroker

type RabbitBroker struct {
	Hostname string `json:"hostname"`
	Port     string `json:"port"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

RabbitBroker .

type RocketChatAttachment

type RocketChatAttachment struct {
	Text   string                      `json:"text"`
	Color  string                      `json:"color"`
	Fields []RocketChatAttachmentField `json:"fields"`
}

RocketChatAttachment .

type RocketChatAttachmentField

type RocketChatAttachmentField struct {
	Short bool   `json:"short"`
	Title string `json:"title"`
	Value string `json:"value"`
}

RocketChatAttachmentField .

type RocketChatData

type RocketChatData struct {
	Channel     string                 `json:"channel"`
	Attachments []RocketChatAttachment `json:"attachments"`
}

RocketChatData .

type WebhookData

type WebhookData struct {
	Type        string   `json:"type"`
	Event       string   `json:"event"`
	Project     string   `json:"project"`
	Environment string   `json:"environment"`
	BuildName   string   `json:"buildName,omitempty"`
	Warnings    bool     `json:"warnings,omitempty"`
	BuildStep   string   `json:"buildStep,omitempty"`
	Route       string   `json:"route,omitempty"`
	Routes      []string `json:"routes,omitempty"`
	LogLink     string   `json:"logLink,omitempty"`
}

WebhookData .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL