helpers

package
v0.0.0-...-6d13933 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const JiraJqlQuery string = "project = 'OHSS' AND (status = 'To Do' OR status = 'In Progress') AND priority >= 'High'"
View Source
const JiraPressure int = 3
View Source
const PDPressure int = 3

Variables

This section is empty.

Functions

func FormatIncList

func FormatIncList(incs []string, baseurl string) string

FormatIncList pretty prints the incident list with clickable links

Types

type Helper

type Helper struct {
	PD    PDHelper
	Jira  JiraHelper
	Slack SlackHelper
}

Helper is a class-like struct to help quickly init other needed helpers and provide a single access point to values

func NewHelper

func NewHelper() Helper

NewHelper builds a new Helper and its underlying clients and settings

func (*Helper) GetAllIncidents

func (h *Helper) GetAllIncidents() ([]string, []string, error)

GetAllIncidents fetches incidents from PagerDuty and Jira for listing and checking pressure

type JiraHelper

type JiraHelper struct {
	Client   *jira.Client
	User     *jira.User
	BaseUrl  string
	Pressure int
	JqlQuery string
}

JiraHelper helps configure a client and settings needed to interact with Jira

func (*JiraHelper) AssignJiraIssue

func (j *JiraHelper) AssignJiraIssue(issueKey string) error

AssignJiraIssue assigns an issues to the helpers defined user

func (*JiraHelper) CheckJiraPressure

func (j *JiraHelper) CheckJiraPressure() (bool, error)

CheckJiraPressure checks the number of issues and compares it to the Pressure value. It initializes a swarm of the value is exceeded.

func (*JiraHelper) GetJiraClient

func (j *JiraHelper) GetJiraClient()

GetJiraClient setups a Jira client

func (*JiraHelper) GetJiraIssues

func (j *JiraHelper) GetJiraIssues() ([]string, error)

GetJiraIssues returns all issues based on the JQL query defined in the Helper

func (*JiraHelper) GetJiraUser

func (j *JiraHelper) GetJiraUser(email string) error

GetJiraUser finds a Jira user using the provided user's email

type PDHelper

type PDHelper struct {
	Client           *pagerduty.Client
	User             *pagerduty.User
	ScheduleID       string
	EscalationPolicy string
	BaseUrl          string
	Pressure         int
}

PDHelper helps configure a client and settings needed to interact with PagerDuty

func (*PDHelper) AssignPDInc

func (p *PDHelper) AssignPDInc(incidentID string) error

AssignPDInc handles assigning a PagerDuty incident to a user

func (*PDHelper) CheckPDPressure

func (p *PDHelper) CheckPDPressure() (bool, error)

CheckPDPressure checks the number of incidents and compares it to the Pressure value. It initializes a swarm of the value is exceeded.

func (*PDHelper) GetPDClient

func (p *PDHelper) GetPDClient()

GetPDClient creates a PagerDuty client for interacting with the API

func (*PDHelper) GetPDIncs

func (p *PDHelper) GetPDIncs() ([]string, error)

GetPDIncs lists all incidents assigned to a user

func (*PDHelper) GetPDUser

func (p *PDHelper) GetPDUser(userEmail string) error

GetPDUser gets a user from PagerDuty

func (*PDHelper) GetPrimaryOnCall

func (p *PDHelper) GetPrimaryOnCall() error

GetPrimaryOnCall gets the current on-call user in PagerDuty to determining incident counts

type SlackHelper

type SlackHelper struct {
	Client    *slack.Client
	Username  string
	UserEmail string
}

SlackHelper helps configure a client and stores data captured from Slack

func (*SlackHelper) GetSlackUserEmail

func (s *SlackHelper) GetSlackUserEmail(userID string) error

GetSlackUserEmail gets the email address of a user

func (*SlackHelper) GetSlackUsername

func (s *SlackHelper) GetSlackUsername(email string) error

GetSlackUsername gets the slack handle for a user by email

Jump to

Keyboard shortcuts

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