Skip to content

Commit

Permalink
Merge branch 'main' into skip_clone_no_changes_fork_prs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulminator authored Jan 13, 2025
2 parents 711f614 + de1d8dc commit 1c79da5
Show file tree
Hide file tree
Showing 87 changed files with 1,514 additions and 554 deletions.
3 changes: 2 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
automerge: true,
baseBranches: [
'main',
'/^release-.*/',
'release-0.31',
'release-0.32',
],
platformAutomerge: true,
labels: [
Expand Down
37 changes: 33 additions & 4 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
strategy:
matrix:
image_type: [alpine, debian]
platform: [linux/arm64/v8, linux/amd64, linux/arm/v7]
runs-on: ubuntu-24.04
env:
# Set docker repo to either the fork or the main repo where the branch exists
Expand All @@ -69,6 +70,11 @@ jobs:
with:
dockerfile: "Dockerfile"

- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"

- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
with:
Expand All @@ -82,6 +88,10 @@ jobs:
driver-opts: |
image=moby/buildkit:v0.14.0
- name: "Install cosign"
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
if: env.PUSH == 'true' && github.event_name != 'pull_request'

# release version is the name of the tag i.e. v0.10.0
# release version also has the image type appended i.e. v0.10.0-alpine
# release tag is either pre-release or latest i.e. latest
Expand Down Expand Up @@ -146,21 +156,38 @@ jobs:
ATLANTIS_VERSION=${{ env.RELEASE_VERSION }}
ATLANTIS_COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
ATLANTIS_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
platforms: linux/arm64/v8,linux/amd64,linux/arm/v7
platforms: ${{ matrix.platform }}
push: ${{ env.PUSH }}
tags: ${{ steps.meta.outputs.tags }}
target: ${{ matrix.image_type }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}

- name: "Sign and Attest Image"
if: env.PUSH == 'true'
- name: "Create Image Attestation"
if: env.PUSH == 'true' && github.event_name != 'pull_request'
uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0
with:
subject-digest: ${{ steps.build.outputs.digest }}
subject-name: ghcr.io/${{ github.repository }}
push-to-registry: true

- name: "Sign images with environment annotations"
# no key needed, we're using the GitHub OIDC flow
# Only run on alpine/amd64 build to avoid signing multiple times
if: env.PUSH == 'true' && github.event_name != 'pull_request' && matrix.image_type == 'alpine' && matrix.platform == 'linux/amd64'
run: |
# Sign dev tags, version tags, and latest tags
echo "${TAGS}" | xargs -I {} cosign sign \
--yes \
--recursive=true \
-a actor=${{ github.actor}} \
-a ref_name=${{ github.ref_name}} \
-a ref=${{ github.sha }} \
{}@${DIGEST}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build.outputs.digest }}

test:
needs: [changes]
if: needs.changes.outputs.should-run-build == 'true'
Expand All @@ -169,6 +196,7 @@ jobs:
strategy:
matrix:
image_type: [alpine, debian]
platform: [linux/arm64/v8, linux/amd64, linux/arm/v7]
env:
# Set docker repo to either the fork or the main repo where the branch exists
DOCKER_REPO: ghcr.io/${{ github.repository }}
Expand Down Expand Up @@ -215,4 +243,5 @@ jobs:
image_type: [alpine, debian]
runs-on: ubuntu-24.04
steps:
- run: 'echo "No build required"'
- run: 'echo "No build required"'

2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: markdown-lint
uses: DavidAnson/markdownlint-cli2-action@eb5ca3ab411449c66620fe7f1b3c9e10547144b0 # v18
uses: DavidAnson/markdownlint-cli2-action@a23dae216ce3fee4db69da41fed90d2a4af801cf # v19
with:
config: .markdownlint.yaml
globs: 'runatlantis.io/**/*.md'
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG GOLANG_TAG=1.23.4-alpine@sha256:6c5c9590f169f77c8046e45c611d3b28fe477789acd8
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp
ARG DEFAULT_TERRAFORM_VERSION=1.10.3
# renovate: datasource=github-releases depName=opentofu/opentofu versioning=hashicorp
ARG DEFAULT_OPENTOFU_VERSION=1.8.7
ARG DEFAULT_OPENTOFU_VERSION=1.8.8
# renovate: datasource=github-releases depName=open-policy-agent/conftest
ARG DEFAULT_CONFTEST_VERSION=0.56.0

Expand Down Expand Up @@ -122,7 +122,7 @@ RUN ./download-release.sh \
"terraform" \
"${TARGETPLATFORM}" \
"${DEFAULT_TERRAFORM_VERSION}" \
"1.6.6 1.7.5 1.8.5 ${DEFAULT_TERRAFORM_VERSION}" \
"1.8.5 1.9.8 ${DEFAULT_TERRAFORM_VERSION}" \
&& ./download-release.sh \
"tofu" \
"${TARGETPLATFORM}" \
Expand Down
37 changes: 25 additions & 12 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const (
CheckoutStrategyFlag = "checkout-strategy"
ConfigFlag = "config"
DataDirFlag = "data-dir"
DefaultTFDistributionFlag = "default-tf-distribution"
DefaultTFVersionFlag = "default-tf-version"
DisableApplyAllFlag = "disable-apply-all"
DisableAutoplanFlag = "disable-autoplan"
Expand Down Expand Up @@ -141,7 +142,7 @@ const (
SSLCertFileFlag = "ssl-cert-file"
SSLKeyFileFlag = "ssl-key-file"
RestrictFileList = "restrict-file-list"
TFDistributionFlag = "tf-distribution"
TFDistributionFlag = "tf-distribution" // deprecated for DefaultTFDistributionFlag
TFDownloadFlag = "tf-download"
TFDownloadURLFlag = "tf-download-url"
UseTFPluginCache = "use-tf-plugin-cache"
Expand Down Expand Up @@ -421,8 +422,8 @@ var stringFlags = map[string]stringFlag{
description: fmt.Sprintf("File containing x509 private key matching --%s.", SSLCertFileFlag),
},
TFDistributionFlag: {
description: fmt.Sprintf("Which TF distribution to use. Can be set to %s or %s.", TFDistributionTerraform, TFDistributionOpenTofu),
defaultValue: DefaultTFDistribution,
description: "[Deprecated for --default-tf-distribution].",
hidden: true,
},
TFDownloadURLFlag: {
description: "Base URL to download Terraform versions from.",
Expand All @@ -437,6 +438,10 @@ var stringFlags = map[string]stringFlag{
" Only set if using TFC/E as a remote backend." +
" Should be specified via the ATLANTIS_TFE_TOKEN environment variable for security.",
},
DefaultTFDistributionFlag: {
description: fmt.Sprintf("Which TF distribution to use. Can be set to %s or %s.", TFDistributionTerraform, TFDistributionOpenTofu),
defaultValue: DefaultTFDistribution,
},
DefaultTFVersionFlag: {
description: "Terraform version to default to (ex. v0.12.0). Will download if not yet on disk." +
" If not set, Atlantis uses the terraform binary in its PATH.",
Expand Down Expand Up @@ -840,12 +845,13 @@ func (s *ServerCmd) run() error {

// Config looks good. Start the server.
server, err := s.ServerCreator.NewServer(userConfig, server.Config{
AllowForkPRsFlag: AllowForkPRsFlag,
AtlantisURLFlag: AtlantisURLFlag,
AtlantisVersion: s.AtlantisVersion,
DefaultTFVersionFlag: DefaultTFVersionFlag,
RepoConfigJSONFlag: RepoConfigJSONFlag,
SilenceForkPRErrorsFlag: SilenceForkPRErrorsFlag,
AllowForkPRsFlag: AllowForkPRsFlag,
AtlantisURLFlag: AtlantisURLFlag,
AtlantisVersion: s.AtlantisVersion,
DefaultTFDistributionFlag: DefaultTFDistributionFlag,
DefaultTFVersionFlag: DefaultTFVersionFlag,
RepoConfigJSONFlag: RepoConfigJSONFlag,
SilenceForkPRErrorsFlag: SilenceForkPRErrorsFlag,
})

if err != nil {
Expand Down Expand Up @@ -921,8 +927,11 @@ func (s *ServerCmd) setDefaults(c *server.UserConfig, v *viper.Viper) {
if c.RedisPort == 0 {
c.RedisPort = DefaultRedisPort
}
if c.TFDistribution == "" {
c.TFDistribution = DefaultTFDistribution
if c.TFDistribution != "" && c.DefaultTFDistribution == "" {
c.DefaultTFDistribution = c.TFDistribution
}
if c.DefaultTFDistribution == "" {
c.DefaultTFDistribution = DefaultTFDistribution
}
if c.TFDownloadURL == "" {
c.TFDownloadURL = DefaultTFDownloadURL
Expand Down Expand Up @@ -953,7 +962,7 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
return fmt.Errorf("invalid log level: must be one of %v", ValidLogLevels)
}

if userConfig.TFDistribution != TFDistributionTerraform && userConfig.TFDistribution != TFDistributionOpenTofu {
if userConfig.DefaultTFDistribution != TFDistributionTerraform && userConfig.DefaultTFDistribution != TFDistributionOpenTofu {
return fmt.Errorf("invalid tf distribution: expected one of %s or %s",
TFDistributionTerraform, TFDistributionOpenTofu)
}
Expand Down Expand Up @@ -1172,6 +1181,10 @@ func (s *ServerCmd) deprecationWarnings(userConfig *server.UserConfig) error {
// }
//

if userConfig.TFDistribution != "" {
deprecatedFlags = append(deprecatedFlags, TFDistributionFlag)
}

if len(deprecatedFlags) > 0 {
warning := "WARNING: "
if len(deprecatedFlags) == 1 {
Expand Down
41 changes: 41 additions & 0 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var testFlags = map[string]interface{}{
CheckoutStrategyFlag: CheckoutStrategyMerge,
CheckoutDepthFlag: 0,
DataDirFlag: "/path",
DefaultTFDistributionFlag: "terraform",
DefaultTFVersionFlag: "v0.11.0",
DisableApplyAllFlag: true,
DisableMarkdownFoldingFlag: true,
Expand Down Expand Up @@ -977,6 +978,46 @@ func TestExecute_AutoplanFileList(t *testing.T) {
}
}

func TestExecute_ValidateDefaultTFDistribution(t *testing.T) {
cases := []struct {
description string
flags map[string]interface{}
expectErr string
}{
{
"terraform",
map[string]interface{}{
DefaultTFDistributionFlag: "terraform",
},
"",
},
{
"opentofu",
map[string]interface{}{
DefaultTFDistributionFlag: "opentofu",
},
"",
},
{
"errs on invalid distribution",
map[string]interface{}{
DefaultTFDistributionFlag: "invalid_distribution",
},
"invalid tf distribution: expected one of terraform or opentofu",
},
}
for _, testCase := range cases {
t.Log("Should validate default tf distribution when " + testCase.description)
c := setupWithDefaults(testCase.flags, t)
err := c.Execute()
if testCase.expectErr != "" {
ErrEquals(t, testCase.expectErr, err)
} else {
Ok(t, err)
}
}
}

func setup(flags map[string]interface{}, t *testing.T) *cobra.Command {
vipr := viper.New()
for k, v := range flags {
Expand Down
6 changes: 3 additions & 3 deletions e2e/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os/exec"
"strings"

"github.com/google/go-github/v66/github"
"github.com/google/go-github/v68/github"
)

type GithubClient struct {
Expand Down Expand Up @@ -90,7 +90,7 @@ func (g GithubClient) CreateAtlantisWebhook(ctx context.Context, hookURL string)
atlantisHook := &github.Hook{
Events: []string{"issue_comment", "pull_request", "push"},
Config: hookConfig,
Active: github.Bool(true),
Active: github.Ptr(true),
}

hook, _, err := g.client.Repositories.CreateHook(ctx, g.ownerName, g.repoName, atlantisHook)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (g GithubClient) GetAtlantisStatus(ctx context.Context, branchName string)

func (g GithubClient) ClosePullRequest(ctx context.Context, pullRequestNumber int) error {
// clean up
_, _, err := g.client.PullRequests.Edit(ctx, g.ownerName, g.repoName, pullRequestNumber, &github.PullRequest{State: github.String("closed")})
_, _, err := g.client.PullRequests.Edit(ctx, g.ownerName, g.repoName, pullRequestNumber, &github.PullRequest{State: github.Ptr("closed")})
if err != nil {
return fmt.Errorf("error while closing new pull request: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"os"
"os/exec"

"github.com/xanzy/go-gitlab"
gitlab "gitlab.com/gitlab-org/api/client-go"
)

type GitlabClient struct {
Expand Down
12 changes: 6 additions & 6 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ module github.com/runatlantis/atlantis/e2e
go 1.23.4

require (
github.com/google/go-github/v66 v66.0.0
github.com/google/go-github/v68 v68.0.0
github.com/hashicorp/go-multierror v1.1.1
github.com/xanzy/go-gitlab v0.114.0
gitlab.com/gitlab-org/api/client-go v0.118.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.36.0 // indirect
)
Loading

0 comments on commit 1c79da5

Please sign in to comment.