slack

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ThrowStatusWebhook

func ThrowStatusWebhook(cli Poster, url string, channel string, results *pb.Status, baseUrl string) error

ThrowStatusWebhook will create a status string from the protobuf message Status as defined in guideocelot.proto and

  will post the data to the slack url provided. If the status code is not 200 OK, then a WebhookRejectedErr will be generated and the error
	 body will contain the error returned from the slack api.

Types

type FakePoster

type FakePoster struct {
	// the data that was posted to FakePoster will be posted here
	PostBody []byte
	// response code to return
	ResponseCode int
	// body to return in response
	ResponseBody string
	// urls that have been posted
	PostedUrls []string
}

FakePoster is for testing anything related to posting slack webhooks

When you use it instead of http.DefaultClient in ThrowStatusWebhook the body posted to the client
will be saved to the PostBody attribute. FakePoster will reutrn the ResponseCode and ResponseBody
it will also save a list of urls that have been posted to it

func MakeFakePoster

func MakeFakePoster(desiredStatusCode int, desiredReturnBody string) *FakePoster

MakeFakePoster will create a FakePoster instance for you with the desired resopnse code and response body set

func (*FakePoster) Post

func (f *FakePoster) Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)

type Poster

type Poster interface {
	Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)
}

type WebhookRejectedErr

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

func WebhookRejected

func WebhookRejected(statusCode int, errorMsg string) *WebhookRejectedErr

WebhookRejected will return a RejectedError with the reason as the message to be returned by a call to Error()

func (*WebhookRejectedErr) Error

func (r *WebhookRejectedErr) Error() string

Jump to

Keyboard shortcuts

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