Skip to content

Commit b25803a

Browse files
Initial commit
0 parents  commit b25803a

17 files changed

+951
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: weekly

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: "0 0 * * *"
12+
13+
jobs:
14+
test:
15+
name: ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, windows-latest]
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
- name: Set up Go
24+
uses: actions/setup-go@v3
25+
with:
26+
go-version-file: 'go.mod'
27+
- name: Run tests
28+
run: make test
29+
- name: Run build
30+
run: make build

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches:
6+
- '!*'
7+
tags:
8+
- v*.*.*
9+
10+
jobs:
11+
goreleaser:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Set up Go
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version-file: 'go.mod'
20+
- name: Import GPG key
21+
id: import_gpg
22+
uses: crazy-max/ghaction-import-gpg@v5
23+
with:
24+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
25+
passphrase: ${{ secrets.PASSPHRASE }}
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v3
28+
with:
29+
version: latest
30+
args: release --rm-dist
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.goreleaser.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This is an example goreleaser.yaml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
env:
4+
- CGO_ENABLED=0
5+
builds:
6+
- targets:
7+
- darwin_amd64
8+
- darwin_arm64
9+
- linux_386
10+
- linux_amd64
11+
- linux_arm
12+
- linux_arm64
13+
- windows_386
14+
- windows_amd64
15+
archives:
16+
- id: zip
17+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
18+
format: zip
19+
files:
20+
- none*
21+
checksum:
22+
name_template: 'checksums.txt'
23+
signs:
24+
- artifacts: checksum
25+
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
default: build
2+
3+
test:
4+
go test ./...
5+
6+
build:
7+
go build
8+
9+
install: build
10+
mkdir -p ~/.tflint.d/plugins
11+
mv ./tflint-ruleset-template ~/.tflint.d/plugins

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# TFLint Ruleset Template
2+
[![Build Status](https://github.com/terraform-linters/tflint-ruleset-template/workflows/build/badge.svg?branch=main)](https://github.com/terraform-linters/tflint-ruleset-template/actions)
3+
4+
This is a template repository for building a custom ruleset. You can create a plugin repository from "Use this template". See also [Writing Plugins](https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md).
5+
6+
## Requirements
7+
8+
- TFLint v0.40+
9+
- Go v1.19
10+
11+
## Installation
12+
13+
TODO: This template repository does not contain release binaries, so this installation will not work. Please rewrite for your repository. See the "Building the plugin" section to get this template ruleset working.
14+
15+
You can install the plugin with `tflint --init`. Declare a config in `.tflint.hcl` as follows:
16+
17+
```hcl
18+
plugin "template" {
19+
enabled = true
20+
21+
version = "0.1.0"
22+
source = "github.com/terraform-linters/tflint-ruleset-template"
23+
24+
signing_key = <<-KEY
25+
-----BEGIN PGP PUBLIC KEY BLOCK-----
26+
mQINBGCqS2YBEADJ7gHktSV5NgUe08hD/uWWPwY07d5WZ1+F9I9SoiK/mtcNGz4P
27+
JLrYAIUTMBvrxk3I+kuwhp7MCk7CD/tRVkPRIklONgtKsp8jCke7FB3PuFlP/ptL
28+
SlbaXx53FCZSOzCJo9puZajVWydoGfnZi5apddd11Zw1FuJma3YElHZ1A1D2YvrF
29+
...
30+
KEY
31+
}
32+
```
33+
34+
## Rules
35+
36+
|Name|Description|Severity|Enabled|Link|
37+
| --- | --- | --- | --- | --- |
38+
|aws_instance_example_type|Example rule for accessing and evaluating top-level attributes|ERROR|||
39+
|aws_s3_bucket_example_lifecycle_rule|Example rule for accessing top-level/nested blocks and attributes under the blocks|ERROR|||
40+
|google_compute_ssl_policy|Example rule with a custom rule config|WARNING|||
41+
|terraform_backend_type|Example rule for accessing other than resources|ERROR|||
42+
43+
## Building the plugin
44+
45+
Clone the repository locally and run the following command:
46+
47+
```
48+
$ make
49+
```
50+
51+
You can easily install the built plugin with the following:
52+
53+
```
54+
$ make install
55+
```
56+
57+
You can run the built plugin like the following:
58+
59+
```
60+
$ cat << EOS > .tflint.hcl
61+
plugin "template" {
62+
enabled = true
63+
}
64+
EOS
65+
$ tflint
66+
```

go.mod

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module github.com/terraform-linters/tflint-ruleset-template
2+
3+
go 1.19
4+
5+
require (
6+
github.com/hashicorp/hcl/v2 v2.14.1
7+
github.com/terraform-linters/tflint-plugin-sdk v0.14.0
8+
)
9+
10+
require (
11+
github.com/agext/levenshtein v1.2.1 // indirect
12+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
13+
github.com/fatih/color v1.13.0 // indirect
14+
github.com/golang/protobuf v1.5.2 // indirect
15+
github.com/google/go-cmp v0.5.9 // indirect
16+
github.com/hashicorp/go-hclog v1.3.1 // indirect
17+
github.com/hashicorp/go-plugin v1.4.5 // indirect
18+
github.com/hashicorp/go-version v1.6.0 // indirect
19+
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
20+
github.com/mattn/go-colorable v0.1.12 // indirect
21+
github.com/mattn/go-isatty v0.0.14 // indirect
22+
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
23+
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
24+
github.com/oklog/run v1.0.0 // indirect
25+
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
26+
github.com/vmihailenco/tagparser v0.1.1 // indirect
27+
github.com/zclconf/go-cty v1.11.0 // indirect
28+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
29+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
30+
golang.org/x/text v0.3.7 // indirect
31+
google.golang.org/appengine v1.6.5 // indirect
32+
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
33+
google.golang.org/grpc v1.50.1 // indirect
34+
google.golang.org/protobuf v1.28.1 // indirect
35+
)

0 commit comments

Comments
 (0)