controller

package
v0.0.0-...-61a96ab Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDatadogNotInitialized is returned of the datadog is not initialized, but the polling
	// scheduler has been used.
	ErrDatadogNotInitialized = errors.New("datadog not initialized")
)
View Source
var (
	// ErrInvalidPullRequestPayload is returned if the payload invalid.
	ErrInvalidPullRequestPayload = errors.New("invalid pull request payload")
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Controller is the business logic component of watchdog app.

func New

func New(cfg *config.Config, opts ...Option) (*Controller, error)

New is a constructor which returns a new instance of Controller.

func (*Controller) ComponentExists

func (c *Controller) ComponentExists(component types.Component, team, project string, id int) bool

ComponentExists checks if a component file on the master branch.

func (*Controller) CreatePullRequest

func (c *Controller) CreatePullRequest(team, project, configFile string, componentsMap map[types.Component][]int) error

CreatePullRequest takes a map of datadog components and their ids checks for the difference between current state and state from master branch and creates a pull requests if needed. This is the main controller's function.

func (*Controller) HandlePullRequestWebhook

func (c *Controller) HandlePullRequestWebhook(payload github.PullRequestPayload) error

HandlePullRequestWebhook takes a pull request payload, extracts the files affected by the change looks for config files and component files, reloads the user config if such files were affected and restores the datadog components if such files were affected.

func (*Controller) Poll

func (c *Controller) Poll(userConfigFiles []*config.UserConfigFile) error

Poll the datadog components

func (*Controller) PollDatadog

func (c *Controller) PollDatadog(ctx context.Context)

PollDatadog will start a datadog polling scheduler.

func (*Controller) ReloadUserConfigsAndPoll

func (c *Controller) ReloadUserConfigsAndPoll(userConfigFiles []*config.UserConfigFile) error

ReloadUserConfigsAndPoll will reload the user config nad run Poll()

type Option

type Option func(controller *Controller) error

Option defines a functional option for Controller.

func WithDatadog

func WithDatadog(apiKey, appKey string, clientOpts ...client.Option) Option

WithDatadog is an option used to configure a datadog client.

func WithGithub

func WithGithub(owner, repo, githubAPI string, integrationID, installationID int, privateKeyBody []byte) Option

WithGithub is an option used to configure a github client. more about github apps https://developer.github.com/v3/apps/

func WithSSHGit

func WithSSHGit(url, gitUser, gitEmail string, privateKeyBody []byte, ignoreKnownHosts bool) Option

WithSSHGit is an option used to configure an SSH transport for git.

func WithSimplePollster

func WithSimplePollster(interval time.Duration, cfg *config.Config) Option

WithSimplePollster is an option for simple implementation of datadog polling mechanism.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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