server

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: 25 Imported by: 21

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 LockRouteName = "lock-detail"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.1.3

type Config 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"`
}

Config configures Server. The mapstructure tags correspond to flags in cmd/server.go and are used when the config is parsed from a YAML file.

type EventsController added in v0.1.3

type EventsController struct {
	CommandRunner events.CommandRunner
	PullCleaner   events.PullCleaner
	Logger        *logging.SimpleLogger
	Parser        events.EventParsing
	// GithubWebHookSecret is the secret added to this webhook via the GitHub
	// UI that identifies this call as coming from GitHub. If empty, no
	// request validation is done.
	GithubWebHookSecret []byte
	Validator           GHRequestValidator
}

func (*EventsController) HandleCommentEvent added in v0.1.3

func (e *EventsController) HandleCommentEvent(w http.ResponseWriter, event *github.IssueCommentEvent, githubReqID string)

func (*EventsController) HandlePullRequestEvent added in v0.1.3

func (e *EventsController) HandlePullRequestEvent(w http.ResponseWriter, pullEvent *github.PullRequestEvent, githubReqID string)

HandlePullRequestEvent will delete any locks associated with the pull request

func (*EventsController) Post added in v0.1.3

type GHRequestValidation added in v0.1.3

type GHRequestValidation struct{}

GHRequestValidation implements the GHRequestValidator interface.

func (*GHRequestValidation) Validate added in v0.1.3

func (g *GHRequestValidation) Validate(r *http.Request, secret []byte) ([]byte, error)

Validate returns the JSON payload of the request. If secret is not empty, it checks that the request was signed by secret and returns an error if it was not. If secret is empty, it does not check if the request was signed.

type GHRequestValidator added in v0.1.3

type GHRequestValidator interface {
	// Validate returns the JSON payload of the request.
	// If secret is not empty, it checks that the request was signed
	// by secret and returns an error if it was not.
	// If secret is empty, it does not check if the request was signed.
	Validate(r *http.Request, secret []byte) ([]byte, error)
}

GHRequestValidator validates GitHub requests.

type LockDetailData added in v0.1.3

type LockDetailData struct {
	UnlockURL       string
	LockKeyEncoded  string
	LockKey         string
	RepoOwner       string
	RepoName        string
	PullRequestLink string
	LockedBy        string
	Environment     string
	Time            time.Time
}

type LockIndexData added in v0.1.3

type LockIndexData struct {
	LockURL      string
	RepoFullName string
	PullNum      int ``
	Time         time.Time
}

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 Server

type Server struct {
	Router             *mux.Router
	Port               int
	CommandHandler     *events.CommandHandler
	Logger             *logging.SimpleLogger
	Locker             locking.Locker
	AtlantisURL        string
	EventsController   *EventsController
	IndexTemplate      TemplateWriter
	LockDetailTemplate TemplateWriter
}

Server listens for GitHub events and runs the necessary Atlantis command

func NewServer

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

func (*Server) DeleteLock added in v0.1.3

func (s *Server) DeleteLock(w http.ResponseWriter, _ *http.Request, id string)

func (*Server) DeleteLockRoute added in v0.1.3

func (s *Server) DeleteLockRoute(w http.ResponseWriter, r *http.Request)

func (*Server) GetLock added in v0.1.3

func (s *Server) GetLock(w http.ResponseWriter, _ *http.Request, id string)

GetLock handles a lock detail page view. getLockRoute is expected to be called before. This function was extracted to make it testable.

func (*Server) GetLockRoute added in v0.1.3

func (s *Server) GetLockRoute(w http.ResponseWriter, r *http.Request)

func (*Server) Index added in v0.1.3

func (s *Server) Index(w http.ResponseWriter, _ *http.Request)

func (*Server) Start

func (s *Server) Start() error

type TemplateWriter added in v0.1.3

type TemplateWriter interface {
	Execute(wr io.Writer, data interface{}) error
}

Directories

Path Synopsis
github
Package github provides convenience wrappers around the go-github package.
Package github provides convenience wrappers around the go-github package.
locking
Package locking handles locking projects when they have in-progress runs.
Package locking handles locking projects when they have in-progress runs.
locking/boltdb
Package boltdb provides a locking implementation using Bolt.
Package boltdb provides a locking implementation using Bolt.
models
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.
terraform
Package terraform handles the actual running of terraform commands
Package terraform handles the actual running of terraform commands
Package logging handles logging throughout Atlantis.
Package logging handles logging throughout Atlantis.
Package recovery is aken from https://github.com/gin-gonic/gin/blob/master/recovery.go License of source below: Copyright 2014 Manu Martinez-Almeida.
Package recovery is aken from https://github.com/gin-gonic/gin/blob/master/recovery.go License of source below: Copyright 2014 Manu Martinez-Almeida.

Jump to

Keyboard shortcuts

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