webhooks

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: Apache-2.0 Imports: 7 Imported by: 116

Documentation

Overview

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Index

Constants

View Source
const ApplyEvent = "apply"
View Source
const SlackKind = "slack"

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResult

type ApplyResult struct {
	Workspace string
	Repo      models.Repo
	Pull      models.PullRequest
	User      models.User
	Success   bool
}

ApplyResult is the result of a terraform apply.

type Config

type Config struct {
	Event          string
	WorkspaceRegex string
	Kind           string
	Channel        string
}

type DefaultSlackClient

type DefaultSlackClient struct {
	Slack UnderlyingSlackClient
	Token string
}

func (*DefaultSlackClient) AuthTest

func (d *DefaultSlackClient) AuthTest() error

func (*DefaultSlackClient) ChannelExists

func (d *DefaultSlackClient) ChannelExists(channelName string) (bool, error)

func (*DefaultSlackClient) PostMessage

func (d *DefaultSlackClient) PostMessage(channel string, applyResult ApplyResult) error

func (*DefaultSlackClient) TokenIsSet

func (d *DefaultSlackClient) TokenIsSet() bool

type MultiWebhookSender

type MultiWebhookSender struct {
	Webhooks []Sender
}

MultiWebhookSender sends multiple webhooks for each one it's configured for.

func NewMultiWebhookSender

func NewMultiWebhookSender(configs []Config, client SlackClient) (*MultiWebhookSender, error)

func (*MultiWebhookSender) Send

Send sends the webhook using its Webhooks.

type Sender

type Sender interface {
	// Send sends the webhook (if the implementation thinks it should).
	Send(log *logging.SimpleLogger, applyResult ApplyResult) error
}

Sender sends webhooks.

type SlackClient

type SlackClient interface {
	AuthTest() error
	TokenIsSet() bool
	ChannelExists(channelName string) (bool, error)
	PostMessage(channel string, applyResult ApplyResult) error
}

SlackClient handles making API calls to Slack.

func NewSlackClient

func NewSlackClient(token string) SlackClient

type SlackWebhook

type SlackWebhook struct {
	Client         SlackClient
	WorkspaceRegex *regexp.Regexp
	Channel        string
}

SlackWebhook sends webhooks to Slack.

func NewSlack

func NewSlack(r *regexp.Regexp, channel string, client SlackClient) (*SlackWebhook, error)

func (*SlackWebhook) Send

func (s *SlackWebhook) Send(log *logging.SimpleLogger, applyResult ApplyResult) error

Send sends the webhook to Slack if the workspace matches the regex.

type UnderlyingSlackClient

type UnderlyingSlackClient interface {
	AuthTest() (response *slack.AuthTestResponse, error error)
	GetChannels(excludeArchived bool) ([]slack.Channel, error)
	PostMessage(channel, text string, parameters slack.PostMessageParameters) (string, string, error)
}

UnderlyingSlackClient wraps the nlopes/slack.Client implementation so we can mock it during tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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