@@ -65,3 +65,46 @@ instructions](https://pre-commit.com/#install) then install the hooks:
65
65
$ pre-commit install
66
66
$ pre-commit run --all-hooks
67
67
```
68
+
69
+ ## Debugging
70
+
71
+ If you're developing some rules and want to see how they run on some actual
72
+ Terraform code you will need to.
73
+
74
+ 1 . Install your changes: ` make install `
75
+
76
+ 2 . Enable the plugin in the repo, if the plugin is already installed, be sure
77
+ to remove references to source and version (other wise it will install from
78
+ there):
79
+
80
+ ``` hcl
81
+ plugin "uw-kafka-config" {
82
+ enabled = true
83
+
84
+ # comment this out if it exists, ensure we use the plugin
85
+ # we just installed, and not building from upstream source
86
+ #version = "1.1.0"
87
+ #source = "github.com/utilitywarehouse/tflint-ruleset-kafka-config"
88
+ }
89
+ ```
90
+
91
+ 3. Run the plugin
92
+
93
+ The plugin expects to be run from the directory containing the files you want
94
+ you'll need to change directory first and make sure you pass the :
95
+
96
+ ```
97
+ $ cd ./path/to/debug
98
+ $ tflint --config=$(git rev-parse --show-toplevel)/.tflint.hcl
99
+ ```
100
+
101
+ To view more logs you can set set the [`TFLINT_DEBUG` environment
102
+ variable](https://github.com/terraform-linters/tflint/blob/fc6795ce12fde842fc73f67e55369a63bdfc27d8/README.md#debugging),
103
+ combining all in one line:
104
+
105
+ cd ./path/to/debug && TFLINT_LOG=debug tflint --config=$(git rev-parse --show-toplevel)/.tflint-msk.hcl ; cd -
106
+
107
+ Similarly if you want to debug the plugin via a `pre-commit` hook (assuming the
108
+ hook has name `terraform_tflint_msk`):
109
+
110
+ TFLINT_LOG=debug pre-commit run --verbose --files ./path/to/debug/*.tf -- terraform_tflint_msk
0 commit comments