atlantis

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 3 Imported by: 0

README

Atlantis SDK for Go

GoDoc Go Report Card

Go library for creating custom run commands for Atlantis.

go get github.com/pbar1/atlantis-go

Usage

package main

import (
	"log"

	atlantis "github.com/pbar1/atlantis-go"
)

func main() {
	step, err := atlantis.NewRunStep()
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Pull request number: %d\n", step.PullNum)
	log.Printf("Terraform plan file: %s\n", step.Planfile)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentArgs

type CommentArgs []string

CommentArgs is a string slice.

func (*CommentArgs) Decode

func (a *CommentArgs) Decode(value string) error

Decode parses the Atlantis `COMMENT_ARGS` environment variable into a string slice. Flags are separated by commas and every character is escaped, ex. `atlantis plan -- arg1 arg2` will result in `COMMENT_ARGS=\a\r\g\1,\a\r\g\2`.

type RunStep

type RunStep struct {

	// The Terraform workspace used for this project, ex. `default`.
	// NOTE: if the step is executed before `init` then Atlantis won't have switched to this workspace yet.
	TerraformWorkspace string `envconfig:"WORKSPACE" required:"true"`

	// The version of Terraform used for this project, ex. `0.11.0`.
	TerraformVersion string `envconfig:"ATLANTIS_TERRAFORM_VERSION" required:"true"`

	// Absolute path to the current directory.
	AbsoluteProjectDir string `envconfig:"DIR" required:"true"`

	// Absolute path to the location where Atlantis expects the plan to either be generated (by plan) or already exist (if running apply). Can be used to override the built-in `plan`/`apply` commands, ex. run: `terraform plan -out $PLANFILE`.
	Planfile string `envconfig:"PLANFILE" required:"true"`

	// Name of the repository that the pull request will be merged into, ex. `atlantis`.
	BaseRepoName string `envconfig:"BASE_REPO_NAME" required:"true"`

	// Owner of the repository that the pull request will be merged into, ex. `runatlantis`.
	BaseRepoOwner string `envconfig:"BASE_REPO_OWNER" required:"true"`

	// Name of the repository that is getting merged into the base repository, ex. `atlantis`.
	HeadRepoName string `envconfig:"HEAD_REPO_NAME" required:"true"`

	// Owner of the repository that is getting merged into the base repository, ex. `acme-corp`.
	HeadRepoOwner string `envconfig:"HEAD_REPO_OWNER" required:"true"`

	// Name of the head branch of the pull request (the branch that is getting merged into the base)
	HeadBranchName string `envconfig:"HEAD_BRANCH_NAME" required:"true"`

	//  Name of the base branch of the pull request (the branch that the pull request is getting merged into)
	BaseBranchName string `envconfig:"BASE_BRANCH_NAME" required:"true"`

	// Name of the project configured in `atlantis.yaml`. If no project name is configured this will be an empty string.
	ProjectName string `envconfig:"PROJECT_NAME"`

	// Pull request number or ID, ex. `2`.
	PullNum int `envconfig:"PULL_NUM" required:"true"`

	// Username of the pull request author, ex. `acme-user`.
	PullAuthor string `envconfig:"PULL_AUTHOR" required:"true"`

	// The relative path of the project in the repository. For example if your project is in `dir1/dir2/` then this will be set to `dir1/dir2`. If your project is at the root this will be `"."`.
	RelativeProjectDir string `envconfig:"REPO_REL_DIR" required:"true"`

	// Username of the VCS user running command, ex. acme-user. During an `autoplan`, the user will be the Atlantis API user, ex. `atlantis`.
	Username string `envconfig:"USER_NAME" required:"true"`

	// Any additional flags passed in the comment on the pull request.
	CommentArgs CommentArgs `envconfig:"COMMENT_ARGS"`
}

RunStep is a struct populated with the current Atlantis custom run command runtime variables.

func NewRunStep

func NewRunStep() (*RunStep, error)

NewRunStep constructs a RunStep populated with the current Atlantis custom run command runtime variables.

Jump to

Keyboard shortcuts

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