From eaf6168185169ffeba33195c7bc5c536a843c211 Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 11 Nov 2024 10:09:57 +0100 Subject: [PATCH] move .tf formatting to pre-commit --- .pre-commit-config.yaml | 19 +++++++++++++++++++ GNUmakefile | 3 +++ tools/tools.go | 2 -- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a76ce0f9a..9c5bad08e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,3 +48,22 @@ repos: hooks: - id: shellcheck args: [--shell, bash] + + - repo: local + hooks: + - id: opentofu_fmt + name: opentofu_fmt + description: Format all .tf files to a canonical format. + language: docker_image + entry: ghcr.io/opentofu/opentofu fmt + files: \.tf$ + + - repo: local + hooks: + - id: generate + name: generate + description: Ensure generated files are up to date + language: golang + entry: make generate + pass_filenames: false + files: (^examples/|\.go$) diff --git a/GNUmakefile b/GNUmakefile index 679081ce9..92fec18fe 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -6,6 +6,9 @@ build: install: build go install -v ./... +generate: + go -C ./tools generate ./... + lint: golangci-lint run --fix diff --git a/tools/tools.go b/tools/tools.go index 3c9b215ca..a0fedea75 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -4,6 +4,4 @@ import ( _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" ) -//go:generate terraform fmt -recursive ../examples - //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-dir .. -provider-name hcloud