slackbot

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SlackAnnotationPrefix annotatation used on a PipelineActivity to associate a pipeline instance with a slack
	// messsage in a particular channel
	SlackAnnotationPrefix = "message.slack.jenkins-x.io"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONPatch

type JSONPatch []jsonpatch.JsonPatchOperation

func CreatePatch

func CreatePatch(before, after interface{}) (JSONPatch, error)

func (JSONPatch) MarshalJSON

func (p JSONPatch) MarshalJSON() ([]byte, error)

type MessageFormat

type MessageFormat struct {
	DashboardURL     string
	ShowRepository   bool
	ShowBuildURL     bool
	ShowBuildLogs    bool
	ShowReleaseNotes bool
	ShowSteps        bool
}

type MessageReference

type MessageReference struct {
	ChannelID string
	Timestamp string
}

type Options added in v0.0.54

type Options struct {
	SlackOptions
	MessageFormat     MessageFormat
	KubeClient        kubernetes.Interface
	JXClient          jenkinsv1client.Interface
	SlackClient       slacker.Interface
	ScmClient         *scm.Client
	SourceConfigs     *v1alpha1.SourceConfig
	Statuses          Statuses
	Timestamps        map[string]map[string]*MessageReference
	SlackUserResolver SlackUserResolver
	GitClient         gitclient.Interface
	CommandRunner     cmdrunner.CommandRunner
}

SlackBotOptions contains options for the SlackBot

func (*Options) NotifyPipeline added in v0.0.54

NotifyPipeline returns true if the given pipeline activity matches the configuration

func (*Options) PipelineMessage added in v0.0.54

func (o *Options) PipelineMessage(activity *jenkinsv1.PipelineActivity) error

func (*Options) ReviewRequestMessage added in v0.0.54

func (o *Options) ReviewRequestMessage(activity *jenkinsv1.PipelineActivity) error

func (*Options) Run added in v0.0.54

func (o *Options) Run() error

func (*Options) Validate added in v0.0.54

func (o *Options) Validate() error

Validate configures the clients for the slack bot

func (*Options) WatchActivities added in v0.0.54

func (o *Options) WatchActivities() chan struct{}

WatchActivities watches for pipeline activities

type PipelineDetails

type PipelineDetails struct {
	GitOwner      string
	GitRepository string
	BranchName    string
	Pipeline      string
	Build         string
	Context       string
}

func CreatePipelineDetails

func CreatePipelineDetails(activity *jenkinsv1.PipelineActivity) *PipelineDetails

CreatePipelineDetails creates a PipelineDetails object populated from the activity

type SlackOptions

type SlackOptions struct {
	Dir           string `env:"GIT_DIR"`
	SlackToken    string `env:"SLACK_TOKEN"`
	SlackURL      string `env:"SLACK_URL"`
	GitURL        string `env:"GIT_URL"`
	Name          string
	Namespace     string
	FakeTimestamp string
}

type SlackUserResolver

type SlackUserResolver struct {
	SlackClient  slacker.Interface
	JXClient     jenkninsv1client.Interface
	Namespace    string
	UserMappings map[string]string
}

SlackUserResolver allows slack users to be converted to Jenkins X users

func NewSlackUserResolver

func NewSlackUserResolver(slackClient slacker.Interface, jenkinsClient jenkninsv1client.Interface, namespace string) SlackUserResolver

NewSlackUserResolver creates a new struct to work with resolving slack user details

func (*SlackUserResolver) SlackProviderKey

func (r *SlackUserResolver) SlackProviderKey() string

SlackProviderKey returns the provider key for this SlackUserResolver

func (*SlackUserResolver) SlackUserLogin

func (r *SlackUserResolver) SlackUserLogin(user *jenkinsv1.UserDetails) (string, error)

SlackUserLogin returns the login for the slack provider, or an empty string if not found

type Status

type Status struct {
	Emoji string `json:"emoji,omitempty" protobuf:"bytes,1,name=emoji"`
	Text  string `json:"text,omitempty" protobuf:"bytes,2,name=text"`
}

type Statuses

type Statuses struct {
	Succeeded     *Status `json:"succeeded,omitempty" protobuf:"bytes,1,name=succeeded"`
	Failed        *Status `json:"failed,omitempty" protobuf:"bytes,2,name=failed"`
	NotApproved   *Status `json:"notApproved,omitempty" protobuf:"bytes,3,name=notApproved"`
	Approved      *Status `json:"approved,omitempty" protobuf:"bytes,4,name=approved"`
	Running       *Status `json:"running,omitempty" protobuf:"bytes,5,name=running"`
	Hold          *Status `json:"hold,omitempty" protobuf:"bytes,6,name=hold"`
	NeedsOkToTest *Status `json:"needsOkToTest,omitempty" protobuf:"bytes,7,name=needsOkToTest"`
	Merged        *Status `json:"merged,omitempty" protobuf:"bytes,8,name=merged"`
	Pending       *Status `json:"pending,omitempty" protobuf:"bytes,9,name=pending"`
	Errored       *Status `json:"errored,omitempty" protobuf:"bytes,10,name=errored"`
	Aborted       *Status `json:"aborted,omitempty" protobuf:"bytes,11,name=aborted"`
	LGTM          *Status `json:"lgtm,omitempty" protobuf:"bytes,12,name=lgtm"`
	Unknown       *Status `json:"unknown,omitempty" protobuf:"bytes,13,name=unknown"`
	Closed        *Status `json:"closed,omitempty" protobuf:"bytes,14,name=closed"` // Closed means the PR is closed but not merged
}

Jump to

Keyboard shortcuts

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