Skip to content

Commit 231682d

Browse files
authored
chore: Adding quality controls (#240)
* chore: Adding `mise.toml` * chore: Adding tooling for automated quality controls * chore: Running `go fmt` * fix: Using keyed struct instances to make them resilient to shuffles * fix: Adding `gopls` to `mise.toml`, as we're gonna want that later * fix: Fixing automatically fixable lint failures * fix: Addressing lint findings * fix: More Url to URL replacements * fix: Running `gopls` updates * fix: Adding backwards compatibility to this * fix: Fixing rename of `integrationtests` package * fix: Reverting unintended lowercasing of errors * fix: More accidental error updates
1 parent afb4d12 commit 231682d

Some content is hidden

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

59 files changed

+1556
-1023
lines changed

.golangci.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# This file is generated using `make update-local-lint` to track the linting used in Terragrunt. Do not edit manually.
2+
version: "2"
3+
run:
4+
go: "1.24"
5+
issues-exit-code: 1
6+
tests: true
7+
output:
8+
formats:
9+
text:
10+
path: stdout
11+
print-linter-name: true
12+
print-issued-lines: true
13+
linters:
14+
enable:
15+
- asasalint
16+
- asciicheck
17+
- bidichk
18+
- bodyclose
19+
- contextcheck
20+
- dupl
21+
- durationcheck
22+
- errchkjson
23+
- errorlint
24+
- exhaustive
25+
- fatcontext
26+
- gocheckcompilerdirectives
27+
- gochecksumtype
28+
- goconst
29+
- gocritic
30+
- gosmopolitan
31+
- loggercheck
32+
- makezero
33+
- misspell
34+
- mnd
35+
- musttag
36+
- nilerr
37+
- nilnesserr
38+
- noctx
39+
- paralleltest
40+
- perfsprint
41+
- prealloc
42+
- protogetter
43+
- reassign
44+
- rowserrcheck
45+
- spancheck
46+
- sqlclosecheck
47+
- staticcheck
48+
- testableexamples
49+
- testifylint
50+
- testpackage
51+
- thelper
52+
- tparallel
53+
- unconvert
54+
- unparam
55+
- usetesting
56+
- wastedassign
57+
- wsl
58+
- zerologlint
59+
disable:
60+
- depguard
61+
- exhaustruct
62+
- gocyclo
63+
- gosec
64+
- nolintlint
65+
- recvcheck
66+
- varnamelen
67+
- wrapcheck
68+
settings:
69+
dupl:
70+
threshold: 120
71+
errcheck:
72+
check-type-assertions: false
73+
check-blank: false
74+
exclude-functions:
75+
- (*os.File).Close
76+
errorlint:
77+
errorf: true
78+
asserts: true
79+
comparison: true
80+
goconst:
81+
min-len: 3
82+
min-occurrences: 5
83+
gocritic:
84+
disabled-checks:
85+
- regexpMust
86+
- rangeValCopy
87+
- appendAssign
88+
- hugeParam
89+
enabled-tags:
90+
- performance
91+
disabled-tags:
92+
- experimental
93+
govet:
94+
enable:
95+
- fieldalignment
96+
nakedret:
97+
max-func-lines: 20
98+
staticcheck:
99+
checks:
100+
- all
101+
- -SA9005
102+
- -QF1008
103+
- -ST1001
104+
unparam:
105+
check-exported: false
106+
exclusions:
107+
generated: lax
108+
rules:
109+
- linters:
110+
- dupl
111+
- errcheck
112+
- gocyclo
113+
- lll
114+
- mnd
115+
- unparam
116+
- wsl
117+
path: _test\.go
118+
paths:
119+
- docs
120+
- _ci
121+
- .github
122+
- .circleci
123+
- third_party$
124+
- builtin$
125+
- examples$
126+
issues:
127+
max-issues-per-linter: 0
128+
max-same-issues: 0
129+
formatters:
130+
enable:
131+
- goimports
132+
settings:
133+
gofmt:
134+
simplify: true
135+
exclusions:
136+
generated: lax
137+
paths:
138+
- docs
139+
- _ci
140+
- .github
141+
- .circleci
142+
- third_party$
143+
- builtin$
144+
- examples$

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
GOFMT_FILES?=$$(find . -name '*.go' -not -path "./examples/*")
2+
3+
default: build
4+
5+
build: $(shell find . \( -type f -name '*.go' -print \))
6+
set -xe ;\
7+
vtag=$$(git describe --tags --abbrev=12 --dirty --broken) ;\
8+
go build -o boilerplate -ldflags "-X github.com/gruntwork-io/go-commons/version.Version=$${vtag} -extldflags '-static'" .
9+
10+
clean:
11+
rm -f boilerplate
12+
13+
lint: SHELL:=/bin/bash
14+
lint:
15+
golangci-lint run -c <(curl -s https://raw.githubusercontent.com/gruntwork-io/terragrunt/main/.golangci.yml) ./...
16+
17+
update-local-lint: SHELL:=/bin/bash
18+
update-local-lint:
19+
curl -s https://raw.githubusercontent.com/gruntwork-io/terragrunt/main/.golangci.yml --output .golangci.yml
20+
tmpfile=$$(mktemp) ;\
21+
echo '# This file is generated using `make update-local-lint` to track the linting used in Terragrunt. Do not edit manually.' | cat - .golangci.yml > $${tmpfile} && mv $${tmpfile} .golangci.yml
22+
23+
test:
24+
go test -v ./...
25+
26+
fmt:
27+
@echo "Running source files through gofmt..."
28+
gofmt -w $(GOFMT_FILES)
29+
30+
.PHONY: lint test default

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,15 @@ Boilerplate also includes several custom helpers that you can access that enhanc
842842
return str2;
843843
// boilerplate-snippet: foo
844844
```
845+
845846
* `include <PATH> <VARIABLES>`: Returns the contents of the file at `PATH` after rendering it through the templating
846847
engine with the provided variables, as a string (unlike `snippet`, which returns the contents of the file verbatim).
847848
Use `.` to pass the current variables to the included template. E.g:
848-
```
849+
850+
```text
849851
{{ include "../source-template.snippet" . }}
850852
```
853+
851854
* `replaceOne OLD NEW`: Replace the first occurrence of `OLD` with `NEW`. This is a literal replace, not regex.
852855
* `replaceAll OLD NEW`: Replace all occurrences of `OLD` with `NEW`. This is a literal replace, not regex.
853856
* `roundInt FLOAT`: Round `FLOAT` to the nearest integer. E.g. 1.5 becomes 2.
@@ -875,7 +878,7 @@ Boilerplate also includes several custom helpers that you can access that enhanc
875878
form `ENV:KEY=VALUE` will be set as an environment variable for the command rather than an argument. **Security Note**: Shell commands will prompt for confirmation before execution. To run shell commands without confirmation, use the `--non-interactive` flag. To disable shell command execution entirely, use the `--no-shell` flag. For another way to execute commands, see [hooks](#hooks).
876879
* `templateFolder`: Return the value of the template working dir. This is the value of the `--template-url` command-line
877880
option if local template, or the download dir if remote template. Useful for building relative paths.
878-
* `templateUrl`: Return the value of the template URL as was provided in the `--template-url`.
881+
* `templateURL`: Return the value of the template URL as was provided in the `--template-url`.
879882
* `vars`: Return the dictionary of all input variables.
880883
* `outputFolder`: Return the value of the `--output-folder` command-line option. Useful for building relative paths.
881884
* `envWithDefault NAME DEFAULT`: Render the value of environment variable `NAME`. If that environment variable is empty or not

cli/boilerplate_cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package cli provides the command-line interface for the boilerplate tool.
12
package cli
23

34
import (
@@ -57,7 +58,7 @@ func CreateBoilerplateCli() *cli.App {
5758

5859
app.Flags = []cli.Flag{
5960
&cli.StringFlag{
60-
Name: options.OptTemplateUrl,
61+
Name: options.OptTemplateURL,
6162
Usage: "Generate the project from the templates in `URL`. This can be a local path, or a go-getter compatible URL for remote templates (e.g., `[email protected]:gruntwork-io/boilerplate.git//examples/for-learning-and-testing/include?ref=main`).",
6263
},
6364
&cli.StringFlag{
@@ -106,7 +107,6 @@ func CreateBoilerplateCli() *cli.App {
106107
app.DisableSliceFlagSeparator = true
107108

108109
return app
109-
110110
}
111111

112112
// When you run the CLI, this is the action function that gets called

0 commit comments

Comments
 (0)