Documentation
¶
Index ¶
- Variables
- type Controller
- func (c *Controller) ComponentExists(component types.Component, team, project string, id int) bool
- func (c *Controller) CreatePullRequest(team, project, configFile string, componentsMap map[types.Component][]int) error
- func (c *Controller) HandlePullRequestWebhook(payload github.PullRequestPayload) error
- func (c *Controller) Poll(userConfigFiles []*config.UserConfigFile) error
- func (c *Controller) PollDatadog(ctx context.Context)
- func (c *Controller) ReloadUserConfigsAndPoll(userConfigFiles []*config.UserConfigFile) error
- type Option
- func WithDatadog(apiKey, appKey string, clientOpts ...client.Option) Option
- func WithGithub(owner, repo, githubAPI string, integrationID, installationID int, ...) Option
- func WithSSHGit(url, gitUser, gitEmail string, privateKeyBody []byte, ignoreKnownHosts bool) Option
- func WithSimplePollster(interval time.Duration, cfg *config.Config) Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDatadogNotInitialized is returned of the datadog is not initialized, but the polling // scheduler has been used. ErrDatadogNotInitialized = errors.New("datadog not initialized") )
var ( // ErrInvalidPullRequestPayload is returned if the payload invalid. ErrInvalidPullRequestPayload = errors.New("invalid pull request payload") )
Functions ¶
This section is empty.
Types ¶
type Controller ¶
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 ¶
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 ¶
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 ¶
WithSSHGit is an option used to configure an SSH transport for git.