Skip to content

Commit

Permalink
chore: Cherry-pick #4462 into release-0.27 (#4476)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Winther <[email protected]>
  • Loading branch information
lukemassa and jippi authored Apr 24, 2024
1 parent 7cb3ebd commit f8d2673
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
filters: |
go:
- '**.go'
- '**.txt' # golden file test output
- 'go.*'
- '.github/workflows/test.yml'
test:
Expand All @@ -51,6 +52,7 @@ jobs:

- run: make test-all
- run: make check-fmt

###########################################################
# Notifying #contributors about test failure on main branch
###########################################################
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ check-lint: ## Run linter in CI/CD. If running locally use 'lint'

.PHONY: check-fmt
check-fmt: ## Fail if not formatted
if [[ $$(goimports -l $$(find . -type f -name '*.go' ! -path "./vendor/*" ! -path "**/mocks/*")) ]]; then exit 1; fi
./scripts/fmt.sh

.PHONY: end-to-end-deps
end-to-end-deps: ## Install e2e dependencies
Expand Down
23 changes: 23 additions & 0 deletions scripts/fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -euo pipefail

go install golang.org/x/tools/cmd/goimports@latest

gobin="$(go env GOPATH)/bin"
declare -r gobin

declare -a files
readarray -d '' files < <(find . -type f -name '*.go' ! -name 'mock_*' ! -path './vendor/*' ! -path '**/mocks/*' -print0)
declare -r files

output="$("${gobin}"/goimports -l "${files[@]}")"
declare -r output

if [[ -n "$output" ]]; then
echo "These files had their 'import' changed - please fix them locally and push a fix"

echo "$output"

exit 1
fi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
resource "random_id" "dummy1" {
keepers = {}
byte_length = 1
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
resource "random_id" "dummy2" {
keepers = {}
byte_length = 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand Down Expand Up @@ -54,7 +53,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand All @@ -72,4 +70,4 @@ Plan: 1 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand All @@ -56,4 +55,4 @@ Plan: 1 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

# random_id.for_each["default"] will be created
Expand All @@ -28,7 +27,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 2 to add, 0 to change, 0 to destroy.
Expand All @@ -46,4 +44,4 @@ Plan: 2 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
resource "random_id" "for_each" {
for_each = toset([var.var])
keepers = {}
byte_length = 1
}

resource "random_id" "count" {
count = 1
keepers = {}
byte_length = 1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

# random_id.dummy2 will be created
Expand All @@ -28,7 +27,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 2 to add, 0 to change, 0 to destroy.
Expand All @@ -46,4 +44,4 @@ Plan: 2 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
resource "random_id" "dummy1" {
keepers = {}
byte_length = 1
}

resource "random_id" "dummy2" {
keepers = {}
byte_length = 1
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
resource "random_id" "dummy1" {
count = terraform.workspace == "ops" ? 1 : 0

keepers = {}
byte_length = 1
}

resource "random_id" "dummy2" {
count = terraform.workspace == "ops" ? 1 : 0

keepers = {}
byte_length = 1
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
resource "random_id" "dummy" {
keepers = {}
byte_length = 1
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
resource "random_id" "dummy" {
keepers = {}
byte_length = 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand Down Expand Up @@ -54,7 +53,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand All @@ -72,4 +70,4 @@ Plan: 1 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand Down Expand Up @@ -54,7 +53,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand All @@ -72,4 +70,4 @@ Plan: 1 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

# random_id.for_each["default"] will be created
Expand All @@ -28,7 +27,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

# random_id.simple will be created
Expand All @@ -39,7 +37,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 3 to add, 0 to change, 0 to destroy.
Expand All @@ -57,4 +54,4 @@ Plan: 3 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

# random_id.for_each["overridden"] will be created
Expand All @@ -28,7 +27,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

# random_id.simple will be created
Expand All @@ -39,7 +37,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 3 to add, 0 to change, 0 to destroy.
Expand All @@ -57,4 +54,4 @@ Plan: 3 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
resource "random_id" "simple" {
keepers = {}
byte_length = 1
}

resource "random_id" "for_each" {
for_each = toset([var.var])
keepers = {}
byte_length = 1
}

resource "random_id" "count" {
count = 1
keepers = {}
byte_length = 1
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
resource "random_id" "dummy1" {
count = terraform.workspace == "ops" ? 1 : 0

keepers = {}
byte_length = 1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Terraform will perform the following actions:
+ dec = (known after apply)
+ hex = (known after apply)
+ id = (known after apply)
+ keepers = {}
}

Plan: 1 to add, 0 to change, 0 to destroy.
Expand All @@ -35,4 +34,4 @@ Plan: 1 to add, 0 to change, 0 to destroy.
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `atlantis apply`
* :put_litter_in_its_place: To **delete** all plans and locks for the PR, comment:
* `atlantis unlock`
* `atlantis unlock`

0 comments on commit f8d2673

Please sign in to comment.