Skip to content

Commit

Permalink
Merge branch 'main' into extend-api
Browse files Browse the repository at this point in the history
  • Loading branch information
jamengual authored Dec 7, 2023
2 parents af923be + 6391d60 commit b7854a5
Show file tree
Hide file tree
Showing 33 changed files with 917 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
# that flag starts the download asynchronously so we'd have a race
# condition.
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
TERRAFORM_VERSION: 1.6.4
TERRAFORM_VERSION: 1.6.5
steps:
- checkout
- run: make build-service
Expand Down
42 changes: 26 additions & 16 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
build:
- 'Dockerfile*'
- changed-files:
- any-glob-to-any-file: 'Dockerfile*'

dependencies:
- 'yarn.lock'
- 'go.*'
- changed-files:
- any-glob-to-any-file: 'yarn.lock'
- any-glob-to-any-file: 'go.*'

docs:
- 'runatlantis.io/**/*.md'
- 'README.md'
- changed-files:
- any-glob-to-any-file: 'runatlantis.io/**/*.md'
- any-glob-to-any-file: 'README.md'

github-actions:
- '.github/**'
- changed-files:
- any-glob-to-any-file: '.github/**'

go:
- '**/*.go'
- changed-files:
- any-glob-to-any-file: '**/*.go'

provider/azuredevops:
- 'server/**/*azuredevops*.go'
- changed-files:
- any-glob-to-any-file: 'server/**/*azuredevops*.go'

provider/bitbucket:
- 'server/**/*bitbucket*.go'
- 'server/events/vcs/bitbucketcloud/*.go'
- 'server/events/vcs/bitbucketserver/*.go'
- changed-files:
- any-glob-to-any-file: 'server/**/*bitbucket*.go'
- any-glob-to-any-file: 'server/events/vcs/bitbucketcloud/*.go'
- any-glob-to-any-file: 'server/events/vcs/bitbucketserver/*.go'

provider/github:
- 'server/**/*github*.go'
- changed-files:
- any-glob-to-any-file: 'server/**/*github*.go'

provider/gitlab:
- 'server/**/*gitlab*.go'
- changed-files:
- any-glob-to-any-file: 'server/**/*gitlab*.go'

website:
- 'runatlantis.io/.vuepress/**/*'
- 'package.json'
- 'yarn.lock'
- changed-files:
- any-glob-to-any-file: 'runatlantis.io/.vuepress/**/*'
- any-glob-to-any-file: 'package.json'
- any-glob-to-any-file: 'yarn.lock'
5 changes: 1 addition & 4 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ jobs:
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler.yml
- uses: actions/labeler@v5
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9.0
20.10.0
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# syntax=docker/dockerfile:1
# what distro is the image being built for
ARG ALPINE_TAG=3.18.4
ARG ALPINE_TAG=3.18.5
ARG DEBIAN_TAG=12.2-slim

ARG DEFAULT_TERRAFORM_VERSION=1.6.3
ARG DEFAULT_CONFTEST_VERSION=0.46.0

# Stage 1: build artifact and download deps

FROM golang:1.21.4-alpine AS builder
FROM golang:1.21.5-alpine AS builder

ARG ATLANTIS_VERSION=dev
ENV ATLANTIS_VERSION=${ATLANTIS_VERSION}
Expand Down
11 changes: 11 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (
AllowForkPRsFlag = "allow-fork-prs"
AllowRepoConfigFlag = "allow-repo-config"
AtlantisURLFlag = "atlantis-url"
AutoDiscoverModeFlag = "autodiscover-mode"
AutomergeFlag = "automerge"
ParallelPlanFlag = "parallel-plan"
ParallelApplyFlag = "parallel-apply"
Expand Down Expand Up @@ -148,6 +149,7 @@ const (
DefaultADBasicUser = ""
DefaultADBasicPassword = ""
DefaultADHostname = "dev.azure.com"
DefaultAutoDiscoverMode = "auto"
DefaultAutoplanFileList = "**/*.tf,**/*.tfvars,**/*.tfvars.json,**/terragrunt.hcl,**/.terraform.lock.hcl"
DefaultAllowCommands = "version,plan,apply,unlock,approve_policies"
DefaultCheckoutStrategy = CheckoutStrategyBranch
Expand Down Expand Up @@ -207,6 +209,12 @@ var stringFlags = map[string]stringFlag{
AtlantisURLFlag: {
description: "URL that Atlantis can be reached at. Defaults to http://$(hostname):$port where $port is from --" + PortFlag + ". Supports a base path ex. https://example.com/basepath.",
},
AutoDiscoverModeFlag: {
description: "Auto discover mode controls whether projects in a repo are discovered by Atlantis. Defaults to 'auto' which " +
"means projects will be discovered when no explicit projects are defined in repo config. Also supports 'enabled' (always " +
"discover projects) and 'disabled' (never discover projects).",
defaultValue: DefaultAutoDiscoverMode,
},
AutoplanModulesFromProjects: {
description: "Comma separated list of file patterns to select projects Atlantis will index for module dependencies." +
" Indexed projects will automatically be planned if a module they depend on is modified." +
Expand Down Expand Up @@ -871,6 +879,9 @@ func (s *ServerCmd) setDefaults(c *server.UserConfig) {
if c.WebPassword == "" {
c.WebPassword = DefaultWebPassword
}
if c.AutoDiscoverModeFlag == "" {
c.AutoDiscoverModeFlag = DefaultAutoDiscoverMode
}
}

func (s *ServerCmd) validate(userConfig server.UserConfig) error {
Expand Down
1 change: 1 addition & 0 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var testFlags = map[string]interface{}{
AllowCommandsFlag: "version,plan,unlock,import,approve_policies", // apply is disabled by DisableApply
AllowForkPRsFlag: true,
AllowRepoConfigFlag: true,
AutoDiscoverModeFlag: "auto",
AutomergeFlag: true,
AutoplanFileListFlag: "**/*.tf,**/*.yml",
BitbucketBaseURLFlag: "https://bitbucket-base-url.com",
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
github.com/go-playground/validator/v10 v10.16.0
github.com/go-test/deep v1.1.0
github.com/golang-jwt/jwt/v5 v5.1.0
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/go-github/v54 v54.0.0
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.4.0
Expand All @@ -21,7 +21,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/hashicorp/terraform-config-inspect v0.0.0-20230925220900-5a6f8d18746d
github.com/hashicorp/terraform-config-inspect v0.0.0-20231204233900-a34142ec2a72
github.com/kr/pretty v0.3.1
github.com/mcdafydd/go-azuredevops v0.12.1
github.com/microcosm-cc/bluemonday v1.0.26
Expand All @@ -33,7 +33,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.3.0
github.com/remeh/sizedwaitgroup v1.0.0
github.com/shurcooL/githubv4 v0.0.0-20230704064427-599ae7bbf278
github.com/shurcooL/githubv4 v0.0.0-20231126234147-1cffa1f02456
github.com/slack-go/slack v0.12.3
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncV
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HWQU=
github.com/golang-jwt/jwt/v5 v5.1.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -266,8 +266,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI=
github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
github.com/hashicorp/terraform-config-inspect v0.0.0-20230925220900-5a6f8d18746d h1:g6kHlvZrFPFKeWRj5q/zyJA5gu7rlJGPf17h8hX7LHY=
github.com/hashicorp/terraform-config-inspect v0.0.0-20230925220900-5a6f8d18746d/go.mod h1:l8HcFPm9cQh6Q0KSWoYPiePqMvRFenybP1CH2MjKdlg=
github.com/hashicorp/terraform-config-inspect v0.0.0-20231204233900-a34142ec2a72 h1:nZ5gGjbe5o7XUu1d7j+Y5Ztcxlp+yaumTKH9i0D3wlg=
github.com/hashicorp/terraform-config-inspect v0.0.0-20231204233900-a34142ec2a72/go.mod h1:l8HcFPm9cQh6Q0KSWoYPiePqMvRFenybP1CH2MjKdlg=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
Expand Down Expand Up @@ -407,8 +407,8 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/githubv4 v0.0.0-20230704064427-599ae7bbf278 h1:kdEGVAV4sO46DPtb8k793jiecUEhaX9ixoIBt41HEGU=
github.com/shurcooL/githubv4 v0.0.0-20230704064427-599ae7bbf278/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8=
github.com/shurcooL/githubv4 v0.0.0-20231126234147-1cffa1f02456 h1:6dExqsYngGEiixqa1vmtlUd+zbyISilg0Cf3GWVdeYM=
github.com/shurcooL/githubv4 v0.0.0-20231126234147-1cffa1f02456/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8=
github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 h1:B1PEwpArrNp4dkQrfxh/abbBAOZBVp0ds+fBEOUOqOc=
github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@vuepress/plugin-docsearch": "2.0.0-beta.66",
"@vuepress/plugin-google-analytics": "2.0.0-beta.68",
"@vuepress/plugin-google-analytics": "2.0.0-rc.0",
"vuepress": "2.0.0-beta.66"
},
"scripts": {
Expand Down
42 changes: 39 additions & 3 deletions runatlantis.io/docs/repo-level-atlantis-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,27 @@ By default, this is not allowed.
:::

::: warning
Once an `atlantis.yaml` file exists in a repo, Atlantis won't try to determine
where to run plan automatically. Instead it will just follow the project configuration.
This means that you'll need to define each project in your repo.
Once an `atlantis.yaml` file exists in a repo and one or more `projects` are configured,
Atlantis won't try to determine where to run plan automatically. Instead it will just
follow the project configuration. This means that you'll need to define each project
in your repo.

If you have many directories with Terraform configuration, each directory will
need to be defined.

This behavior can be overriden by setting `autodiscover.mode` to
`enabled` in which case Atlantis will still try to discover projects which were not
explicitly configured. If the directory of any discovered project conflicts with a
manually configured project, the manually configured project will take precedence.
:::

## Example Using All Keys

```yaml
version: 3
automerge: true
autodiscover:
mode: auto
delete_source_branch_on_merge: true
parallel_plan: true
parallel_apply: true
Expand Down Expand Up @@ -281,6 +289,34 @@ in each group one by one.
If any plan/apply fails and `abort_on_execution_order_fail` is set to true on a repo level, all the
following groups will be aborted. For this example, if project2 fails then project1 will not run.

### Autodiscovery Config
```yaml
autodiscover:
mode: "auto"
```
The above is the default configuration for `autodiscover.mode`. When `autodiscover.mode` is auto,
projects will be discovered only if the repo has no `projects` configured.

```yaml
autodiscover:
mode: "disabled"
```
With the config above, Atlantis will never try to discover projects, even when there are no
`projects` configured. This is useful if dynamically generating Atlantis config in pre_workflow hooks.
See [Dynamic Repo Config Generation](pre-workflow-hooks.html#dynamic-repo-config-generation).

```yaml
autodiscover:
mode: "enabled"
```
With the config above, Atlantis will unconditionally try to discover projects based on modified_files,
even when the directory of the project is missing from the configured `projects` in the repo configuration.
If a discovered project has the same directory as a project which was manually configured in `projects`,
the manual configuration will take precedence.

Use this feature when some projects require specific configuration in a repo with many projects yet
it's still desirable for Atlantis to plan/apply for projects not enumerated in the config.

### Custom Backend Config
See [Custom Workflow Use Cases: Custom Backend Config](custom-workflows.html#custom-backend-config)

Expand Down
16 changes: 16 additions & 0 deletions runatlantis.io/docs/server-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ Values are chosen in this order:
* If a load balancer with a non http/https port (not the one defined in the `--port` flag) is used, update the URL to include the port like in the example above.
* This URL is used as the `details` link next to each atlantis job to view the job's logs.

### `--autodiscover-mode`
```bash
atlantis server --autodiscover-mode="<auto|enabled|disabled>"
# or
ATLANTIS_AUTODISCOVER_MODE="<auto|enabled|disabled>"
```
Sets auto discover mode, default is `auto`. When set to `auto`, projects in a repo will be discovered by
Atlantis when there are no projects configured in the repo config. If one or more projects are defined
in the repo config then auto discovery will be completely disabled.

When set to `enabled` projects will be discovered unconditionally. If an auto discovered project is already
defined in the projects section of the repo config, the project from the repo config will take precedence over
the auto discovered project.

When set to `disabled` projects will never be discovered, even if there are no projects configured in the repo config.

### `--automerge`
```bash
atlantis server --automerge
Expand Down
5 changes: 5 additions & 0 deletions runatlantis.io/docs/server-side-repo-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ repos:
# policy_check defines if policy checking should be enable on this repository.
policy_check: false

# autodiscover defines how atlantis should automatically discover projects in this repository.
autodiscover:
mode: auto

# id can also be an exact match.
- id: github.com/myorg/specific-repo

Expand Down Expand Up @@ -496,6 +500,7 @@ If you set a workflow with the key `default`, it will override this.
| repo_locking | bool | false | no | Whether or not to get a lock. |
| policy_check | bool | false | no | Whether or not to run policy checks on this repository. |
| custom_policy_check | bool | false | no | Whether or not to enable custom policy check tools outside of Conftest on this repository. |
| autodiscover | AutoDiscover | none | no | Auto discover settings for this repo


:::tip Notes
Expand Down
1 change: 1 addition & 0 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers
false,
false,
false,
"auto",
statsScope,
logger,
terraformClient,
Expand Down
Loading

0 comments on commit b7854a5

Please sign in to comment.