events

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: Apache-2.0 Imports: 35 Imported by: 60

Documentation

Overview

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

Index

Constants

View Source
const (
	WorkspaceFlagLong  = "workspace"
	WorkspaceFlagShort = "w"
	DirFlagLong        = "dir"
	DirFlagShort       = "d"
	ProjectFlagLong    = "project"
	ProjectFlagShort   = "p"
	VerboseFlagLong    = "verbose"
	VerboseFlagShort   = ""
	AtlantisExecutable = "atlantis"
)
View Source
const (
	PlanCommandTitle  = "Plan"
	ApplyCommandTitle = "Apply"
)
View Source
const (
	DefaultRepoRelDir = "."
	DefaultWorkspace  = "default"
)
View Source
const Wildcard = "*"

Wildcard matches 0-n of all characters except commas.

Variables

View Source
var DidYouMeanAtlantisComment = "Did you mean to use `atlantis` instead of `terraform`?"
View Source
var HelpComment = "```cmake\n" +
	`atlantis
Terraform automation and collaboration for your team

Usage:
  atlantis <command> [options] -- [terraform options]

Examples:
  # run plan in the root directory passing the -target flag to terraform
  atlantis plan -d . -- -target=resource

  # apply all unapplied plans
  atlantis apply

  # apply the plan for the root directory and staging workspace
  atlantis apply -d . -w staging

Commands:
  plan   Runs 'terraform plan' for the changes in this pull request.
         To plan a specific project, use the -d, -w and -p flags.
  apply  Runs 'terraform apply' on all unapplied plans.
         To only apply a specific plan, use the -d, -w and -p flags.
  help   View help.

Flags:
  -h, --help   help for atlantis

Use "atlantis [command] --help" for more information about a command.
`

Functions

This section is empty.

Types

type AutoplanCommand added in v0.4.0

type AutoplanCommand struct{}

func (AutoplanCommand) CommandName added in v0.4.0

func (c AutoplanCommand) CommandName() CommandName

func (AutoplanCommand) IsAutoplan added in v0.4.0

func (c AutoplanCommand) IsAutoplan() bool

func (AutoplanCommand) IsVerbose added in v0.4.0

func (c AutoplanCommand) IsVerbose() bool

type CommandContext

type CommandContext struct {
	// BaseRepo is the repository that the pull request will be merged into.
	BaseRepo models.Repo
	// HeadRepo is the repository that is getting merged into the BaseRepo.
	// If the pull request branch is from the same repository then HeadRepo will
	// be the same as BaseRepo.
	// See https://help.github.com/articles/about-pull-request-merges/.
	HeadRepo models.Repo
	Pull     models.PullRequest
	// User is the user that triggered this command.
	User models.User
	Log  *logging.SimpleLogger
}

CommandContext represents the context of a command that should be executed for a pull request.

type CommandInterface added in v0.4.0

type CommandInterface interface {
	CommandName() CommandName
	IsVerbose() bool
	IsAutoplan() bool
}

type CommandName

type CommandName int

CommandName is the type of command.

const (
	ApplyCommand CommandName = iota
	PlanCommand
)

func (CommandName) String

func (c CommandName) String() string

String returns the string representation of c.

type CommandResult added in v0.4.0

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

CommandResult is the result of running a Command.

type CommandRunner

type CommandRunner interface {
	// RunCommentCommand is the first step after a command request has been parsed.
	// It handles gathering additional information needed to execute the command
	// and then calling the appropriate services to finish executing the command.
	RunCommentCommand(baseRepo models.Repo, maybeHeadRepo *models.Repo, maybePull *models.PullRequest, user models.User, pullNum int, cmd *CommentCommand)
	RunAutoplanCommand(baseRepo models.Repo, headRepo models.Repo, pull models.PullRequest, user models.User)
}

CommandRunner is the first step after a command request has been parsed.

type CommentBuilder added in v0.4.5

type CommentBuilder interface {
	// BuildPlanComment builds a plan comment for the specified args.
	BuildPlanComment(repoRelDir string, workspace string, project string, commentArgs []string) string
	// BuildApplyComment builds an apply comment for the specified args.
	BuildApplyComment(repoRelDir string, workspace string, project string) string
}

CommentBuilder builds comment commands that can be used on pull requests.

type CommentCommand added in v0.4.0

type CommentCommand struct {
	// RepoRelDir is the path relative to the repo root to run the command in.
	// Will never end in "/". If empty then the comment specified no directory.
	RepoRelDir string
	// CommentArgs are the extra arguments appended to comment,
	// ex. atlantis plan -- -target=resource
	Flags   []string
	Name    CommandName
	Verbose bool
	// Workspace is the name of the Terraform workspace to run the command in.
	// If empty then the comment specified no workspace.
	Workspace string
	// ProjectName is the name of a project to run the command on. It refers to a
	// project specified in an atlantis.yaml file.
	// If empty then the comment specified no project.
	ProjectName string
}

func NewCommentCommand added in v0.4.0

func NewCommentCommand(repoRelDir string, flags []string, name CommandName, verbose bool, workspace string, project string) *CommentCommand

NewCommentCommand constructs a CommentCommand, setting all missing fields to defaults.

func (CommentCommand) CommandName added in v0.4.0

func (c CommentCommand) CommandName() CommandName

func (CommentCommand) IsAutoplan added in v0.4.0

func (c CommentCommand) IsAutoplan() bool

func (CommentCommand) IsForSpecificProject added in v0.4.5

func (c CommentCommand) IsForSpecificProject() bool

IsForSpecificProject returns true if the command is for a specific dir, workspace or project name. Otherwise it's a command like "atlantis plan" or "atlantis apply".

func (CommentCommand) IsVerbose added in v0.4.0

func (c CommentCommand) IsVerbose() bool

func (CommentCommand) String added in v0.4.0

func (c CommentCommand) String() string

type CommentParseResult added in v0.3.0

type CommentParseResult struct {
	// Command is the successfully parsed command. Will be nil if
	// CommentResponse or Ignore is set.
	Command *CommentCommand
	// CommentResponse is set when we should respond immediately to the command
	// for example for atlantis help.
	CommentResponse string
	// Ignore is set to true when we should just ignore this comment.
	Ignore bool
}

CommentParseResult describes the result of parsing a comment as a command.

type CommentParser added in v0.3.0

type CommentParser struct {
	GithubUser  string
	GithubToken string
	GitlabUser  string
	GitlabToken string
}

CommentParser implements CommentParsing

func (*CommentParser) BuildApplyComment added in v0.4.5

func (e *CommentParser) BuildApplyComment(repoRelDir string, workspace string, project string) string

BuildApplyComment builds an apply comment for the specified args.

func (*CommentParser) BuildPlanComment added in v0.4.5

func (e *CommentParser) BuildPlanComment(repoRelDir string, workspace string, project string, commentArgs []string) string

BuildPlanComment builds a plan comment for the specified args.

func (*CommentParser) Parse added in v0.3.0

func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) CommentParseResult

Parse parses the comment as an Atlantis command.

Valid commands contain:

  • The initial "executable" name, 'run' or 'atlantis' or '@GithubUser' where GithubUser is the API user Atlantis is running as.
  • Then a command, either 'plan', 'apply', or 'help'.
  • Then optional flags, then an optional separator '--' followed by optional extra flags to be appended to the terraform plan/apply command.

Examples: - atlantis help - run plan - @GithubUser plan -w staging - atlantis plan -w staging -d dir --verbose - atlantis plan --verbose -- -key=value -key2 value2

type CommentParsing added in v0.3.0

type CommentParsing interface {
	// Parse attempts to parse a pull request comment to see if it's an Atlantis
	// command.
	Parse(comment string, vcsHost models.VCSHostType) CommentParseResult
}

CommentParsing handles parsing pull request comments.

type CommitStatusUpdater added in v0.2.0

type CommitStatusUpdater interface {
	// Update updates the status of the head commit of pull.
	Update(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command CommandName) error
	// UpdateProjectResult updates the status of the head commit given the
	// state of response.
	UpdateProjectResult(ctx *CommandContext, commandName CommandName, res CommandResult) error
}

CommitStatusUpdater updates the status of a commit with the VCS host. We set the status to signify whether the plan/apply succeeds.

type CommonData

type CommonData struct {
	Command string
	Verbose bool
	Log     string
}

CommonData is data that all responses have.

type DefaultCommandRunner added in v0.4.0

type DefaultCommandRunner struct {
	VCSClient                vcs.ClientProxy
	GithubPullGetter         GithubPullGetter
	GitlabMergeRequestGetter GitlabMergeRequestGetter
	CommitStatusUpdater      CommitStatusUpdater
	EventParser              EventParsing
	MarkdownRenderer         *MarkdownRenderer
	Logger                   logging.SimpleLogging
	// AllowForkPRs controls whether we operate on pull requests from forks.
	AllowForkPRs bool
	// AllowForkPRsFlag is the name of the flag that controls fork PR's. We use
	// this in our error message back to the user on a forked PR so they know
	// how to enable this functionality.
	AllowForkPRsFlag      string
	ProjectCommandBuilder ProjectCommandBuilder
	ProjectCommandRunner  ProjectCommandRunner
}

DefaultCommandRunner is the first step when processing a comment command.

func (*DefaultCommandRunner) RunAutoplanCommand added in v0.4.0

func (c *DefaultCommandRunner) RunAutoplanCommand(baseRepo models.Repo, headRepo models.Repo, pull models.PullRequest, user models.User)

func (*DefaultCommandRunner) RunCommentCommand added in v0.4.0

func (c *DefaultCommandRunner) RunCommentCommand(baseRepo models.Repo, maybeHeadRepo *models.Repo, maybePull *models.PullRequest, user models.User, pullNum int, cmd *CommentCommand)

RunCommentCommand executes the command. We take in a pointer for maybeHeadRepo because for some events there isn't enough data to construct the Repo model and callers might want to wait until the event is further validated before making an additional (potentially wasteful) call to get the necessary data.

type DefaultCommitStatusUpdater added in v0.2.0

type DefaultCommitStatusUpdater struct {
	Client vcs.ClientProxy
}

DefaultCommitStatusUpdater implements CommitStatusUpdater.

func (*DefaultCommitStatusUpdater) Update added in v0.2.0

Update updates the commit status.

func (*DefaultCommitStatusUpdater) UpdateProjectResult added in v0.2.0

func (d *DefaultCommitStatusUpdater) UpdateProjectResult(ctx *CommandContext, commandName CommandName, res CommandResult) error

UpdateProjectResult updates the commit status based on the status of res.

type DefaultProjectCommandBuilder added in v0.4.0

type DefaultProjectCommandBuilder struct {
	ParserValidator     *yaml.ParserValidator
	ProjectFinder       ProjectFinder
	VCSClient           vcs.ClientProxy
	WorkingDir          WorkingDir
	WorkingDirLocker    WorkingDirLocker
	AllowRepoConfig     bool
	AllowRepoConfigFlag string
	PendingPlanFinder   *PendingPlanFinder
	CommentBuilder      CommentBuilder
}

func (*DefaultProjectCommandBuilder) BuildApplyCommands added in v0.4.5

func (*DefaultProjectCommandBuilder) BuildAutoplanCommands added in v0.4.0

func (*DefaultProjectCommandBuilder) BuildPlanCommands added in v0.4.5

type DefaultProjectCommandRunner added in v0.4.0

type DefaultProjectCommandRunner struct {
	Locker                  ProjectLocker
	LockURLGenerator        LockURLGenerator
	InitStepRunner          StepRunner
	PlanStepRunner          StepRunner
	ApplyStepRunner         StepRunner
	RunStepRunner           StepRunner
	PullApprovedChecker     runtime.PullApprovedChecker
	WorkingDir              WorkingDir
	Webhooks                WebhooksSender
	WorkingDirLocker        WorkingDirLocker
	RequireApprovalOverride bool
}

func (*DefaultProjectCommandRunner) Apply added in v0.4.0

func (*DefaultProjectCommandRunner) Plan added in v0.4.0

type DefaultProjectFinder added in v0.2.1

type DefaultProjectFinder struct{}

DefaultProjectFinder implements ProjectFinder.

func (*DefaultProjectFinder) DetermineProjects added in v0.3.0

func (p *DefaultProjectFinder) DetermineProjects(log *logging.SimpleLogger, modifiedFiles []string, repoFullName string, repoDir string) []models.Project

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

func (*DefaultProjectFinder) DetermineProjectsViaConfig added in v0.4.0

func (p *DefaultProjectFinder) DetermineProjectsViaConfig(log *logging.SimpleLogger, modifiedFiles []string, config valid.Config, repoDir string) ([]valid.Project, error)

DetermineProjectsViaConfig returns the list of projects that were modified based on the modifiedFiles and config. We look at the WhenModified section of the config for each project and see if the modifiedFiles matches. The list will be de-duplicated.

type DefaultProjectLocker added in v0.4.0

type DefaultProjectLocker struct {
	Locker locking.Locker
}

DefaultProjectLocker implements ProjectLocker.

func (*DefaultProjectLocker) TryLock added in v0.4.0

func (p *DefaultProjectLocker) TryLock(log *logging.SimpleLogger, pull models.PullRequest, user models.User, workspace string, project models.Project) (*TryLockResponse, error)

TryLock implements ProjectLocker.TryLock.

type DefaultWorkingDirLocker added in v0.4.0

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

DefaultWorkingDirLocker implements WorkingDirLocker.

func NewDefaultWorkingDirLocker added in v0.4.0

func NewDefaultWorkingDirLocker() *DefaultWorkingDirLocker

NewDefaultWorkingDirLocker is a constructor.

func (*DefaultWorkingDirLocker) TryLock added in v0.4.0

func (d *DefaultWorkingDirLocker) TryLock(repoFullName string, pullNum int, workspace string) (func(), error)

func (*DefaultWorkingDirLocker) TryLockPull added in v0.4.5

func (d *DefaultWorkingDirLocker) TryLockPull(repoFullName string, pullNum int) (func(), error)

func (*DefaultWorkingDirLocker) UnlockPull added in v0.4.5

func (d *DefaultWorkingDirLocker) UnlockPull(repoFullName string, pullNum int)

Unlock unlocks all workspaces for this pull.

type ErrData

type ErrData struct {
	Error string
	CommonData
}

ErrData is data about an error response.

type EventParser

type EventParser struct {
	GithubUser         string
	GithubToken        string
	GitlabUser         string
	GitlabToken        string
	BitbucketUser      string
	BitbucketToken     string
	BitbucketServerURL string
}

func (*EventParser) GetBitbucketCloudEventType added in v0.4.4

func (e *EventParser) GetBitbucketCloudEventType(eventTypeHeader string) models.PullRequestEventType

GetBitbucketCloudEventType translates the bitbucket header name into a pull request event type.

func (*EventParser) GetBitbucketServerEventType added in v0.4.4

func (e *EventParser) GetBitbucketServerEventType(eventTypeHeader string) models.PullRequestEventType

func (*EventParser) ParseBitbucketCloudCommentEvent added in v0.4.3

func (e *EventParser) ParseBitbucketCloudCommentEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, comment string, err error)

func (*EventParser) ParseBitbucketCloudPullEvent added in v0.4.3

func (e *EventParser) ParseBitbucketCloudPullEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)

func (*EventParser) ParseBitbucketServerCommentEvent added in v0.4.4

func (e *EventParser) ParseBitbucketServerCommentEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, comment string, err error)

func (*EventParser) ParseBitbucketServerPullEvent added in v0.4.4

func (e *EventParser) ParseBitbucketServerPullEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)

func (*EventParser) ParseGithubIssueCommentEvent added in v0.2.0

func (e *EventParser) ParseGithubIssueCommentEvent(comment *github.IssueCommentEvent) (baseRepo models.Repo, user models.User, pullNum int, err error)

func (*EventParser) ParseGithubPull added in v0.2.0

func (e *EventParser) ParseGithubPull(pull *github.PullRequest) (pullModel models.PullRequest, baseRepo models.Repo, headRepo models.Repo, err error)

func (*EventParser) ParseGithubPullEvent added in v0.4.0

func (e *EventParser) ParseGithubPullEvent(pullEvent *github.PullRequestEvent) (pull models.PullRequest, pullEventType models.PullRequestEventType, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)

func (*EventParser) ParseGithubRepo added in v0.2.0

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

func (*EventParser) ParseGitlabMergeCommentEvent added in v0.2.0

func (e *EventParser) ParseGitlabMergeCommentEvent(event gitlab.MergeCommentEvent) (baseRepo models.Repo, headRepo models.Repo, user models.User, err error)

ParseGitlabMergeCommentEvent creates Atlantis models out of a GitLab event.

func (*EventParser) ParseGitlabMergeEvent added in v0.2.0

func (e *EventParser) ParseGitlabMergeEvent(event gitlab.MergeEvent) (pull models.PullRequest, eventType models.PullRequestEventType, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)

func (*EventParser) ParseGitlabMergeRequest added in v0.2.0

func (e *EventParser) ParseGitlabMergeRequest(mr *gitlab.MergeRequest, baseRepo models.Repo) models.PullRequest

ParseGitlabMergeRequest parses the merge requests and returns a pull request model. We require passing in baseRepo because although can't get this information from the merge request, the only caller of this function already has that data. This means we can construct the pull request object correctly.

type EventParsing

type EventParsing interface {
	ParseGithubIssueCommentEvent(comment *github.IssueCommentEvent) (baseRepo models.Repo, user models.User, pullNum int, err error)
	// ParseGithubPull returns the pull request, base repo and head repo.
	ParseGithubPull(pull *github.PullRequest) (models.PullRequest, models.Repo, models.Repo, error)
	// ParseGithubPullEvent returns the pull request, head repo and user that
	// caused the event. Base repo is available as a field on PullRequest.
	ParseGithubPullEvent(pullEvent *github.PullRequestEvent) (pull models.PullRequest, pullEventType models.PullRequestEventType, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)
	ParseGithubRepo(ghRepo *github.Repository) (models.Repo, error)
	// ParseGitlabMergeEvent returns the pull request, base repo, head repo and
	// user that caused the event.
	ParseGitlabMergeEvent(event gitlab.MergeEvent) (pull models.PullRequest, pullEventType models.PullRequestEventType, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)
	ParseGitlabMergeCommentEvent(event gitlab.MergeCommentEvent) (baseRepo models.Repo, headRepo models.Repo, user models.User, err error)
	ParseGitlabMergeRequest(mr *gitlab.MergeRequest, baseRepo models.Repo) models.PullRequest
	ParseBitbucketCloudPullEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)
	ParseBitbucketCloudCommentEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, comment string, err error)
	GetBitbucketCloudEventType(eventTypeHeader string) models.PullRequestEventType
	ParseBitbucketServerPullEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, err error)
	ParseBitbucketServerCommentEvent(body []byte) (pull models.PullRequest, baseRepo models.Repo, headRepo models.Repo, user models.User, comment string, err error)
	GetBitbucketServerEventType(eventTypeHeader string) models.PullRequestEventType
}

type FailureData

type FailureData struct {
	Failure string
	CommonData
}

FailureData is data about a failure response.

type FileWorkspace

type FileWorkspace struct {
	DataDir string
	// TestingOverrideCloneURL can be used during testing to override the URL
	// that is cloned. If it's empty then we clone normally.
	TestingOverrideCloneURL string
}

FileWorkspace implements WorkingDir with the file system.

func (*FileWorkspace) Clone

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

Clone git clones headRepo, checks out the branch and then returns the absolute path to the root of the cloned repo. If the repo already exists and is at the right commit it does nothing. This is to support running commands in multiple dirs of the same repo without deleting existing plans.

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) DeleteForWorkspace added in v0.4.0

func (w *FileWorkspace) DeleteForWorkspace(r models.Repo, p models.PullRequest, workspace string) error

Delete deletes the working dir for this workspace.

func (*FileWorkspace) GetPullDir added in v0.4.5

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

GetPullDir returns the dir where the workspaces for this pull are cloned. If the dir doesn't exist it will return an error.

func (*FileWorkspace) GetWorkingDir added in v0.4.0

func (w *FileWorkspace) GetWorkingDir(r models.Repo, p models.PullRequest, workspace string) (string, error)

GetWorkingDir returns the path to the workspace for this repo and pull.

type GithubPullGetter added in v0.2.0

type GithubPullGetter interface {
	// GetPullRequest gets the pull request with id pullNum for the repo.
	GetPullRequest(repo models.Repo, pullNum int) (*github.PullRequest, error)
}

GithubPullGetter makes API calls to get pull requests.

type GitlabMergeRequestGetter added in v0.2.0

type GitlabMergeRequestGetter interface {
	// GetMergeRequest gets the pull request with the id pullNum for the repo.
	GetMergeRequest(repoFullName string, pullNum int) (*gitlab.MergeRequest, error)
}

GitlabMergeRequestGetter makes API calls to get merge requests.

type LockURLGenerator

type LockURLGenerator interface {
	GenerateLockURL(lockID string) string
}

type MarkdownRenderer added in v0.2.0

type MarkdownRenderer struct{}

MarkdownRenderer renders responses as markdown.

func (*MarkdownRenderer) Render added in v0.2.0

func (m *MarkdownRenderer) Render(res CommandResult, cmdName CommandName, log string, verbose bool) string

Render formats the data into a markdown string. nolint: interfacer

type PendingPlan added in v0.4.5

type PendingPlan struct {
	// RepoDir is the absolute path to the root of the repo that holds this
	// plan.
	RepoDir string
	// RepoRelDir is the relative path from the repo to the project that
	// the plan is for.
	RepoRelDir string
	// Workspace is the workspace this plan should execute in.
	Workspace string
}

PendingPlan is a plan that has not been applied.

type PendingPlanFinder added in v0.4.5

type PendingPlanFinder struct{}

PendingPlanFinder finds unapplied plans.

func (*PendingPlanFinder) Find added in v0.4.5

func (p *PendingPlanFinder) Find(pullDir string) ([]PendingPlan, error)

Find finds all pending plans in pullDir. pullDir should be the working directory where Atlantis will operate on this pull request. It's one level up from where Atlantis clones the repo for each workspace.

type PlanSuccess

type PlanSuccess struct {
	TerraformOutput string
	LockURL         string
	// RePlanCmd is the command that users should run to re-plan this project.
	RePlanCmd string
	// ApplyCmd is the command that users should run to apply this plan.
	ApplyCmd string
}

PlanSuccess is the result of a successful plan.

type ProjectCommandBuilder added in v0.4.0

type ProjectCommandBuilder interface {
	BuildAutoplanCommands(ctx *CommandContext) ([]models.ProjectCommandContext, error)
	BuildPlanCommands(ctx *CommandContext, commentCommand *CommentCommand) ([]models.ProjectCommandContext, error)
	BuildApplyCommands(ctx *CommandContext, commentCommand *CommentCommand) ([]models.ProjectCommandContext, error)
}

type ProjectCommandResult added in v0.4.0

type ProjectCommandResult struct {
	Error        error
	Failure      string
	PlanSuccess  *PlanSuccess
	ApplySuccess string
}

type ProjectCommandRunner added in v0.4.0

type ProjectCommandRunner interface {
	Plan(ctx models.ProjectCommandContext) ProjectResult
	Apply(ctx models.ProjectCommandContext) ProjectResult
}

type ProjectFinder

type ProjectFinder interface {
	// DetermineProjects returns the list of projects that were modified based on
	// the modifiedFiles. The list will be de-duplicated.
	DetermineProjects(log *logging.SimpleLogger, modifiedFiles []string, repoFullName string, repoDir string) []models.Project
	DetermineProjectsViaConfig(log *logging.SimpleLogger, modifiedFiles []string, config valid.Config, repoDir string) ([]valid.Project, error)
}

ProjectFinder determines what are the terraform project(s) within a repo.

type ProjectLocker added in v0.4.0

type ProjectLocker interface {
	// TryLock attempts to acquire the lock for this project. It returns true if the lock
	// was acquired. If it returns false, the lock was not acquired and the second
	// return value will be a string describing why the lock was not acquired.
	// The third return value is a function that can be called to unlock the
	// lock. It will only be set if the lock was acquired. Any errors will set
	// error.
	TryLock(log *logging.SimpleLogger, pull models.PullRequest, user models.User, workspace string, project models.Project) (*TryLockResponse, error)
}

ProjectLocker locks this project against other plans being run until this project is unlocked.

type ProjectResult

type ProjectResult struct {
	ProjectCommandResult
	RepoRelDir string
	Workspace  string
}

ProjectResult is the result of executing a plan/apply for a project.

func (ProjectResult) Status

func (p ProjectResult) Status() models.CommitStatus

Status returns the vcs commit status of this project result.

type ProjectResultTmplData added in v0.4.0

type ProjectResultTmplData struct {
	Workspace  string
	RepoRelDir string
	Rendered   string
}

type PullCleaner

type PullCleaner interface {
	// CleanUpPull deletes the workspaces used by the pull request on disk
	// and deletes any locks associated with this pull request for all workspaces.
	CleanUpPull(repo models.Repo, pull models.PullRequest) error
}

PullCleaner cleans up pull requests after they're closed/merged.

type PullClosedExecutor

type PullClosedExecutor struct {
	Locker     locking.Locker
	VCSClient  vcs.ClientProxy
	WorkingDir WorkingDir
}

PullClosedExecutor executes the tasks required to clean up a closed pull request.

func (*PullClosedExecutor) CleanUpPull

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

CleanUpPull cleans up after a closed pull request.

type RepoWhitelistChecker added in v0.4.0

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

RepoWhitelistChecker implements checking if repos are whitelisted to be used with this Atlantis.

func NewRepoWhitelistChecker added in v0.4.3

func NewRepoWhitelistChecker(whitelist string) (*RepoWhitelistChecker, error)

NewRepoWhitelistChecker constructs a new checker and validates that the whitelist isn't malformed.

func (*RepoWhitelistChecker) IsWhitelisted added in v0.4.0

func (r *RepoWhitelistChecker) IsWhitelisted(repoFullName string, vcsHostname string) bool

IsWhitelisted returns true if this repo is in our whitelist and false otherwise.

type ResultData

type ResultData struct {
	Results []ProjectResultTmplData
	CommonData
}

ResultData is data about a successful response.

type StepRunner added in v0.4.0

type StepRunner interface {
	Run(ctx models.ProjectCommandContext, extraArgs []string, path string) (string, error)
}

type TerraformExec added in v0.4.0

type TerraformExec interface {
	RunCommandWithVersion(log *logging.SimpleLogger, path string, args []string, v *version.Version, workspace string) (string, error)
}

type TryLockResponse added in v0.4.0

type TryLockResponse struct {
	// LockAcquired is true if the lock was acquired.
	LockAcquired bool
	// LockFailureReason is the reason why the lock was not acquired. It will
	// only be set if LockAcquired is false.
	LockFailureReason string
	// UnlockFn will unlock the lock created by the caller. This might be called
	// if there is an error later and the caller doesn't want to continue to
	// hold the lock.
	UnlockFn func() error
	// LockKey is the key for the lock if the lock was acquired.
	LockKey string
}

TryLockResponse is the result of trying to lock a project.

type WebhooksSender added in v0.4.0

type WebhooksSender interface {
	Send(log *logging.SimpleLogger, res webhooks.ApplyResult) error
}

type WorkingDir added in v0.4.0

type WorkingDir 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, workspace string) (string, error)
	// GetWorkingDir returns the path to the workspace for this repo and pull.
	// If workspace does not exist on disk, error will be of type os.IsNotExist.
	GetWorkingDir(r models.Repo, p models.PullRequest, workspace string) (string, error)
	GetPullDir(r models.Repo, p models.PullRequest) (string, error)
	// Delete deletes the workspace for this repo and pull.
	Delete(r models.Repo, p models.PullRequest) error
	DeleteForWorkspace(r models.Repo, p models.PullRequest, workspace string) error
}

WorkingDir handles the workspace on disk for running commands.

type WorkingDirLocker added in v0.4.0

type WorkingDirLocker interface {
	// TryLock tries to acquire a lock for this repo, workspace and pull.
	// It returns a function that should be used to unlock the workspace and
	// an error if the workspace is already locked. The error is expected to
	// be printed to the pull request.
	TryLock(repoFullName string, pullNum int, workspace string) (func(), error)
	// TryLockPull tries to acquire a lock for all the workspaces in this repo
	// and pull.
	// It returns a function that should be used to unlock the workspace and
	// an error if the workspace is already locked. The error is expected to
	// be printed to the pull request.
	TryLockPull(repoFullName string, pullNum int) (func(), error)
}

WorkingDirLocker is used to prevent multiple commands from executing at the same time for a single repo, pull, and workspace. We need to prevent this from happening because a specific repo/pull/workspace has a single workspace on disk and we haven't written Atlantis (yet) to handle concurrent execution within this workspace.

Directories

Path Synopsis
Package runtime holds code for actually running commands vs.
Package runtime holds code for actually running commands vs.
vcs
bitbucketcloud
Package bitbucketcloud holds code for Bitbucket Cloud aka (bitbucket.org).
Package bitbucketcloud holds code for Bitbucket Cloud aka (bitbucket.org).
raw
Package raw contains the golang representations of the YAML elements supported in atlantis.yaml.
Package raw contains the golang representations of the YAML elements supported in atlantis.yaml.
valid
Package valid contains the structs representing the atlantis.yaml config after it's been parsed and validated.
Package valid contains the structs representing the atlantis.yaml config after it's been parsed and validated.

Jump to

Keyboard shortcuts

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