models

package
v0.8.1 Latest Latest
Warning

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

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

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.

Package models holds all models that are needed across packages. We place these models in their own package so as to avoid circular dependencies between packages (which is a compile error).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitRepoFullName added in v0.4.7

func SplitRepoFullName(repoFullName string) (owner string, repo string)

SplitRepoFullName splits a repo full name up into its owner and repo name segments. If the repoFullName is malformed, may return empty strings for owner or repo. Ex. runatlantis/atlantis => (runatlantis, atlantis)

gitlab/subgroup/runatlantis/atlantis => (gitlab/subgroup/runatlantis, atlantis)

Types

type CommandName added in v0.5.0

type CommandName int

CommandName is which command to run.

const (
	// ApplyCommand is a command to run terraform apply.
	ApplyCommand CommandName = iota
	// PlanCommand is a command to run terraform plan.
	PlanCommand
)

func (CommandName) String added in v0.5.0

func (c CommandName) String() string

String returns the string representation of c.

type CommitStatus added in v0.4.3

type CommitStatus int

CommitStatus is the result of executing an Atlantis command for the commit. In Github the options are: error, failure, pending, success. In Gitlab the options are: failed, canceled, pending, running, success. We only support Failed, Pending, Success.

const (
	PendingCommitStatus CommitStatus = iota
	SuccessCommitStatus
	FailedCommitStatus
)

func (CommitStatus) String added in v0.4.3

func (s CommitStatus) String() string

type Plan

type Plan struct {
	// Project is the project this plan is for.
	Project Project
	// LocalPath is the absolute path to the plan on disk
	// (versus the relative path from the repo root).
	LocalPath string
}

Plan is the result of running an Atlantis plan command. This model is used to represent a plan on disk.

type PlanSuccess added in v0.4.14

type PlanSuccess struct {
	// TerraformOutput is the output from Terraform of running plan.
	TerraformOutput string
	// LockURL is the full URL to the lock held by this plan.
	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 Project

type Project struct {
	// RepoFullName is the owner and repo name, ex. "runatlantis/atlantis"
	RepoFullName string
	// Path to project root in the repo.
	// If "." then project is at root.
	// Never ends in "/".
	// todo: rename to RepoRelDir to match rest of project once we can separate
	// out how this is saved in boltdb vs. its usage everywhere else so we don't
	// break existing dbs.
	Path string
}

Project represents a Terraform project. Since there may be multiple Terraform projects in a single repo we also include Path to the project root relative to the repo root.

func NewProject

func NewProject(repoFullName string, path string) Project

NewProject constructs a Project. Use this constructor because it sets Path correctly.

func (Project) String added in v0.4.0

func (p Project) String() string

type ProjectCommandContext added in v0.4.0

type ProjectCommandContext struct {
	// ApplyCmd is the command that users should run to apply this plan. If
	// this is an apply then this will be empty.
	ApplyCmd string
	// ApplyRequirements is the list of requirements that must be satisfied
	// before we will run the apply stage.
	ApplyRequirements []string
	// AutoplanEnabled is true if automerge is enabled for the repo that this
	// project is in.
	AutomergeEnabled bool
	// AutoplanEnabled is true if autoplanning is enabled for this project.
	AutoplanEnabled bool
	// BaseRepo is the repository that the pull request will be merged into.
	BaseRepo Repo
	// CommentArgs are the extra arguments appended to comment,
	// ex. atlantis plan -- -target=resource
	CommentArgs []string
	// 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.
	HeadRepo Repo
	// Log is a logger that's been set up for this context.
	Log *logging.SimpleLogger
	// PullMergeable is true if the pull request for this project is able to be merged.
	PullMergeable bool
	// Pull is the pull request we're responding to.
	Pull PullRequest
	// ProjectName is the name of the project set in atlantis.yaml. If there was
	// no name this will be an empty string.
	ProjectName string
	// RepoConfigVersion is the version of the repo's atlantis.yaml file. If
	// there was no file, this will be 0.
	RepoConfigVersion int
	// RePlanCmd is the command that users should run to re-plan this project.
	// If this is an apply then this will be empty.
	RePlanCmd string
	// RepoRelDir is the directory of this project relative to the repo root.
	RepoRelDir string
	// Steps are the sequence of commands we need to run for this project and this
	// stage.
	Steps []valid.Step
	// TerraformVersion is the version of terraform we should use when executing
	// commands for this project. This can be set to nil in which case we will
	// use the default Atlantis terraform version.
	TerraformVersion *version.Version
	// User is the user that triggered this command.
	User User
	// Verbose is true when the user would like verbose output.
	Verbose bool
	// Workspace is the Terraform workspace this project is in. It will always
	// be set.
	Workspace string
}

ProjectCommandContext defines the context for a plan or apply stage that will be executed for a project.

type ProjectLock

type ProjectLock struct {
	// Project is the project that is being locked.
	Project Project
	// Pull is the pull request from which the command was run that
	// created this lock.
	Pull PullRequest
	// User is the username of the user that ran the command
	// that created this lock.
	User User
	// Workspace is the Terraform workspace that this
	// lock is being held against.
	Workspace string
	// Time is the time at which the lock was first created.
	Time time.Time
}

ProjectLock represents a lock on a project.

type ProjectPlanStatus added in v0.4.14

type ProjectPlanStatus int

ProjectPlanStatus is the status of where this project is at in the planning cycle.

const (
	// ErroredPlanStatus means that this plan has an error or the apply has an
	// error.
	ErroredPlanStatus ProjectPlanStatus = iota
	// PlannedPlanStatus means that a plan has been successfully generated but
	// not yet applied.
	PlannedPlanStatus
	// ErrorApplyStatus means that a plan has been generated but there was an
	// error while applying it.
	ErroredApplyStatus
	// AppliedPlanStatus means that a plan has been generated and applied
	// successfully.
	AppliedPlanStatus
)

func (ProjectPlanStatus) String added in v0.4.14

func (p ProjectPlanStatus) String() string

String returns a string representation of the status.

type ProjectResult added in v0.4.14

type ProjectResult struct {
	Command      CommandName
	RepoRelDir   string
	Workspace    string
	Error        error
	Failure      string
	PlanSuccess  *PlanSuccess
	ApplySuccess string
	ProjectName  string
}

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

func (ProjectResult) CommitStatus added in v0.5.0

func (p ProjectResult) CommitStatus() CommitStatus

CommitStatus returns the vcs commit status of this project result.

func (ProjectResult) IsSuccessful added in v0.4.14

func (p ProjectResult) IsSuccessful() bool

IsSuccessful returns true if this project result had no errors.

func (ProjectResult) PlanStatus added in v0.5.0

func (p ProjectResult) PlanStatus() ProjectPlanStatus

PlanStatus returns the plan status.

type ProjectStatus added in v0.4.14

type ProjectStatus struct {
	Workspace   string
	RepoRelDir  string
	ProjectName string
	// Status is the status of where this project is at in the planning cycle.
	Status ProjectPlanStatus
}

ProjectStatus is the status of a specific project.

type PullRequest

type PullRequest struct {
	// Num is the pull request number or ID.
	Num int
	// HeadCommit is a sha256 that points to the head of the branch that is being
	// pull requested into the base. If the pull request is from Bitbucket Cloud
	// the string will only be 12 characters long because Bitbucket Cloud
	// truncates its commit IDs.
	HeadCommit string
	// URL is the url of the pull request.
	// ex. "https://github.com/runatlantis/atlantis/pull/1"
	URL string
	// HeadBranch is the name of the head branch (the branch that is getting
	// merged into the base).
	HeadBranch string
	// BaseBranch is the name of the base branch (the branch that the pull
	// request is getting merged into).
	BaseBranch string
	// Author is the username of the pull request author.
	Author string
	// State will be one of Open or Closed.
	// Gitlab supports an additional "merged" state but Github doesn't so we map
	// merged to Closed.
	State PullRequestState
	// BaseRepo is the repository that the pull request will be merged into.
	BaseRepo Repo
}

PullRequest is a VCS pull request. GitLab calls these Merge Requests.

type PullRequestEventType added in v0.4.3

type PullRequestEventType int
const (
	OpenedPullEvent PullRequestEventType = iota
	UpdatedPullEvent
	ClosedPullEvent
	OtherPullEvent
)

func (PullRequestEventType) String added in v0.4.3

func (p PullRequestEventType) String() string

type PullRequestState added in v0.2.0

type PullRequestState int
const (
	OpenPullState PullRequestState = iota
	ClosedPullState
)

type PullStatus added in v0.4.14

type PullStatus struct {
	// Projects are the projects that have been modified in this pull request.
	Projects []ProjectStatus
	// Pull is the original pull request model.
	Pull PullRequest
}

PullStatus is the current status of a pull request that is in progress.

func (PullStatus) StatusCount added in v0.5.0

func (p PullStatus) StatusCount(status ProjectPlanStatus) int

StatusCount returns the number of projects that have status.

type Repo

type Repo struct {
	// FullName is the owner and repo name separated
	// by a "/", ex. "runatlantis/atlantis", "gitlab/subgroup/atlantis", "Bitbucket Server/atlantis".
	FullName string
	// Owner is just the repo owner, ex. "runatlantis" or "gitlab/subgroup".
	// This may contain /'s in the case of GitLab subgroups.
	// This may contain spaces in the case of Bitbucket Server.
	Owner string
	// Name is just the repo name, ex. "atlantis". This will never have
	// /'s in it.
	Name string
	// CloneURL is the full HTTPS url for cloning with username and token string
	// ex. "https://username:token@github.com/atlantis/atlantis.git".
	CloneURL string
	// SanitizedCloneURL is the full HTTPS url for cloning with the password
	// redacted.
	// ex. "https://user:<redacted>@github.com/atlantis/atlantis.git".
	SanitizedCloneURL string
	// VCSHost is where this repo is hosted.
	VCSHost VCSHost
}

Repo is a VCS repository.

func NewRepo added in v0.3.2

func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsUser string, vcsToken string) (Repo, error)

NewRepo constructs a Repo object. repoFullName is the owner/repo form, cloneURL can be with or without .git at the end ex. https://github.com/runatlantis/atlantis.git OR

https://github.com/runatlantis/atlantis

func (Repo) ID added in v0.7.0

func (r Repo) ID() string

ID returns the atlantis ID for this repo. ID is in the form: {vcs hostname}/{repoFullName}.

type User

type User struct {
	Username string
}

User is a VCS user. During an autoplan, the user will be the Atlantis API user.

type VCSHost added in v0.3.6

type VCSHost struct {
	// Hostname is the hostname of the VCS provider, ex. "github.com" or
	// "github-enterprise.example.com".
	Hostname string

	// Type is which type of VCS host this is, ex. GitHub or GitLab.
	Type VCSHostType
}

VCSHost is a Git hosting provider, for example GitHub.

type VCSHostType added in v0.3.6

type VCSHostType int
const (
	Github VCSHostType = iota
	Gitlab
	BitbucketCloud
	BitbucketServer
)

func (VCSHostType) String added in v0.3.6

func (h VCSHostType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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