events

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ProjectConfigFile = "atlantis.yaml"

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyExecutor

type ApplyExecutor struct {
	Github            github.Client
	Terraform         *terraform.Client
	RequireApproval   bool
	Run               *run.Run
	Workspace         Workspace
	ProjectPreExecute *ProjectPreExecute
}

func (*ApplyExecutor) Execute

func (a *ApplyExecutor) Execute(ctx *CommandContext) CommandResponse

type Command

type Command struct {
	Name        CommandName
	Environment string
	Verbose     bool
	Flags       []string
}

type CommandContext

type CommandContext struct {
	BaseRepo models.Repo
	HeadRepo models.Repo
	Pull     models.PullRequest
	User     models.User
	Command  *Command
	Log      *logging.SimpleLogger
}

type CommandHandler

type CommandHandler struct {
	PlanExecutor      Executor
	ApplyExecutor     Executor
	HelpExecutor      Executor
	LockURLGenerator  LockURLGenerator
	GHClient          github.Client
	GHStatus          GHStatusUpdater
	EventParser       EventParsing
	EnvLocker         EnvLocker
	GHCommentRenderer *GithubCommentRenderer
	Logger            *logging.SimpleLogger
}

CommandHandler is the first step when processing a comment command.

func (*CommandHandler) ExecuteCommand

func (c *CommandHandler) ExecuteCommand(ctx *CommandContext)

func (*CommandHandler) SetLockURL

func (c *CommandHandler) SetLockURL(f func(id string) (url string))

type CommandName

type CommandName int
const (
	Apply CommandName = iota
	Plan
	Help
)

func (CommandName) String

func (c CommandName) String() string

type CommandResponse

type CommandResponse struct {
	Error          error
	Failure        string
	ProjectResults []ProjectResult
}

type CommandRunner

type CommandRunner interface {
	ExecuteCommand(ctx *CommandContext)
}

type CommonData

type CommonData struct {
	Command string
	Verbose bool
	Log     string
}

type EnvLock

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

EnvLock is used to prevent multiple runs and commands from occurring at the same time for a single repo, pull, and environment

func NewEnvLock

func NewEnvLock() *EnvLock

func (*EnvLock) TryLock

func (c *EnvLock) TryLock(repoFullName string, env string, pullNum int) bool

TryLock returns true if you acquired the lock and false if someone else already has the lock

func (*EnvLock) Unlock

func (c *EnvLock) Unlock(repoFullName, env string, pullNum int)

Unlock unlocks the repo and environment

type EnvLocker

type EnvLocker interface {
	TryLock(repoFullName string, env string, pullNum int) bool
	Unlock(repoFullName, env string, pullNum int)
}

type ErrData

type ErrData struct {
	Error string
	CommonData
}

type EventParser

type EventParser struct {
	GithubUser  string
	GithubToken string
}

func (*EventParser) DetermineCommand

func (e *EventParser) DetermineCommand(comment *github.IssueCommentEvent) (*Command, error)

DetermineCommand parses the comment as an atlantis command. If it succeeds, it returns the command. Otherwise it returns error.

func (*EventParser) ExtractCommentData

func (e *EventParser) ExtractCommentData(comment *github.IssueCommentEvent) (baseRepo models.Repo, user models.User, pull models.PullRequest, err error)

func (*EventParser) ExtractPullData

func (e *EventParser) ExtractPullData(pull *github.PullRequest) (models.PullRequest, models.Repo, error)

func (*EventParser) ExtractRepoData

func (e *EventParser) ExtractRepoData(ghRepo *github.Repository) (models.Repo, error)

type EventParsing

type EventParsing interface {
	DetermineCommand(comment *github.IssueCommentEvent) (*Command, error)
	ExtractCommentData(comment *github.IssueCommentEvent) (baseRepo models.Repo, user models.User, pull models.PullRequest, err error)
	ExtractPullData(pull *github.PullRequest) (models.PullRequest, models.Repo, error)
	ExtractRepoData(ghRepo *github.Repository) (models.Repo, error)
}

type Executor

type Executor interface {
	Execute(ctx *CommandContext) CommandResponse
}

type FailureData

type FailureData struct {
	Failure string
	CommonData
}

type FileWorkspace

type FileWorkspace struct {
	DataDir string
}

func (*FileWorkspace) Clone

func (w *FileWorkspace) Clone(
	log *logging.SimpleLogger,
	baseRepo models.Repo,
	headRepo models.Repo,
	p models.PullRequest,
	env string) (string, error)

Clone git clones headRepo, checks out the branch and then returns the absolute path to the root of the cloned repo.

func (*FileWorkspace) Delete

func (w *FileWorkspace) Delete(r models.Repo, p models.PullRequest) error

Delete deletes the workspace for this repo and pull

func (*FileWorkspace) GetWorkspace

func (w *FileWorkspace) GetWorkspace(r models.Repo, p models.PullRequest, env string) (string, error)

type GHStatusUpdater

type GHStatusUpdater interface {
	Update(repo models.Repo, pull models.PullRequest, status Status, cmd *Command) error
	UpdateProjectResult(ctx *CommandContext, res CommandResponse) error
}

type GithubCommentRenderer

type GithubCommentRenderer struct{}

GithubCommentRenderer renders responses as GitHub comments

func (*GithubCommentRenderer) Render

func (g *GithubCommentRenderer) Render(res CommandResponse, cmdName CommandName, log string, verbose bool) string

Render formats the data into a string that can be commented back to GitHub. nolint: interfacer

type GithubStatus

type GithubStatus struct {
	Client github.Client
}

func (*GithubStatus) Update

func (g *GithubStatus) Update(repo models.Repo, pull models.PullRequest, status Status, cmd *Command) error

func (*GithubStatus) UpdateProjectResult

func (g *GithubStatus) UpdateProjectResult(ctx *CommandContext, res CommandResponse) error

type HelpExecutor

type HelpExecutor struct{}

func (*HelpExecutor) Execute

func (h *HelpExecutor) Execute(ctx *CommandContext) CommandResponse

type Hook

type Hook struct {
	Commands []string `yaml:"commands"`
}

Hook represents the commands that can be run at a certain stage.

type LockURLGenerator

type LockURLGenerator interface {
	// SetLockURL takes a function that given a lock id, will return a url
	// to view that lock
	SetLockURL(func(id string) (url string))
}

type ModifiedProjectFinder

type ModifiedProjectFinder interface {
	// FindModified returns the list of projects that were modified based on
	// the modifiedFiles. The list will be de-duplicated.
	FindModified(log *logging.SimpleLogger, modifiedFiles []string, repoFullName string) []models.Project
}

type PlanExecutor

type PlanExecutor struct {
	Github            github.Client
	Terraform         terraform.Runner
	Locker            locking.Locker
	LockURL           func(id string) (url string)
	Run               run.Runner
	Workspace         Workspace
	ProjectPreExecute ProjectPreExecutor
	ModifiedProject   ModifiedProjectFinder
}

PlanExecutor handles everything related to running terraform plan including integration with S3, Terraform, and GitHub

func (*PlanExecutor) Execute

func (p *PlanExecutor) Execute(ctx *CommandContext) CommandResponse

func (*PlanExecutor) SetLockURL

func (p *PlanExecutor) SetLockURL(f func(id string) (url string))

type PlanSuccess

type PlanSuccess struct {
	TerraformOutput string
	LockURL         string
}

type PreExecuteResult

type PreExecuteResult struct {
	ProjectResult    ProjectResult
	ProjectConfig    ProjectConfig
	TerraformVersion *version.Version
	LockResponse     locking.TryLockResponse
}

type ProjectConfig

type ProjectConfig struct {
	// PreInit is a slice of command strings to run prior to terraform init.
	PreInit []string
	// PreGet is a slice of command strings to run prior to terraform get.
	PreGet []string
	// PrePlan is a slice of command strings to run prior to terraform plan.
	PrePlan []string
	// PostPlan is a slice of command strings to run after terraform plan.
	PostPlan []string
	// PreApply is a slice of command strings to run prior to terraform apply.
	PreApply []string
	// PostApply is a slice of command strings to run after terraform apply.
	PostApply []string
	// TerraformVersion is the version specified in the config file or nil
	// if version wasn't specified.
	TerraformVersion *version.Version
	// contains filtered or unexported fields
}

ProjectConfig is a more usable version of projectConfigYAML that we can return to our callers. It holds the config for a project.

func (*ProjectConfig) GetExtraArguments

func (c *ProjectConfig) GetExtraArguments(command string) []string

GetExtraArguments returns the arguments that were specified to be appended to command in the project config file.

type ProjectConfigManager

type ProjectConfigManager struct{}

ProjectConfigManager deals with project config files that users can use to specify additional behaviour around how Atlantis executes for a project.

func (*ProjectConfigManager) Exists

func (c *ProjectConfigManager) Exists(projectPath string) bool

Exists returns true if an atlantis config file exists for the project at projectPath. projectPath is an absolute path to the project.

func (*ProjectConfigManager) Read

func (c *ProjectConfigManager) Read(execPath string) (ProjectConfig, error)

Read attempts to read the project config file for the project at projectPath. NOTE: projectPath is not the path to the actual config file. Returns the parsed ProjectConfig or error if unable to read.

type ProjectConfigReader

type ProjectConfigReader interface {
	// Exists returns true if a project config file exists at projectPath.
	Exists(projectPath string) bool
	// Read attempts to read the project config file for the project at projectPath.
	// NOTE: projectPath is not the path to the actual config file.
	// Returns the parsed ProjectConfig or error if unable to read.
	Read(projectPath string) (ProjectConfig, error)
}

ProjectConfigReader implements reading project config.

type ProjectFinder

type ProjectFinder struct{}

ProjectFinder identifies projects in a repo.

func (*ProjectFinder) FindModified

func (p *ProjectFinder) FindModified(log *logging.SimpleLogger, modifiedFiles []string, repoFullName string) []models.Project

FindModified returns the list of projects that were modified based on the modifiedFiles. The list will be de-duplicated.

type ProjectPreExecute

type ProjectPreExecute struct {
	Locker       locking.Locker
	ConfigReader ProjectConfigReader
	Terraform    terraform.Runner
	Run          run.Runner
}

func (*ProjectPreExecute) Execute

func (p *ProjectPreExecute) Execute(ctx *CommandContext, repoDir string, project models.Project) PreExecuteResult

type ProjectPreExecutor

type ProjectPreExecutor interface {
	Execute(ctx *CommandContext, repoDir string, project models.Project) PreExecuteResult
}

type ProjectResult

type ProjectResult struct {
	Path         string
	Error        error
	Failure      string
	PlanSuccess  *PlanSuccess
	ApplySuccess string
}

func (ProjectResult) Status

func (p ProjectResult) Status() Status

type PullCleaner

type PullCleaner interface {
	CleanUpPull(repo models.Repo, pull models.PullRequest) error
}

type PullClosedExecutor

type PullClosedExecutor struct {
	Locker    locking.Locker
	Github    github.Client
	Workspace Workspace
}

func (*PullClosedExecutor) CleanUpPull

func (p *PullClosedExecutor) CleanUpPull(repo models.Repo, pull models.PullRequest) error

type ResultData

type ResultData struct {
	Results map[string]string
	CommonData
}

type Status

type Status int
const (
	Pending Status = iota
	Success
	Failure
	Error
)

func (Status) String

func (s Status) String() string

type Workspace

type Workspace interface {
	// Clone git clones headRepo, checks out the branch and then returns the absolute
	// path to the root of the cloned repo.
	Clone(log *logging.SimpleLogger, baseRepo models.Repo, headRepo models.Repo, p models.PullRequest, env string) (string, error)
	GetWorkspace(r models.Repo, p models.PullRequest, env string) (string, error)
	Delete(r models.Repo, p models.PullRequest) error
}

Directories

Path Synopsis
Package github provides convenience wrappers around the go-github package.
Package github provides convenience wrappers around the go-github package.
Package locking handles locking projects when they have in-progress runs.
Package locking handles locking projects when they have in-progress runs.
boltdb
Package boltdb provides a locking implementation using Bolt.
Package boltdb provides a locking implementation using Bolt.
Package models holds all models that are needed across packages.
Package models holds all models that are needed across packages.
run
Package run handles running commands prior and following the regular Atlantis commands.
Package run handles running commands prior and following the regular Atlantis commands.
Package terraform handles the actual running of terraform commands
Package terraform handles the actual running of terraform commands

Jump to

Keyboard shortcuts

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