agent

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobResultSuccess   = "success"
	JobResultFailure   = "failure"
	JobResultCancelled = "cancelled"
	JobResultUnknown   = "unknown"
)
View Source
const DefaultJobInfoFile = "/tmp/github.env"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for Slack agent.

func NewClient

func NewClient(serverURL string) (*Client, error)

NewClient creates Client.

func (*Client) PostResult

func (c *Client) PostResult(ctx context.Context, channel, result string, extend bool, namespaceName, podName string, info *JobInfo) error

PostResult sends a result of CI job to server.

type JobInfo

type JobInfo struct {
	Actor          string `json:"actor,omitempty"`
	GitRef         string `json:"git_ref,omitempty"`
	JobID          string `json:"job_id,omitempty"`
	PullRequestNum int    `json:"pull_request_number,omitempty"`
	Repository     string `json:"repository,omitempty"`
	RunID          int    `json:"run_id,omitempty"`
	RunNumber      int    `json:"run_number,omitempty"`
	WorkflowName   string `json:"workflow_name,omitempty"`
}

JobInfo represents information about a CI job.

func GetJobInfo

func GetJobInfo() (*JobInfo, error)

GetJobInfo reads environment variables and creates JobInfo.

func GetJobInfoFromFile

func GetJobInfoFromFile(file string) (*JobInfo, error)

func (*JobInfo) BranchTagURL

func (info *JobInfo) BranchTagURL() string

func (*JobInfo) PullRequestURL

func (info *JobInfo) PullRequestURL() string

func (*JobInfo) RepositoryURL

func (info *JobInfo) RepositoryURL() string

func (*JobInfo) WorkflowURL

func (info *JobInfo) WorkflowURL() string

type Server

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

Server receives requests from clients and communicates with Slack.

func NewServer

func NewServer(logger logr.Logger, listenAddr string, defaultChannel string, appToken, botToken string, devMode bool, verbose bool) (*Server, error)

NewServer creates slack agent server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the slack agent server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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