keptn

package
v0.0.0-...-3da42c7 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetV1InClusterAPIMappings

func GetV1InClusterAPIMappings() api.InClusterAPIMappings

GetV1InClusterAPIMappings returns the InClusterAPIMappings.

func GetV2InClusterAPIMappings

func GetV2InClusterAPIMappings() v2.InClusterAPIMappings

GetV2InClusterAPIMappings returns the InClusterAPIMappings.

func TryGetProblemIDFromLabels

func TryGetProblemIDFromLabels(keptnEvent adapter.EventContentAdapter) string

TryGetProblemIDFromLabels tries to extract the problem ID from a "Problem URL" label or returns "" if it cannot be done. The value should be of form https://dynatracetenant/#problems/problemdetails;pid=8485558334848276629_1604413609638V2

Types

type BridgeURLCreator

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

BridgeURLCreator is the default implementation of BridgeURLCreatorInterface.

func NewBridgeURLCreator

func NewBridgeURLCreator(credentialsProvider credentials.KeptnCredentialsProvider) *BridgeURLCreator

NewBridgeURLCreator creates a new BridgeURLCreator.

func (*BridgeURLCreator) TryGetBridgeURLForEvaluation

func (c *BridgeURLCreator) TryGetBridgeURLForEvaluation(ctx context.Context, event adapter.EventContentAdapter) string

TryGetBridgeURLForEvaluation gets a backlink to the evaluation in Keptn Bridge if available or returns empty string.

func (*BridgeURLCreator) TryGetBridgeURLForKeptnContext

func (c *BridgeURLCreator) TryGetBridgeURLForKeptnContext(ctx context.Context, event adapter.EventContentAdapter) string

TryGetBridgeURLForKeptnContext gets a backlink to the Keptn Bridge if available or returns empty string.

type BridgeURLCreatorInterface

type BridgeURLCreatorInterface interface {
	TryGetBridgeURLForKeptnContext(ctx context.Context, event adapter.EventContentAdapter) string
	TryGetBridgeURLForEvaluation(ctx context.Context, event adapter.EventContentAdapter) string
}

BridgeURLCreatorInterface defines a component that can get URLs for Keptn contexts and evaluations.

type ClientFactory

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

ClientFactory is an implementation of ClientFactoryInterface.

func NewClientFactory

func NewClientFactory() (*ClientFactory, error)

NewClientFactory creates a new ClientFactory.

func (*ClientFactory) CreateEventClient

func (c *ClientFactory) CreateEventClient() EventClientInterface

CreateEventClient creates an EventClientInterface.

func (*ClientFactory) CreateResourceClient

func (c *ClientFactory) CreateResourceClient() ResourceClientInterface

CreateResourceClient creates a ResourceClientInterface.

func (*ClientFactory) CreateServiceClient

func (c *ClientFactory) CreateServiceClient() ServiceClientInterface

CreateServiceClient creates a ServiceClientInterface.

func (*ClientFactory) CreateUniformClient

func (c *ClientFactory) CreateUniformClient() UniformClientInterface

CreateUniformClient creates a UniformClientInterface.

type ClientFactoryInterface

type ClientFactoryInterface interface {
	CreateEventClient() EventClientInterface
	CreateResourceClient() ResourceClientInterface
	CreateServiceClient() ServiceClientInterface
	CreateUniformClient() UniformClientInterface
}

ClientFactoryInterface provides a factories for clients.

type ConfigClient

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

ConfigClient is the default implementation for ResourceClientInterface using a ConfigResourceClientInterface.

func NewConfigClient

func NewConfigClient(client ResourceClientInterface) *ConfigClient

NewConfigClient creates a new ConfigClient with a Keptn resource handler for the configuration service.

func (*ConfigClient) GetDynatraceConfig

func (rc *ConfigClient) GetDynatraceConfig(ctx context.Context, project string, stage string, service string) (string, error)

GetDynatraceConfig gets the Dynatrace config for the specified project, stage and service, checking first on the service, then stage and then project level.

func (*ConfigClient) GetSLIs

func (rc *ConfigClient) GetSLIs(ctx context.Context, project string, stage string, service string) (map[string]string, error)

GetSLIs gets the SLIs stored for the specified project, stage and service. First, the configuration of project-level is retrieved, which is then overridden by configuration on stage level, and then overridden by configuration on service level.

func (*ConfigClient) GetSLOs

func (rc *ConfigClient) GetSLOs(ctx context.Context, project string, stage string, service string) (*keptn.ServiceLevelObjectives, error)

GetSLOs gets the SLOs stored for exactly the specified project, stage and service.

func (*ConfigClient) GetShipyard

func (rc *ConfigClient) GetShipyard(ctx context.Context, project string) (*keptnv2.Shipyard, error)

GetShipyard returns the shipyard definition of a project.

func (*ConfigClient) UploadSLIs

func (rc *ConfigClient) UploadSLIs(ctx context.Context, project string, stage string, service string, slis *SLI) error

UploadSLIs uploads the SLIs for the specified project, stage and service.

func (*ConfigClient) UploadSLOs

func (rc *ConfigClient) UploadSLOs(ctx context.Context, project string, stage string, service string, slos *keptn.ServiceLevelObjectives) error

UploadSLOs uploads the SLOs for the specified project, stage and service.

type CredentialsChecker

type CredentialsChecker struct {
}

CredentialsChecker is an implementation of ConnectionCheckerInterface.

func NewDefaultCredentialsChecker

func NewDefaultCredentialsChecker() *CredentialsChecker

NewDefaultCredentialsChecker creates a new CredentialsChecker.

func (*CredentialsChecker) CheckCredentials

func (c *CredentialsChecker) CheckCredentials(keptnCredentials credentials.KeptnCredentials) error

CheckCredentials checks the provided credentials and returns an error if they are invalid.

type CredentialsCheckerInterface

type CredentialsCheckerInterface interface {
	// CheckCredentials checks if the provided credentials are valid.
	CheckCredentials(keptnCredentials credentials.KeptnCredentials) error
}

CredentialsCheckerInterface validates Keptn credentials.

type DynatraceConfigReaderInterface

type DynatraceConfigReaderInterface interface {
	// GetDynatraceConfig gets the Dynatrace config for the specified project, stage and service, checking first on the service, then stage and then project level.
	GetDynatraceConfig(ctx context.Context, project string, stage string, service string) (string, error)
}

DynatraceConfigReaderInterface provides functionality for getting a Dynatrace config.

type EventClient

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

EventClient implements offers EventClientInterface using api.EventsV1Interface.

func NewEventClient

func NewEventClient(client v2.EventsInterface) *EventClient

NewEventClient creates a new EventClient using the specified api.EventsV1Interface.

func (*EventClient) FindProblemID

func (c *EventClient) FindProblemID(ctx context.Context, keptnEvent adapter.EventContentAdapter) (string, error)

FindProblemID finds the Problem ID that is associated with the specified Keptn event or returns an error. It first parses it from Problem URL label and if it cant be found there it will look for the Initial Problem Open Event and gets the ID from there.

func (*EventClient) GetEventTimeStampForType

func (c *EventClient) GetEventTimeStampForType(ctx context.Context, event adapter.EventContentAdapter, eventType string) (*time.Time, error)

func (*EventClient) GetImageAndTag

GetImageAndTag extracts the image and tag associated with a deployment triggered as part of the sequence.

func (*EventClient) IsPartOfRemediation

func (c *EventClient) IsPartOfRemediation(ctx context.Context, event adapter.EventContentAdapter) (bool, error)

IsPartOfRemediation checks whether the sequence includes a remediation triggered event or returns an error.

type EventClientInterface

type EventClientInterface interface {
	// IsPartOfRemediation checks whether the sequence includes a remediation triggered event or returns an error.
	IsPartOfRemediation(ctx context.Context, event adapter.EventContentAdapter) (bool, error)

	// FindProblemID finds the Problem ID that is associated with the specified Keptn event or returns an error.
	FindProblemID(ctx context.Context, keptnEvent adapter.EventContentAdapter) (string, error)

	// GetImageAndTag extracts the image and tag associated with a deployment triggered as part of the sequence.
	GetImageAndTag(ctx context.Context, keptnEvent adapter.EventContentAdapter) common.ImageAndTag

	// GetEventTimeStampForType tries to get the time stamp of a certain event as part of the sequence.
	GetEventTimeStampForType(ctx context.Context, keptnEvent adapter.EventContentAdapter, eventType string) (*time.Time, error)
}

EventClientInterface encapsulates functionality built on top of Keptn events.

type EventSenderClient

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

EventSenderClient is an implementation of EventSenderClientInterface.

func NewEventSenderClient

func NewEventSenderClient(eventSender controlplane.EventSender) *EventSenderClient

NewEventSenderClient creates a new EventSenderClient using the specified event sender.

func (*EventSenderClient) SendCloudEvent

func (c *EventSenderClient) SendCloudEvent(factory adapter.CloudEventFactoryInterface) error

SendCloudEvent sends a cloud event from specified factory or returns an error.

type EventSenderClientInterface

type EventSenderClientInterface interface {
	// SendCloudEvent sends a cloud event from specified factory or returns an error.
	SendCloudEvent(factory adapter.CloudEventFactoryInterface) error
}

EventSenderClientInterface sends cloud events.

type ResourceClient

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

ResourceClient is the default implementation for the ResourceClientInterface using a Keptn api.ResourcesV1Interface.

func NewResourceClient

func NewResourceClient(client v2.ResourcesInterface) *ResourceClient

NewResourceClient creates a new ResourceClient using a api.ResourcesV1Interface.

func (*ResourceClient) GetProjectResource

func (rc *ResourceClient) GetProjectResource(ctx context.Context, project string, resourceURI string) (string, error)

GetProjectResource tries to retrieve a resource on project level.

func (*ResourceClient) GetResource

func (rc *ResourceClient) GetResource(ctx context.Context, project string, stage string, service string, resourceURI string) (string, error)

GetResource tries to find the first instance of a given resource on service, stage or project level.

func (*ResourceClient) GetServiceResource

func (rc *ResourceClient) GetServiceResource(ctx context.Context, project string, stage string, service string, resourceURI string) (string, error)

GetServiceResource tries to retrieve a resource on service level.

func (*ResourceClient) GetStageResource

func (rc *ResourceClient) GetStageResource(ctx context.Context, project string, stage string, resourceURI string) (string, error)

GetStageResource tries to retrieve a resource on stage level.

func (*ResourceClient) UploadResource

func (rc *ResourceClient) UploadResource(ctx context.Context, contentToUpload []byte, remoteResourceURI string, project string, stage string, service string) error

UploadResource tries to upload a resource.

type ResourceClientInterface

type ResourceClientInterface interface {
	// GetResource tries to find the first instance of a given resource on service, stage or project level.
	GetResource(ctx context.Context, project string, stage string, service string, resourceURI string) (string, error)

	// GetProjectResource tries to retrieve a resource on project level.
	GetProjectResource(ctx context.Context, project string, resourceURI string) (string, error)

	// GetStageResource tries to retrieve a resource on stage level.
	GetStageResource(ctx context.Context, project string, stage string, resourceURI string) (string, error)

	// GetServiceResource tries to retrieve a resource on service level.
	GetServiceResource(ctx context.Context, project string, stage string, service string, resourceURI string) (string, error)

	// UploadResource tries to upload a resource.
	UploadResource(ctx context.Context, contentToUpload []byte, remoteResourceURI string, project string, stage string, service string) error
}

ResourceClientInterface defines the methods for interacting with resources of Keptn's configuration service.

type ResourceEmptyError

type ResourceEmptyError ResourceError

ResourceEmptyError represents an error for a resource that was found, but is empty.

func (*ResourceEmptyError) Error

func (e *ResourceEmptyError) Error() string

Error returns a string representation of this error

type ResourceError

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

ResourceError represents an error for a resource that was not found.

type ResourceNotFoundError

type ResourceNotFoundError ResourceError

ResourceNotFoundError represents an error for a resource that was not found.

func NewResourceNotFoundError

func NewResourceNotFoundError(resourceURI string, project string, stage string, service string) *ResourceNotFoundError

NewResourceNotFoundError creates a new ResourceNotFoundError.

func (*ResourceNotFoundError) Error

func (e *ResourceNotFoundError) Error() string

Error returns a string representation of this error

type ResourceRetrievalFailedError

type ResourceRetrievalFailedError struct {
	ResourceError
	// contains filtered or unexported fields
}

ResourceRetrievalFailedError represents an error for a resource that could not be retrieved because of an error.

func (*ResourceRetrievalFailedError) Error

Error returns a string representation of this error.

func (*ResourceRetrievalFailedError) Unwrap

func (e *ResourceRetrievalFailedError) Unwrap() error

Unwrap returns the cause of the ResourceRetrievalFailedError.

type ResourceUploadFailedError

type ResourceUploadFailedError struct {
	ResourceError
	// contains filtered or unexported fields
}

ResourceUploadFailedError represents an error for a resource that could not be uploaded.

func (*ResourceUploadFailedError) Error

func (e *ResourceUploadFailedError) Error() string

Error returns a string representation of this error.

type SLI

type SLI struct {
	SpecVersion string            `yaml:"spec_version"`
	Indicators  map[string]string `yaml:"indicators"`
}

SLI struct for SLI.yaml

type SLIAndSLOReaderInterface

type SLIAndSLOReaderInterface interface {
	// GetSLIs gets the SLIs stored for the specified project, stage and service.
	// First, the configuration of project-level is retrieved, which is then overridden by configuration on stage level, and then overridden by configuration on service level.
	GetSLIs(ctx context.Context, project string, stage string, service string) (map[string]string, error)

	// GetSLOs gets the SLOs stored for exactly the specified project, stage and service.
	GetSLOs(ctx context.Context, project string, stage string, service string) (*keptn.ServiceLevelObjectives, error)
}

SLIAndSLOReaderInterface provides functionality for getting SLIs and SLOs.

type SLIAndSLOWriterInterface

type SLIAndSLOWriterInterface interface {
	// UploadSLIs uploads the SLIs for the specified project, stage and service.
	UploadSLIs(ctx context.Context, project string, stage string, service string, slis *SLI) error

	// UploadSLOs uploads the SLOs for the specified project, stage and service.
	UploadSLOs(ctx context.Context, project string, stage string, service string, slos *keptn.ServiceLevelObjectives) error
}

SLIAndSLOWriterInterface provides functionality for uploading SLIs and SLOs.

type SLOAndSLIClientInterface

type SLOAndSLIClientInterface interface {
	SLIAndSLOReaderInterface
	SLIAndSLOWriterInterface
}

SLOAndSLIClientInterface provides functionality for getting and uploading SLIs and SLOs.

type ServiceClient

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

ServiceClient is an implementation of ServiceClientInterface using api.ServicesV1Interface and APIClientInterface.

func NewServiceClient

func NewServiceClient(servicesClient v2.ServicesInterface, apiClient v2.APIInterface) *ServiceClient

NewServiceClient creates a new ServiceClient using the specified clients.

func (*ServiceClient) CreateServiceInProject

func (c *ServiceClient) CreateServiceInProject(ctx context.Context, project string, service string) error

CreateServiceInProject creates a service in all stages of the specified project or returns an error.

func (*ServiceClient) GetServiceNames

func (c *ServiceClient) GetServiceNames(ctx context.Context, project string, stage string) ([]string, error)

GetServiceNames gets the names of the services in the specified project and stage or returns an error.

type ServiceClientInterface

type ServiceClientInterface interface {
	// GetServiceNames gets the names of the services in the specified project and stage or returns an error.
	GetServiceNames(ctx context.Context, project string, stage string) ([]string, error)

	// CreateServiceInProject creates a service in all stages of the specified project or returns an error.
	CreateServiceInProject(ctx context.Context, project string, service string) error
}

ServiceClientInterface provides access to Keptn services.

type ShipyardReaderInterface

type ShipyardReaderInterface interface {
	// GetShipyard returns the shipyard definition of a project.
	GetShipyard(ctx context.Context, project string) (*keptnv2.Shipyard, error)
}

ShipyardReaderInterface provides functionality for getting a project's shipyard.

type UniformClient

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

UniformClient is an implementation of UniformClientInterface using api.UniformV1Interface.

func NewUniformClient

func NewUniformClient(client v2.UniformInterface) *UniformClient

NewUniformClient creates a new UniformClient using the specified api.UniformV1Interface.

func (*UniformClient) GetIntegrationIDByName

func (c *UniformClient) GetIntegrationIDByName(ctx context.Context, integrationName string) (string, error)

GetIntegrationIDByName gets the ID of the integration with specified name or returns an error if none or more than one exist with that name.

type UniformClientInterface

type UniformClientInterface interface {
	// GetIntegrationIDByName gets the ID of the integration with specified name or returns an error if none or more than one exist with that name.
	GetIntegrationIDByName(ctx context.Context, integrationName string) (string, error)
}

UniformClientInterface provides access to Keptn Uniform.

Jump to

Keyboard shortcuts

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