Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Mergin master to 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PePe (Jose) Amengual committed Jun 2, 2020
2 parents a8c6563 + 6e0f265 commit 48fbde5
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 20 deletions.
76 changes: 75 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,76 @@
# v0.13.0

## Description
This release enables support for running plans and applies in parallel **only when using Terraform workspaces**.
It also enables graceful shutdown for Atlantis where it waits for in-progress plans and applies to complete.
See below for the complete list.

## Features
* Upgrade default Terraform version in Docker image to 0.12.26.
* Add support for parallel plans and applies ([#926](https://github.com/runatlantis/atlantis/pull/926) by @Fauzyy)

Running in parallel is only supported if you're using workspaces to separate your projects.
Projects in separate directories can **not** be run in parallel currently.
To use, set

```yaml
parallel_plan: true
parallel_apply: true
```
In your repo-level `atlantis.yaml` file.
* Add support for graceful shutdown ([#1051](https://github.com/runatlantis/atlantis/pull/1051) by @benoit74).
When Atlantis receive a SIGINT or SIGTERM it won't shut down immediately. It will wait for
in-progress plans and applies to complete. Any new actions, e.g. comments or autoplans
will be refused and an error comment will be posted to the PR indicating that Atlantis is shutting
down and the user should try again later.

In addition, a new `/status` endpoint has been added that currently only returns
the number of in-progress operations and whether the server is shutting down.

* GitHub: A new flag `--allow-draft-prs` has been added that will re-enable the ability
for users to run plan and apply on GitHub draft PRs. This ability was removed in
v0.12.0. ([#1053](https://github.com/runatlantis/atlantis/pull/1053) by @cket)
* GitHub: Preserve original commit message when automerging ([#1049](https://github.com/runatlantis/atlantis/pull/1049) by @pratikmallya).

This change removes the `[Atlantis] Automatically merging after successful apply` commit message
and instead has GitHub autogenerate the commit message similarly to how it would when
you click the "Merge" button in the UI.
* Change log level for HTTP requests from INFO to DBUG, e.g.
```
2020/05/26 12:16:20+0000 [INFO] server: GET /healthz – respond HTTP 200
2020/05/26 12:16:36+0000 [INFO] server: GET /healthz – from <IP>
```
([#1056](https://github.com/runatlantis/atlantis/pull/1056) by @tammert)
* GitLab: Use correct link to merge requests (previously used `#<num>` instead of `!<num>`) ([#1059](https://github.com/runatlantis/atlantis/pull/1059) by @EppO)
## Bugfixes
* Azure DevOps: Project links link to pull requests now (Fixes [#957](https://github.com/runatlantis/atlantis/issues/957) by @mcdafydd)
* GitHub: Release locks when GitHub draft PRs are closed ([#1038](https://github.com/runatlantis/atlantis/pull/1038) by @andrewring)
* Ensure git-lfs is in our Docker image (Fixes [#1054](https://github.com/runatlantis/atlantis/pull/1054))
## Backwards Incompatibilities / Notes:
* If you're using the Atlantis Docker image and aren't setting the `--default-tf-version` flag
then the default version of Terraform will now be 0.12.26. Simply set the above
flag to your desired default version to avoid any issues.
* HTTP requests are now logged as DBUG instead of INFO to reduce log spam. If you
still want to see these logs you must run with `--log-level=debug`.
* Atlantis will no longer immediately shutdown when it receives a SIGINT or SIGTERM,
it will now wait for in-progress plans and applies to complete. To stop Atlantis
without waiting, send a SIGKILL.
## Downloads
* [atlantis_darwin_amd64.zip](https://github.com/runatlantis/atlantis/releases/download/v0.13.0/atlantis_darwin_amd64.zip)
* [atlantis_linux_386.zip](https://github.com/runatlantis/atlantis/releases/download/v0.13.0/atlantis_linux_386.zip)
* [atlantis_linux_amd64.zip](https://github.com/runatlantis/atlantis/releases/download/v0.13.0/atlantis_linux_amd64.zip)
* [atlantis_linux_arm.zip](https://github.com/runatlantis/atlantis/releases/download/v0.13.0/atlantis_linux_arm.zip)
## Docker
[`runatlantis/atlantis:v0.13.0`](https://hub.docker.com/r/runatlantis/atlantis/tags/)
## Diff v0.12.0..v0.13.0
https://github.com/runatlantis/atlantis/compare/v0.12.0...v0.13.0
# v0.12.0
## Description
Expand All @@ -24,6 +97,7 @@ a host of other small features and fags.
## Backwards Incompatibilities / Notes:
* GitHub draft PRs are now ignored until they're marked "ready for review" and opened as regular PRs.
**NOTE: ** This functionality was added back in Atlantis v0.13.0 via the `--allow-draft-prs` flag.
* If you're using the Atlantis Docker image and aren't setting the `--default-tf-version` flag
then the default version of Terraform will now be 0.12.24. Simply set the above
flag to your desired default version to avoid any issues.
Expand All @@ -38,7 +112,7 @@ a host of other small features and fags.
[`runatlantis/atlantis:v0.12.0`](https://hub.docker.com/r/runatlantis/atlantis/tags/)
## Diff v0.11.1..v0.12.0
https://github.com/runatlantis/atlantis/compare/v0.11.0...v0.12.0
https://github.com/runatlantis/atlantis/compare/v0.11.1...v0.12.0
# v0.11.1
Expand Down
2 changes: 1 addition & 1 deletion kustomize/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
fsGroup: 1000 # Atlantis group (1000) read/write access to volumes.
containers:
- name: atlantis
image: runatlantis/atlantis:v0.12.0
image: runatlantis/atlantis:v0.13.0
env:
- name: ATLANTIS_DATA_DIR
value: /atlantis
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/spf13/viper"
)

const atlantisVersion = "0.12.0-multienv-ght3"
const atlantisVersion = "0.12.0-multienv-ght"

func main() {

Expand Down
1 change: 1 addition & 0 deletions runatlantis.io/docs/custom-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ Or a custom command
* `PROJECT_NAME` - Name of the project configured in `atlantis.yaml`. If no project name is configured this will be an empty string.
* `PULL_NUM` - Pull request number or ID, ex. `2`.
* `PULL_AUTHOR` - Username of the pull request author, ex. `acme-user`.
* `REPO_REL_DIR` - 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 `"."`.
* `USER_NAME` - Username of the VCS user running command, ex. `acme-user`. During an autoplan, the user will be the Atlantis API user, ex. `atlantis`.
* `COMMENT_ARGS` - Any additional flags passed in the comment on the pull request. 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`.
Expand Down
1 change: 1 addition & 0 deletions server/events/runtime/run_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, pa
"PROJECT_NAME": ctx.ProjectName,
"PULL_AUTHOR": ctx.Pull.Author,
"PULL_NUM": fmt.Sprintf("%d", ctx.Pull.Num),
"REPO_REL_DIR": ctx.RepoRelDir,
"USER_NAME": ctx.User.Username,
"WORKSPACE": ctx.Workspace,
}
Expand Down
4 changes: 2 additions & 2 deletions server/events/runtime/run_step_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func TestRunStepRunner_Run(t *testing.T) {
ExpOut: "workspace=myworkspace version=0.11.0 dir=$DIR planfile=$DIR/my::project::name-myworkspace.tfplan project=my/project/name\n",
},
{
Command: "echo base_repo_name=$BASE_REPO_NAME base_repo_owner=$BASE_REPO_OWNER head_repo_name=$HEAD_REPO_NAME head_repo_owner=$HEAD_REPO_OWNER head_branch_name=$HEAD_BRANCH_NAME base_branch_name=$BASE_BRANCH_NAME pull_num=$PULL_NUM pull_author=$PULL_AUTHOR",
ExpOut: "base_repo_name=basename base_repo_owner=baseowner head_repo_name=headname head_repo_owner=headowner head_branch_name=add-feat base_branch_name=master pull_num=2 pull_author=acme\n",
Command: "echo base_repo_name=$BASE_REPO_NAME base_repo_owner=$BASE_REPO_OWNER head_repo_name=$HEAD_REPO_NAME head_repo_owner=$HEAD_REPO_OWNER head_branch_name=$HEAD_BRANCH_NAME base_branch_name=$BASE_BRANCH_NAME pull_num=$PULL_NUM pull_author=$PULL_AUTHOR repo_rel_dir=$REPO_REL_DIR",
ExpOut: "base_repo_name=basename base_repo_owner=baseowner head_repo_name=headname head_repo_owner=headowner head_branch_name=add-feat base_branch_name=master pull_num=2 pull_author=acme repo_rel_dir=mydir\n",
},
{
Command: "echo user_name=$USER_NAME",
Expand Down
11 changes: 10 additions & 1 deletion server/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs/common"
"github.com/runatlantis/atlantis/server/logging"

"github.com/Laisky/graphql"
"github.com/google/go-github/v28/github"
Expand All @@ -38,10 +39,11 @@ type GithubClient struct {
client *github.Client
v4MutateClient *graphql.Client
ctx context.Context
logger *logging.SimpleLogger
}

// NewGithubClient returns a valid GitHub client.
func NewGithubClient(hostname string, user string, pass string) (*GithubClient, error) {
func NewGithubClient(hostname string, user string, pass string, logger *logging.SimpleLogger) (*GithubClient, error) {
tp := github.BasicAuthTransport{
Username: strings.TrimSpace(user),
Password: strings.TrimSpace(pass),
Expand Down Expand Up @@ -84,6 +86,7 @@ func NewGithubClient(hostname string, user string, pass string) (*GithubClient,
client: client,
v4MutateClient: v4MutateClient,
ctx: context.Background(),
logger: logger,
}, nil
}

Expand All @@ -99,6 +102,7 @@ func (g *GithubClient) GetModifiedFiles(repo models.Repo, pull models.PullReques
if nextPage != 0 {
opts.Page = nextPage
}
g.logger.Debug("GET /repos/%v/%v/pulls/%d/files", repo.Owner, repo.Name, pull.Num)
pageFiles, resp, err := g.client.PullRequests.ListFiles(g.ctx, repo.Owner, repo.Name, pull.Num, &opts)
if err != nil {
return files, err
Expand Down Expand Up @@ -131,6 +135,7 @@ func (g *GithubClient) CreateComment(repo models.Repo, pullNum int, comment stri

comments := common.SplitComment(comment, maxCommentLength, sepEnd, sepStart)
for _, c := range comments {
g.logger.Debug("POST /repos/%v/%v/issues/%d/comments", repo.Owner, repo.Name, pullNum)
_, _, err := g.client.Issues.CreateComment(g.ctx, repo.Owner, repo.Name, pullNum, &github.IssueComment{Body: &c})
if err != nil {
return err
Expand All @@ -143,6 +148,7 @@ func (g *GithubClient) HidePrevPlanComments(repo models.Repo, pullNum int) error
var allComments []*github.IssueComment
nextPage := 0
for {
g.logger.Debug("GET /repos/%v/%v/issues/%d/comments", repo.Owner, repo.Name, pullNum)
comments, resp, err := g.client.Issues.ListComments(g.ctx, repo.Owner, repo.Name, pullNum, &github.IssueListCommentsOptions{
Sort: "created",
Direction: "asc",
Expand Down Expand Up @@ -210,6 +216,7 @@ func (g *GithubClient) PullIsApproved(repo models.Repo, pull models.PullRequest)
if nextPage != 0 {
opts.Page = nextPage
}
g.logger.Debug("GET /repos/%v/%v/pulls/%d/reviews", repo.Owner, repo.Name, pull.Num)
pageReviews, resp, err := g.client.PullRequests.ListReviews(g.ctx, repo.Owner, repo.Name, pull.Num, &opts)
if err != nil {
return false, errors.Wrap(err, "getting reviews")
Expand Down Expand Up @@ -282,6 +289,7 @@ func (g *GithubClient) UpdateStatus(repo models.Repo, pull models.PullRequest, s
func (g *GithubClient) MergePull(pull models.PullRequest) error {
// Users can set their repo to disallow certain types of merging.
// We detect which types aren't allowed and use the type that is.
g.logger.Debug("GET /repos/%v/%v", pull.BaseRepo.Owner, pull.BaseRepo.Name)
repo, _, err := g.client.Repositories.Get(g.ctx, pull.BaseRepo.Owner, pull.BaseRepo.Name)
if err != nil {
return errors.Wrap(err, "fetching repo info")
Expand All @@ -304,6 +312,7 @@ func (g *GithubClient) MergePull(pull models.PullRequest) error {
options := &github.PullRequestOptions{
MergeMethod: method,
}
g.logger.Debug("PUT /repos/%v/%v/pulls/%d/merge", repo.Owner, repo.Name, pull.Num)
mergeResult, _, err := g.client.PullRequests.Merge(
g.ctx,
pull.BaseRepo.Owner,
Expand Down
4 changes: 2 additions & 2 deletions server/events/vcs/github_client_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (

// If the hostname is github.com, should use normal BaseURL.
func TestNewGithubClient_GithubCom(t *testing.T) {
client, err := NewGithubClient("github.com", "user", "pass")
client, err := NewGithubClient("github.com", "user", "pass", nil)
Ok(t, err)
Equals(t, "https://api.github.com/", client.client.BaseURL.String())
}

// If the hostname is a non-github hostname should use the right BaseURL.
func TestNewGithubClient_NonGithub(t *testing.T) {
client, err := NewGithubClient("example.com", "user", "pass")
client, err := NewGithubClient("example.com", "user", "pass", nil)
Ok(t, err)
Equals(t, "https://example.com/api/v3/", client.client.BaseURL.String())
}
20 changes: 10 additions & 10 deletions server/events/vcs/github_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestGithubClient_GetModifiedFiles(t *testing.T) {

testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -114,7 +114,7 @@ func TestGithubClient_GetModifiedFilesMovedFile(t *testing.T) {

testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -208,7 +208,7 @@ func TestGithubClient_PaginatesComments(t *testing.T) {
testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)

client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -294,7 +294,7 @@ func TestGithubClient_HideOldComments(t *testing.T) {
testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)

client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -358,7 +358,7 @@ func TestGithubClient_UpdateStatus(t *testing.T) {

testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -444,7 +444,7 @@ func TestGithubClient_PullIsApproved(t *testing.T) {

testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -535,7 +535,7 @@ func TestGithubClient_PullIsMergeable(t *testing.T) {
}))
testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -617,7 +617,7 @@ func TestGithubClient_MergePullHandlesError(t *testing.T) {

testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand Down Expand Up @@ -739,7 +739,7 @@ func TestGithubClient_MergePullCorrectMethod(t *testing.T) {

testServerURL, err := url.Parse(testServer.URL)
Ok(t, err)
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass")
client, err := vcs.NewGithubClient(testServerURL.Host, "user", "pass", nil)
Ok(t, err)
defer disableSSLVerification()()

Expand All @@ -764,7 +764,7 @@ func TestGithubClient_MergePullCorrectMethod(t *testing.T) {
}

func TestGithubClient_MarkdownPullLink(t *testing.T) {
client, err := vcs.NewGithubClient("hostname", "user", "pass")
client, err := vcs.NewGithubClient("hostname", "user", "pass", nil)
Ok(t, err)
pull := models.PullRequest{Num: 1}
s, _ := client.MarkdownPullLink(pull)
Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
if userConfig.GithubUser != "" {
supportedVCSHosts = append(supportedVCSHosts, models.Github)
var err error
githubClient, err = vcs.NewGithubClient(userConfig.GithubHostname, userConfig.GithubUser, userConfig.GithubToken)
githubClient, err = vcs.NewGithubClient(userConfig.GithubHostname, userConfig.GithubUser, userConfig.GithubToken, logger)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -193,7 +193,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
}
}
if userConfig.AzureDevopsUser != "" {
if err := events.WriteGitCreds(userConfig.AzureDevopsUser, userConfig.AzureDevopsToken, "https://dev.azure.com/", home, logger); err != nil {
if err := events.WriteGitCreds(userConfig.AzureDevopsUser, userConfig.AzureDevopsToken, "dev.azure.com", home, logger); err != nil {
return nil, err
}
}
Expand Down

0 comments on commit 48fbde5

Please sign in to comment.