configuration

package
v0.0.0-...-8fb4044 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JenkinsBaseURL is the base URL for the Jenkins CI server.
	JenkinsBaseURL = "https://leeroy.dockerproject.org/build/retry"

	// FailingCILabel is the label that indicates that a pull request is
	// failing for a legitimate reason and should be ignored.
	FailingCILabel = "status/failing-ci"

	// PouleToken is injected as an HTML comment in the body of all messages
	// posted by the tool itself.
	PouleToken = "AUTOMATED:POULE"

	// PouleConfigurationFile is the name of the special file at the root of the repository.
	PouleConfigurationFile = "poule.yml"
)

Variables

View Source
var GitHubEvents = []string{
	"commit_comment",
	"create",
	"delete",
	"deployment",
	"deployment_status",
	"fork",
	"gollum",
	"integration_installation",
	"integration_installation_repositories",
	"issue_comment",
	"issues",
	"member",
	"membership",
	"page_build",
	"public",
	"pull_request_review_comment",
	"pull_request",
	"push",
	"repository",
	"release",
	"status",
	"team_add",
	"watch",
}

GitHubEvents is the collection of valid GitHub events which can be used as triggers.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Triggers is the collection of GitHub events that should trigger the action. The keys must be
	// valid GitHub event types (e.g., "pull_request"), and the value must be a list of valid values
	// for the action field of the GitHub paylost (e.g., "created").
	Triggers Trigger `yaml:"triggers"`

	// Schedule is a cron expression (https://godoc.org/gopkg.in/robfig/cron.v2).
	Schedule string `yaml:"schedule"`

	// Operations to apply to all repositories when any trigger is met.
	Operations []OperationConfiguration `yaml:"operations"`
}

Action is the definition of an action: it describes operations to apply when any of the associated triggers are met.

func (Action) Validate

func (a Action) Validate(opValidator OperationValidator) error

Validate verifies the validity of the action definition.

type Actions

type Actions []Action

Actions is a collection of Action.

func (Actions) Validate

func (a Actions) Validate(opValidator OperationValidator) []error

Validate verifies the validity of the configuration.

type Config

type Config struct {
	RunDelay   time.Duration `yaml:"delay"`
	DryRun     bool          `yaml:"dry_run"`
	Repository string        `yaml:"repository"`
	Token      string        `yaml:"token"`
	TokenFile  string        `yaml:"token_file"`
}

Config is the main configuration object for poule.

func FromGlobalFlags

func FromGlobalFlags(c *cli.Context) *Config

FromGlobalFlags creates a configuration object from command line flags.

func (*Config) Delay

func (c *Config) Delay() time.Duration

Delay is a helper function to get the delay in a time.Duration format

func (*Config) SplitRepository

func (c *Config) SplitRepository() (string, string)

SplitRepository returns the username and repository associated with the configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate verifies the validity of the configuration object.

type OperationConfiguration

type OperationConfiguration struct {
	Type     string                 `yaml:"type"`
	Filters  map[string]interface{} `yaml:"filters"`
	Settings map[string]interface{} `yaml:"settings"`
}

OperationConfiguration describes an operation.

type OperationValidator

type OperationValidator interface {
	Validate(*OperationConfiguration) error
}

OperationValidator validates an operation definition. We need an interface here to avoid a direct dependency on the operations package.

type Server

type Server struct {
	Config      `yaml:",inline"`
	HTTPListen  string `yaml:"http_listen"`
	HTTPSecret  string `yaml:"http_secret"`
	LookupdAddr string `yaml:"nsq_lookupd"`
	Channel     string `yaml:"nsq_channel"`

	// Repositories maps GitHub repositories full names their corresponding
	// NSQ topic.
	Repositories map[string]string `yaml:"repositories"`

	// CommonActions defines the triggers and operations which apply to every configured repository.
	CommonActions []Action `yaml:"common_configuration"`
}

Server is the configuration object for the server mode.

func (Server) Validate

func (s Server) Validate(opValidator OperationValidator) []error

Validate verifies the validity of the configuration.

type StringSlice

type StringSlice []string

StringSlice is a slice of strings.

func (StringSlice) Contains

func (s StringSlice) Contains(item string) bool

Contains returns whether the StringSlice contains a given item.

type Trigger

type Trigger map[string]StringSlice

Trigger associates a GitHub event type (e.g., "issues", or "pull request") with a collection of corresponding actions (e.g., [ "opened", "reopened" ]).

func (Trigger) Contains

func (t Trigger) Contains(githubEvent, githubAction string) bool

Contains returns whether the triggers contains the specified (event, action) tuple.

func (Trigger) Validate

func (t Trigger) Validate() error

Validate verifies the validity of the trigger definition.

Jump to

Keyboard shortcuts

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