server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package server is the main package for Atlantis. It handles the web server and executing commands that come in via pull request comments.

Index

Constants

View Source
const ProjectConfigFile = "atlantis.yaml"

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type ApplyExecutor

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

type Command

type Command struct {
	Verbose     bool
	Environment string
	Name        CommandName
}

type CommandContext

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

type CommandExtraArguments

type CommandExtraArguments struct {
	Name      string   `yaml:"command_name"`
	Arguments []string `yaml:"arguments"`
}

type CommandHandler

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

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
	Command        CommandName
}

type CommonData

type CommonData struct {
	Command string
	Verbose bool
	Log     string
}

type ConcurrentRunLocker

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

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

func NewConcurrentRunLocker

func NewConcurrentRunLocker() *ConcurrentRunLocker

func (*ConcurrentRunLocker) TryLock

func (c *ConcurrentRunLocker) 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 (*ConcurrentRunLocker) Unlock

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

Unlock unlocks the repo and environment

type ConfigReader

type ConfigReader struct{}

func (*ConfigReader) Exists

func (c *ConfigReader) Exists(execPath string) bool

func (*ConfigReader) Read

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

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)

func (*EventParser) ExtractCommentData

func (e *EventParser) ExtractCommentData(comment *github.IssueCommentEvent, ctx *CommandContext) 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 FailureData

type FailureData struct {
	Failure string
	CommonData
}

type GithubCommentRenderer

type GithubCommentRenderer struct{}

GithubCommentRenderer renders responses as GitHub comments

type GithubStatus

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

func (*GithubStatus) Update

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

func (*GithubStatus) UpdateProjectResult

func (g *GithubStatus) UpdateProjectResult(ctx *CommandContext, projectResults []ProjectResult) error

type HelpExecutor

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

type PlanExecutor

type PlanExecutor struct {

	// LockURL is a function that given a lock id will return a url for lock view
	LockURL func(id string) (url string)
	// contains filtered or unexported fields
}

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

func (*PlanExecutor) ModifiedProjects

func (p *PlanExecutor) ModifiedProjects(repoFullName string, modifiedFiles []string) []models.Project

ModifiedProjects returns the list of Terraform projects that have been changed due to the modified files

type PlanSuccess

type PlanSuccess struct {
	TerraformOutput string
	LockURL         string
}

type PostApply added in v0.1.1

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

type PostPlan added in v0.1.1

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

type PreApply

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

type PrePlan

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

type ProjectConfig

type ProjectConfig struct {
	PrePlan   PrePlan
	PostPlan  PostPlan
	PreApply  PreApply
	PostApply PostApply
	// TerraformVersion is the version specified in the config file or nil if version wasn't specified
	TerraformVersion *version.Version
	ExtraArguments   []CommandExtraArguments
}

func (*ProjectConfig) GetExtraArguments

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

type ProjectConfigYaml

type ProjectConfigYaml struct {
	PrePlan          PrePlan                 `yaml:"pre_plan"`
	PostPlan         PostPlan                `yaml:"post_plan"`
	PreApply         PreApply                `yaml:"pre_apply"`
	PostApply        PostApply               `yaml:"post_apply"`
	TerraformVersion string                  `yaml:"terraform_version"`
	ExtraArguments   []CommandExtraArguments `yaml:"extra_arguments"`
}

type ProjectResult

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

func (ProjectResult) Status

func (p ProjectResult) Status() Status

type PullClosedExecutor

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

func (*PullClosedExecutor) CleanUpPull

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

type RequestLogger

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

RequestLogger logs requests and their response codes

func NewRequestLogger

func NewRequestLogger(logger *logging.SimpleLogger) *RequestLogger

func (*RequestLogger) ServeHTTP

func (l *RequestLogger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type ResultData

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

type Server

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

Server listens for GitHub events and runs the necessary Atlantis command

func NewServer

func NewServer(config ServerConfig) (*Server, error)

func (*Server) Start

func (s *Server) Start() error

type ServerConfig

type ServerConfig struct {
	AtlantisURL         string `mapstructure:"atlantis-url"`
	DataDir             string `mapstructure:"data-dir"`
	GithubHostname      string `mapstructure:"gh-hostname"`
	GithubToken         string `mapstructure:"gh-token"`
	GithubUser          string `mapstructure:"gh-user"`
	GithubWebHookSecret string `mapstructure:"gh-webhook-secret"`
	LogLevel            string `mapstructure:"log-level"`
	Port                int    `mapstructure:"port"`
	RequireApproval     bool   `mapstructure:"require-approval"`
}

the mapstructure tags correspond to flags in cmd/server.go

type Status

type Status int
const (
	Pending Status = iota
	Success
	Failure
	Error
	PlanStep  = "plan"
	ApplyStep = "apply"
)

func (Status) String

func (s Status) String() string

type Workspace

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

func (*Workspace) Clone

func (w *Workspace) Clone(ctx *CommandContext) (string, error)

func (*Workspace) Delete

func (w *Workspace) Delete(repo models.Repo, pull models.PullRequest) error

Delete deletes the workspace for this repo and pull

func (*Workspace) GetWorkspace

func (w *Workspace) GetWorkspace(ctx *CommandContext) (string, error)

Jump to

Keyboard shortcuts

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