pagerduty

package
v0.0.0-...-ea8c238 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package pagerduty is a generated GoMock package.

Index

Constants

View Source
const (
	AlertResolvedSummaryDeleted        string = "Cluster does not exist anymore"
	AlertResolvedSummaryLimitedSupport string = "The cluster has been placed in limited support"
)

Variables

This section is empty.

Functions

func WithCustomHTTPClient

func WithCustomHTTPClient(controllerName string) pdApi.ClientOptions

WithCustomHTTPClient allows to wrapper to monitor API response time

Types

type Client

type Client interface {
	GetService(data *Data) (*pdApi.Service, error)
	GetIntegrationKey(data *Data) (string, error)
	CreateService(data *Data) (string, error)
	DeleteService(data *Data) error
	EnableService(data *Data) error
	DisableService(data *Data) error
	UpdateEscalationPolicy(data *Data) error
	UpdateAlertGrouping(data *Data) error
	ToggleServiceOrchestration(data *Data, active bool) error
	ApplyServiceOrchestrationRule(data *Data) error
}

Client is a wrapper interface for the SvcClient to allow for easier testing

func NewClient

func NewClient(APIKey string, controllerName string) Client

NewClient creates out client wrapper object for the actual pdApi.Client we use.

type Data

type Data struct {
	// These fields are parsed from the PagerDutyIntegration CR
	EscalationPolicyID string
	ResolveTimeout     uint
	AcknowledgeTimeOut uint
	ServicePrefix      string

	// ClusterID and BaseDomain are required during service creation for naming
	ClusterID  string
	BaseDomain string

	// These fields are stored when the PagerDuty service is created and stored
	// in a Configmap in the ClusterDeployment's namespace
	// There is also an EscalationPolicyID field which is parsed fron the PDI CR
	ServiceID      string
	IntegrationID  string
	Hibernating    bool
	LimitedSupport bool

	// ServiceOrchestration related parameters
	ServiceOrchestrationEnabled     bool
	ServiceOrchestrationRuleApplied string

	// Alert grouping related parameters
	AlertGroupingType    string `json:"alert_grouping_type,omitempty"`
	AlertGroupingTimeout uint   `'json:"alert_grouping_timeout,omitempty"`
}

Data describes the data that is needed for PagerDuty api calls

func NewData

func NewData(pdi *pagerdutyv1alpha1.PagerDutyIntegration, clusterId string, baseDomain string) (*Data, error)

NewData initializes a Data struct from a v1alpha1 PagerDutyIntegration spec pdi.Spec.EscalationPolicy is required

func (*Data) ParseClusterConfig

func (data *Data) ParseClusterConfig(osc client.Client, namespace string, cmName string) error

ParseClusterConfig parses the cluster specific config map and stores the IDs in the data struct SERVICE_ID and INTEGRATION_ID are required ConfigMap data fields HIBERNATING and LIMITED_SUPPORT are optional.

func (*Data) SetClusterConfig

func (data *Data) SetClusterConfig(osc client.Client, namespace string, cmName string) error

SetClusterConfig updates a specific ClusterDeployment's PagerDuty Configmap with the contents of the data struct

type DelayFunc

type DelayFunc func(time.Duration)

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) ApplyServiceOrchestrationRule

func (m *MockClient) ApplyServiceOrchestrationRule(data *Data) error

ApplyServiceOrchestrationRule mocks base method.

func (*MockClient) CreateService

func (m *MockClient) CreateService(data *Data) (string, error)

CreateService mocks base method.

func (*MockClient) DeleteService

func (m *MockClient) DeleteService(data *Data) error

DeleteService mocks base method.

func (*MockClient) DisableService

func (m *MockClient) DisableService(data *Data) error

DisableService mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) EnableService

func (m *MockClient) EnableService(data *Data) error

EnableService mocks base method.

func (*MockClient) GetIntegrationKey

func (m *MockClient) GetIntegrationKey(data *Data) (string, error)

GetIntegrationKey mocks base method.

func (*MockClient) GetService

func (m *MockClient) GetService(data *Data) (*go_pagerduty.Service, error)

GetService mocks base method.

func (*MockClient) ToggleServiceOrchestration

func (m *MockClient) ToggleServiceOrchestration(data *Data, active bool) error

ToggleServiceOrchestration mocks base method.

func (*MockClient) UpdateAlertGrouping

func (m *MockClient) UpdateAlertGrouping(data *Data) error

UpdateAlertGrouping mocks base method.

func (*MockClient) UpdateEscalationPolicy

func (m *MockClient) UpdateEscalationPolicy(data *Data) error

UpdateEscalationPolicy mocks base method.

type MockClientMockRecorder

type MockClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) ApplyServiceOrchestrationRule

func (mr *MockClientMockRecorder) ApplyServiceOrchestrationRule(data interface{}) *gomock.Call

ApplyServiceOrchestrationRule indicates an expected call of ApplyServiceOrchestrationRule.

func (*MockClientMockRecorder) CreateService

func (mr *MockClientMockRecorder) CreateService(data interface{}) *gomock.Call

CreateService indicates an expected call of CreateService.

func (*MockClientMockRecorder) DeleteService

func (mr *MockClientMockRecorder) DeleteService(data interface{}) *gomock.Call

DeleteService indicates an expected call of DeleteService.

func (*MockClientMockRecorder) DisableService

func (mr *MockClientMockRecorder) DisableService(data interface{}) *gomock.Call

DisableService indicates an expected call of DisableService.

func (*MockClientMockRecorder) EnableService

func (mr *MockClientMockRecorder) EnableService(data interface{}) *gomock.Call

EnableService indicates an expected call of EnableService.

func (*MockClientMockRecorder) GetIntegrationKey

func (mr *MockClientMockRecorder) GetIntegrationKey(data interface{}) *gomock.Call

GetIntegrationKey indicates an expected call of GetIntegrationKey.

func (*MockClientMockRecorder) GetService

func (mr *MockClientMockRecorder) GetService(data interface{}) *gomock.Call

GetService indicates an expected call of GetService.

func (*MockClientMockRecorder) ToggleServiceOrchestration

func (mr *MockClientMockRecorder) ToggleServiceOrchestration(data, active interface{}) *gomock.Call

ToggleServiceOrchestration indicates an expected call of ToggleServiceOrchestration.

func (*MockClientMockRecorder) UpdateAlertGrouping

func (mr *MockClientMockRecorder) UpdateAlertGrouping(data interface{}) *gomock.Call

UpdateAlertGrouping indicates an expected call of UpdateAlertGrouping.

func (*MockClientMockRecorder) UpdateEscalationPolicy

func (mr *MockClientMockRecorder) UpdateEscalationPolicy(data interface{}) *gomock.Call

UpdateEscalationPolicy indicates an expected call of UpdateEscalationPolicy.

type MockPdClient

type MockPdClient struct {
	// contains filtered or unexported fields
}

MockPdClient is a mock of PdClient interface.

func NewMockPdClient

func NewMockPdClient(ctrl *gomock.Controller) *MockPdClient

NewMockPdClient creates a new mock instance.

func (*MockPdClient) CreateIntegration

func (m *MockPdClient) CreateIntegration(serviceID string, integration go_pagerduty.Integration) (*go_pagerduty.Integration, error)

CreateIntegration mocks base method.

func (*MockPdClient) CreateService

func (m *MockPdClient) CreateService(service go_pagerduty.Service) (*go_pagerduty.Service, error)

CreateService mocks base method.

func (*MockPdClient) DeleteService

func (m *MockPdClient) DeleteService(id string) error

DeleteService mocks base method.

func (*MockPdClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPdClient) GetEscalationPolicy

GetEscalationPolicy mocks base method.

func (*MockPdClient) GetIntegration

func (m *MockPdClient) GetIntegration(arg0, arg1 string, arg2 go_pagerduty.GetIntegrationOptions) (*go_pagerduty.Integration, error)

GetIntegration mocks base method.

func (*MockPdClient) GetService

GetService mocks base method.

func (*MockPdClient) ListIncidentAlertsWithOpts

func (m *MockPdClient) ListIncidentAlertsWithOpts(incidentId string, o go_pagerduty.ListIncidentAlertsOptions) (*go_pagerduty.ListAlertsResponse, error)

ListIncidentAlertsWithOpts mocks base method.

func (*MockPdClient) ListIncidents

ListIncidents mocks base method.

func (*MockPdClient) ListServices

ListServices mocks base method.

func (*MockPdClient) ManageEvent

ManageEvent mocks base method.

func (*MockPdClient) UpdateService

func (m *MockPdClient) UpdateService(service go_pagerduty.Service) (*go_pagerduty.Service, error)

UpdateService mocks base method.

type MockPdClientMockRecorder

type MockPdClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockPdClientMockRecorder is the mock recorder for MockPdClient.

func (*MockPdClientMockRecorder) CreateIntegration

func (mr *MockPdClientMockRecorder) CreateIntegration(serviceID, integration interface{}) *gomock.Call

CreateIntegration indicates an expected call of CreateIntegration.

func (*MockPdClientMockRecorder) CreateService

func (mr *MockPdClientMockRecorder) CreateService(service interface{}) *gomock.Call

CreateService indicates an expected call of CreateService.

func (*MockPdClientMockRecorder) DeleteService

func (mr *MockPdClientMockRecorder) DeleteService(id interface{}) *gomock.Call

DeleteService indicates an expected call of DeleteService.

func (*MockPdClientMockRecorder) GetEscalationPolicy

func (mr *MockPdClientMockRecorder) GetEscalationPolicy(arg0, arg1 interface{}) *gomock.Call

GetEscalationPolicy indicates an expected call of GetEscalationPolicy.

func (*MockPdClientMockRecorder) GetIntegration

func (mr *MockPdClientMockRecorder) GetIntegration(arg0, arg1, arg2 interface{}) *gomock.Call

GetIntegration indicates an expected call of GetIntegration.

func (*MockPdClientMockRecorder) GetService

func (mr *MockPdClientMockRecorder) GetService(arg0, arg1 interface{}) *gomock.Call

GetService indicates an expected call of GetService.

func (*MockPdClientMockRecorder) ListIncidentAlertsWithOpts

func (mr *MockPdClientMockRecorder) ListIncidentAlertsWithOpts(incidentId, o interface{}) *gomock.Call

ListIncidentAlertsWithOpts indicates an expected call of ListIncidentAlertsWithOpts.

func (*MockPdClientMockRecorder) ListIncidents

func (mr *MockPdClientMockRecorder) ListIncidents(arg0 interface{}) *gomock.Call

ListIncidents indicates an expected call of ListIncidents.

func (*MockPdClientMockRecorder) ListServices

func (mr *MockPdClientMockRecorder) ListServices(arg0 interface{}) *gomock.Call

ListServices indicates an expected call of ListServices.

func (*MockPdClientMockRecorder) ManageEvent

func (mr *MockPdClientMockRecorder) ManageEvent(e interface{}) *gomock.Call

ManageEvent indicates an expected call of ManageEvent.

func (*MockPdClientMockRecorder) UpdateService

func (mr *MockPdClientMockRecorder) UpdateService(service interface{}) *gomock.Call

UpdateService indicates an expected call of UpdateService.

type PdClient

type PdClient interface {
	GetService(string, *pdApi.GetServiceOptions) (*pdApi.Service, error)
	GetEscalationPolicy(string, *pdApi.GetEscalationPolicyOptions) (*pdApi.EscalationPolicy, error)
	GetIntegration(string, string, pdApi.GetIntegrationOptions) (*pdApi.Integration, error)
	CreateService(service pdApi.Service) (*pdApi.Service, error)
	DeleteService(id string) error
	CreateIntegration(serviceID string, integration pdApi.Integration) (*pdApi.Integration, error)
	ListServices(pdApi.ListServiceOptions) (*pdApi.ListServiceResponse, error)
	ListIncidents(pdApi.ListIncidentsOptions) (*pdApi.ListIncidentsResponse, error)
	ListIncidentAlertsWithOpts(incidentId string, o pdApi.ListIncidentAlertsOptions) (*pdApi.ListAlertsResponse, error)
	ManageEvent(e *pdApi.V2Event) (*pdApi.V2EventResponse, error)
	UpdateService(service pdApi.Service) (*pdApi.Service, error)
}

type SvcClient

type SvcClient struct {
	APIKey   string
	PdClient PdClient
	Delay    DelayFunc
}

SvcClient wraps pdApi.Client

func (*SvcClient) ApplyServiceOrchestrationRule

func (c *SvcClient) ApplyServiceOrchestrationRule(data *Data) error

ApplyServiceOrchestrationRule applies the pre-defined orchestration rule to the service after enabled

func (*SvcClient) CreateService

func (c *SvcClient) CreateService(data *Data) (string, error)

CreateService creates a service in pagerduty for the specified clusterid and returns the service key

func (*SvcClient) DeleteService

func (c *SvcClient) DeleteService(data *Data) error

DeleteService will get a service from the PD api and delete it

func (*SvcClient) DisableService

func (c *SvcClient) DisableService(data *Data) error

DisableService will set the PD service disabled

func (*SvcClient) EnableService

func (c *SvcClient) EnableService(data *Data) error

EnableService will set the PD service active

func (*SvcClient) GetIntegrationKey

func (c *SvcClient) GetIntegrationKey(data *Data) (string, error)

GetIntegrationKey searches the PD API for an already existing service and returns the first integration key

func (*SvcClient) GetService

func (c *SvcClient) GetService(data *Data) (*pdApi.Service, error)

GetService searches the PD API for an already existing service

func (*SvcClient) ToggleServiceOrchestration

func (c *SvcClient) ToggleServiceOrchestration(data *Data, active bool) error

ToggleServiceOrchestration enables/disables the service orchestration for a given PD service

func (*SvcClient) UpdateAlertGrouping

func (c *SvcClient) UpdateAlertGrouping(data *Data) error

UpdateAlertGrouping will update the PD service alert grouping

func (*SvcClient) UpdateEscalationPolicy

func (c *SvcClient) UpdateEscalationPolicy(data *Data) error

UpdateEscalationPolicy will update the PD service escalation policy

Jump to

Keyboard shortcuts

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