Skip to content

Commit 4a4b5b6

Browse files
authored
Merge branch 'main' into add-regex-filter
2 parents a9c8f94 + ef2a694 commit 4a4b5b6

File tree

216 files changed

+9003
-3653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+9003
-3653
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
# that flag starts the download asynchronously so we'd have a race
1010
# condition.
1111
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
12-
TERRAFORM_VERSION: 1.7.4
12+
TERRAFORM_VERSION: 1.7.5
1313
steps:
1414
- checkout
1515
- run: make build-service

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*
22
!cmd/
3+
!scripts/download-release.sh
34
!server/
45
!testdrive/
56
!main.go

.github/workflows/website.yml

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
-e 'https://medium.com/runatlantis' \
7777
-e 'https://github\.com/runatlantis/atlantis/edit/main/.*' \
7878
-e 'https://github.com/runatlantis/helm-charts#customization' \
79+
-e 'https://github.com/sethvargo/atlantis-on-gke/blob/master/terraform/tls.tf#L64-L84' \
7980
-e 'https://confluence.atlassian.com/*' \
8081
--header 'Accept-Encoding:deflate, gzip' \
8182
--buffer-size 8192 \

.node-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.11.1
1+
20.12.0

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pnpm 8.15.4
1+
pnpm 8.15.5

Dockerfile

+22-24
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
# what distro is the image being built for
33
ARG ALPINE_TAG=3.19.1
44
ARG DEBIAN_TAG=12.5-slim
5+
ARG GOLANG_VERSION=1.22.1
56

67
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
78
ARG DEFAULT_TERRAFORM_VERSION=1.7.2
9+
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
10+
ARG DEFAULT_OPENTOFU_VERSION=1.6.2
811
# renovate: datasource=github-releases depName=open-policy-agent/conftest
912
ARG DEFAULT_CONFTEST_VERSION=0.49.1
1013

1114
# Stage 1: build artifact and download deps
1215

13-
FROM golang:1.22.1-alpine AS builder
16+
FROM golang:${GOLANG_VERSION}-alpine AS builder
1417

1518
ARG ATLANTIS_VERSION=dev
1619
ENV ATLANTIS_VERSION=${ATLANTIS_VERSION}
@@ -68,7 +71,6 @@ ARG TARGETPLATFORM
6871
WORKDIR /tmp/build
6972

7073
# install conftest
71-
# renovate: datasource=github-releases depName=open-policy-agent/conftest
7274
ARG DEFAULT_CONFTEST_VERSION
7375
ENV DEFAULT_CONFTEST_VERSION=${DEFAULT_CONFTEST_VERSION}
7476
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -106,31 +108,26 @@ RUN case ${TARGETPLATFORM} in \
106108
git-lfs --version
107109

108110
# install terraform binaries
109-
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
110111
ARG DEFAULT_TERRAFORM_VERSION
111112
ENV DEFAULT_TERRAFORM_VERSION=${DEFAULT_TERRAFORM_VERSION}
113+
ARG DEFAULT_OPENTOFU_VERSION
114+
ENV DEFAULT_OPENTOFU_VERSION=${DEFAULT_OPENTOFU_VERSION}
115+
116+
# COPY scripts/download-release.sh .
117+
COPY --from=builder /app/scripts/download-release.sh download-release.sh
112118

113119
# In the official Atlantis image, we only have the latest of each Terraform version.
114120
# Each binary is about 80 MB so we limit it to the 4 latest minor releases or fewer
115-
RUN AVAILABLE_TERRAFORM_VERSIONS="1.4.7 1.5.7 1.6.6 ${DEFAULT_TERRAFORM_VERSION}" && \
116-
case "${TARGETPLATFORM}" in \
117-
"linux/amd64") TERRAFORM_ARCH=amd64 ;; \
118-
"linux/arm64") TERRAFORM_ARCH=arm64 ;; \
119-
"linux/arm/v7") TERRAFORM_ARCH=arm ;; \
120-
*) echo "ERROR: 'TARGETPLATFORM' value expected: ${TARGETPLATFORM}"; exit 1 ;; \
121-
esac && \
122-
for VERSION in ${AVAILABLE_TERRAFORM_VERSIONS}; do \
123-
curl -LOs "https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_linux_${TERRAFORM_ARCH}.zip" && \
124-
curl -LOs "https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_SHA256SUMS" && \
125-
sed -n "/terraform_${VERSION}_linux_${TERRAFORM_ARCH}.zip/p" "terraform_${VERSION}_SHA256SUMS" | sha256sum -c && \
126-
mkdir -p "/usr/local/bin/tf/versions/${VERSION}" && \
127-
unzip "terraform_${VERSION}_linux_${TERRAFORM_ARCH}.zip" -d "/usr/local/bin/tf/versions/${VERSION}" && \
128-
ln -s "/usr/local/bin/tf/versions/${VERSION}/terraform" "/usr/local/bin/terraform${VERSION}" && \
129-
rm "terraform_${VERSION}_linux_${TERRAFORM_ARCH}.zip" && \
130-
rm "terraform_${VERSION}_SHA256SUMS"; \
131-
done && \
132-
ln -s "/usr/local/bin/tf/versions/${DEFAULT_TERRAFORM_VERSION}/terraform" /usr/local/bin/terraform
133-
121+
RUN ./download-release.sh \
122+
"terraform" \
123+
"${TARGETPLATFORM}" \
124+
"${DEFAULT_TERRAFORM_VERSION}" \
125+
"1.4.7 1.5.7 1.6.6 ${DEFAULT_TERRAFORM_VERSION}" \
126+
&& ./download-release.sh \
127+
"tofu" \
128+
"${TARGETPLATFORM}" \
129+
"${DEFAULT_OPENTOFU_VERSION}" \
130+
"${DEFAULT_OPENTOFU_VERSION}"
134131

135132
# Stage 2 - Alpine
136133
# Creating the individual distro builds using targets
@@ -151,6 +148,7 @@ RUN addgroup atlantis && \
151148
COPY --from=builder /app/atlantis /usr/local/bin/atlantis
152149
# copy terraform binaries
153150
COPY --from=deps /usr/local/bin/terraform* /usr/local/bin/
151+
COPY --from=deps /usr/local/bin/tofu* /usr/local/bin/
154152
# copy dependencies
155153
COPY --from=deps /usr/local/bin/conftest /usr/local/bin/conftest
156154
COPY --from=deps /usr/bin/git-lfs /usr/bin/git-lfs
@@ -159,7 +157,7 @@ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
159157
# Install packages needed to run Atlantis.
160158
# We place this last as it will bust less docker layer caches when packages update
161159
RUN apk add --no-cache \
162-
ca-certificates~=20230506 \
160+
ca-certificates~=20240226-r0 \
163161
curl~=8 \
164162
git~=2 \
165163
unzip~=6 \
@@ -168,7 +166,6 @@ RUN apk add --no-cache \
168166
dumb-init~=1 \
169167
gcompat~=1
170168

171-
172169
# Set the entry point to the atlantis user and run the atlantis command
173170
USER atlantis
174171
ENTRYPOINT ["docker-entrypoint.sh"]
@@ -191,6 +188,7 @@ RUN useradd --create-home --user-group --shell /bin/bash atlantis && \
191188
COPY --from=builder /app/atlantis /usr/local/bin/atlantis
192189
# copy terraform binaries
193190
COPY --from=deps /usr/local/bin/terraform* /usr/local/bin/
191+
COPY --from=deps /usr/local/bin/tofu* /usr/local/bin/
194192
# copy dependencies
195193
COPY --from=deps /usr/local/bin/conftest /usr/local/bin/conftest
196194
COPY --from=deps /usr/bin/git-lfs /usr/bin/git-lfs

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Go Reference](https://pkg.go.dev/badge/github.com/runatlantis/atlantis.svg)](https://pkg.go.dev/github.com/runatlantis/atlantis)
77
[![codecov](https://codecov.io/gh/runatlantis/atlantis/branch/main/graph/badge.svg)](https://codecov.io/gh/runatlantis/atlantis)
88
[![CircleCI](https://circleci.com/gh/runatlantis/atlantis/tree/main.svg?style=shield)](https://circleci.com/gh/runatlantis/atlantis/tree/main)
9-
[![Slack](https://img.shields.io/badge/Join-Atlantis%20Community%20Slack-red)](https://join.slack.com/t/atlantis-community/shared_invite/zt-1nt7yx7uq-AnVRc_JItF1CDwZtfqv_OA)
9+
[![Slack](https://img.shields.io/badge/Join-Atlantis%20Community%20Slack-red)](https://join.slack.com/t/atlantis-community/shared_invite/zt-9xlxtxtc-CUSKB1ATt_sQy6um~LDPNw)
1010

1111
<p align="center">
1212
<img src="./runatlantis.io/.vuepress/public/hero.png" alt="Atlantis Logo"/><br><br>
@@ -23,7 +23,7 @@
2323
* How to get started: [www.runatlantis.io/guide](https://www.runatlantis.io/guide)
2424
* Full documentation: [www.runatlantis.io/docs](https://www.runatlantis.io/docs)
2525
* Download the latest release: [github.com/runatlantis/atlantis/releases/latest](https://github.com/runatlantis/atlantis/releases/latest)
26-
* Get help in our [Slack channel](https://join.slack.com/t/atlantis-community/shared_invite/zt-1nt7yx7uq-AnVRc_JItF1CDwZtfqv_OA)
26+
* Get help in our [Slack channel](https://join.slack.com/t/atlantis-community/shared_invite/zt-9xlxtxtc-CUSKB1ATt_sQy6um~LDPNw)
2727
* Start Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
2828

2929
## What is Atlantis?

cmd/server.go

+59-7
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ const (
9393
GHOrganizationFlag = "gh-org"
9494
GHWebhookSecretFlag = "gh-webhook-secret" // nolint: gosec
9595
GHAllowMergeableBypassApply = "gh-allow-mergeable-bypass-apply" // nolint: gosec
96+
GiteaBaseURLFlag = "gitea-base-url"
97+
GiteaTokenFlag = "gitea-token"
98+
GiteaUserFlag = "gitea-user"
99+
GiteaWebhookSecretFlag = "gitea-webhook-secret" // nolint: gosec
100+
GiteaPageSizeFlag = "gitea-page-size"
96101
GitlabHostnameFlag = "gitlab-hostname"
97102
GitlabTokenFlag = "gitlab-token"
98103
GitlabUserFlag = "gitlab-user"
@@ -156,6 +161,8 @@ const (
156161
DefaultExecutableName = "atlantis"
157162
DefaultMarkdownTemplateOverridesDir = "~/.markdown_templates"
158163
DefaultGHHostname = "github.com"
164+
DefaultGiteaBaseURL = "https://gitea.com"
165+
DefaultGiteaPageSize = 30
159166
DefaultGitlabHostname = "gitlab.com"
160167
DefaultLockingDBType = "boltdb"
161168
DefaultLogLevel = "info"
@@ -318,6 +325,22 @@ var stringFlags = map[string]stringFlag{
318325
"This means that an attacker could spoof calls to Atlantis and cause it to perform malicious actions. " +
319326
"Should be specified via the ATLANTIS_GH_WEBHOOK_SECRET environment variable.",
320327
},
328+
GiteaBaseURLFlag: {
329+
description: "Base URL of Gitea server installation. Must include 'http://' or 'https://'.",
330+
},
331+
GiteaUserFlag: {
332+
description: "Gitea username of API user.",
333+
defaultValue: "",
334+
},
335+
GiteaTokenFlag: {
336+
description: "Gitea token of API user. Can also be specified via the ATLANTIS_GITEA_TOKEN environment variable.",
337+
},
338+
GiteaWebhookSecretFlag: {
339+
description: "Optional secret used to validate Gitea webhooks." +
340+
" SECURITY WARNING: If not specified, Atlantis won't be able to validate that the incoming webhook call came from Gitea. " +
341+
"This means that an attacker could spoof calls to Atlantis and cause it to perform malicious actions. " +
342+
"Should be specified via the ATLANTIS_GITEA_WEBHOOK_SECRET environment variable.",
343+
},
321344
GitlabHostnameFlag: {
322345
description: "Hostname of your GitLab Enterprise installation. If using gitlab.com, no need to set.",
323346
defaultValue: DefaultGitlabHostname,
@@ -568,6 +591,10 @@ var intFlags = map[string]intFlag{
568591
" If merge base is further behind than this number of commits from any of branches heads, full fetch will be performed.",
569592
defaultValue: DefaultCheckoutDepth,
570593
},
594+
GiteaPageSizeFlag: {
595+
description: "Optional value that specifies the number of results per page to expect from Gitea.",
596+
defaultValue: DefaultGiteaPageSize,
597+
},
571598
ParallelPoolSize: {
572599
description: "Max size of the wait group that runs parallel plans and applies (if enabled).",
573600
defaultValue: DefaultParallelPoolSize,
@@ -813,6 +840,12 @@ func (s *ServerCmd) setDefaults(c *server.UserConfig) {
813840
if c.GitlabHostname == "" {
814841
c.GitlabHostname = DefaultGitlabHostname
815842
}
843+
if c.GiteaBaseURL == "" {
844+
c.GiteaBaseURL = DefaultGiteaBaseURL
845+
}
846+
if c.GiteaPageSize == 0 {
847+
c.GiteaPageSize = DefaultGiteaPageSize
848+
}
816849
if c.BitbucketBaseURL == "" {
817850
c.BitbucketBaseURL = DefaultBitbucketBaseURL
818851
}
@@ -885,12 +918,17 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
885918
// The following combinations are valid.
886919
// 1. github user and token set
887920
// 2. github app ID and (key file set or key set)
888-
// 3. gitlab user and token set
889-
// 4. bitbucket user and token set
890-
// 5. azuredevops user and token set
891-
// 6. any combination of the above
892-
vcsErr := fmt.Errorf("--%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s must be set", GHUserFlag, GHTokenFlag, GHAppIDFlag, GHAppKeyFileFlag, GHAppIDFlag, GHAppKeyFlag, GitlabUserFlag, GitlabTokenFlag, BitbucketUserFlag, BitbucketTokenFlag, ADUserFlag, ADTokenFlag)
893-
if ((userConfig.GithubUser == "") != (userConfig.GithubToken == "")) || ((userConfig.GitlabUser == "") != (userConfig.GitlabToken == "")) || ((userConfig.BitbucketUser == "") != (userConfig.BitbucketToken == "")) || ((userConfig.AzureDevopsUser == "") != (userConfig.AzureDevopsToken == "")) {
921+
// 3. gitea user and token set
922+
// 4. gitlab user and token set
923+
// 5. bitbucket user and token set
924+
// 6. azuredevops user and token set
925+
// 7. any combination of the above
926+
vcsErr := fmt.Errorf("--%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s or --%s/--%s must be set", GHUserFlag, GHTokenFlag, GHAppIDFlag, GHAppKeyFileFlag, GHAppIDFlag, GHAppKeyFlag, GiteaUserFlag, GiteaTokenFlag, GitlabUserFlag, GitlabTokenFlag, BitbucketUserFlag, BitbucketTokenFlag, ADUserFlag, ADTokenFlag)
927+
if ((userConfig.GithubUser == "") != (userConfig.GithubToken == "")) ||
928+
((userConfig.GiteaUser == "") != (userConfig.GiteaToken == "")) ||
929+
((userConfig.GitlabUser == "") != (userConfig.GitlabToken == "")) ||
930+
((userConfig.BitbucketUser == "") != (userConfig.BitbucketToken == "")) ||
931+
((userConfig.AzureDevopsUser == "") != (userConfig.AzureDevopsToken == "")) {
894932
return vcsErr
895933
}
896934
if (userConfig.GithubAppID != 0) && ((userConfig.GithubAppKey == "") && (userConfig.GithubAppKeyFile == "")) {
@@ -901,7 +939,7 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
901939
}
902940
// At this point, we know that there can't be a single user/token without
903941
// its partner, but we haven't checked if any user/token is set at all.
904-
if userConfig.GithubAppID == 0 && userConfig.GithubUser == "" && userConfig.GitlabUser == "" && userConfig.BitbucketUser == "" && userConfig.AzureDevopsUser == "" {
942+
if userConfig.GithubAppID == 0 && userConfig.GithubUser == "" && userConfig.GiteaUser == "" && userConfig.GitlabUser == "" && userConfig.BitbucketUser == "" && userConfig.AzureDevopsUser == "" {
905943
return vcsErr
906944
}
907945

@@ -924,6 +962,14 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
924962
return fmt.Errorf("--%s must have http:// or https://, got %q", BitbucketBaseURLFlag, userConfig.BitbucketBaseURL)
925963
}
926964

965+
parsed, err = url.Parse(userConfig.GiteaBaseURL)
966+
if err != nil {
967+
return fmt.Errorf("error parsing --%s flag value %q: %s", GiteaWebhookSecretFlag, userConfig.GiteaBaseURL, err)
968+
}
969+
if parsed.Scheme != "http" && parsed.Scheme != "https" {
970+
return fmt.Errorf("--%s must have http:// or https://, got %q", GiteaBaseURLFlag, userConfig.GiteaBaseURL)
971+
}
972+
927973
if userConfig.RepoConfig != "" && userConfig.RepoConfigJSON != "" {
928974
return fmt.Errorf("cannot use --%s and --%s at the same time", RepoConfigFlag, RepoConfigJSONFlag)
929975
}
@@ -936,6 +982,8 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
936982
GitlabWebhookSecretFlag: userConfig.GitlabWebhookSecret,
937983
BitbucketTokenFlag: userConfig.BitbucketToken,
938984
BitbucketWebhookSecretFlag: userConfig.BitbucketWebhookSecret,
985+
GiteaTokenFlag: userConfig.GiteaToken,
986+
GiteaWebhookSecretFlag: userConfig.GiteaWebhookSecret,
939987
} {
940988
if strings.Contains(token, "\n") {
941989
s.Logger.Warn("--%s contains a newline which is usually unintentional", name)
@@ -1029,6 +1077,7 @@ func (s *ServerCmd) setVarFileAllowlist(userConfig *server.UserConfig) {
10291077
// trimAtSymbolFromUsers trims @ from the front of the github and gitlab usernames
10301078
func (s *ServerCmd) trimAtSymbolFromUsers(userConfig *server.UserConfig) {
10311079
userConfig.GithubUser = strings.TrimPrefix(userConfig.GithubUser, "@")
1080+
userConfig.GiteaUser = strings.TrimPrefix(userConfig.GiteaUser, "@")
10321081
userConfig.GitlabUser = strings.TrimPrefix(userConfig.GitlabUser, "@")
10331082
userConfig.BitbucketUser = strings.TrimPrefix(userConfig.BitbucketUser, "@")
10341083
userConfig.AzureDevopsUser = strings.TrimPrefix(userConfig.AzureDevopsUser, "@")
@@ -1038,6 +1087,9 @@ func (s *ServerCmd) securityWarnings(userConfig *server.UserConfig) {
10381087
if userConfig.GithubUser != "" && userConfig.GithubWebhookSecret == "" && !s.SilenceOutput {
10391088
s.Logger.Warn("no GitHub webhook secret set. This could allow attackers to spoof requests from GitHub")
10401089
}
1090+
if userConfig.GiteaUser != "" && userConfig.GiteaWebhookSecret == "" && !s.SilenceOutput {
1091+
s.Logger.Warn("no Gitea webhook secret set. This could allow attackers to spoof requests from Gitea")
1092+
}
10411093
if userConfig.GitlabUser != "" && userConfig.GitlabWebhookSecret == "" && !s.SilenceOutput {
10421094
s.Logger.Warn("no GitLab webhook secret set. This could allow attackers to spoof requests from GitLab")
10431095
}

0 commit comments

Comments
 (0)