reviewdog / action-tflint

Run tflint with reviewdog on pull requests to enforce best practices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: ability to install additional plugins (rulesets)

nicole-ashley opened this issue · comments

TFLint supports the concept of adding additional rulesets, for instance for the azurerm and google providers: https://github.com/terraform-linters/tflint#getting-started

To use this action on Terraform configurations that use these providers, an extra option is needed to download and install the appropriate rulesets. For instance:

with:
  rulesets:
    - azurerm
    - google

One would then install that plugin using something like this untested code:

export TFLINT_PLUGIN_DIR="${TEMP_PATH}/.tflint.d/plugins"
for RULESET in ${INPUT_PLUGINS}; do
  PLUGIN="tf-ruleset-${RULESET}"
  REPOSITORY="https://github.com/terraform-linters/${PLUGIN}"

  echo "::group:: Installing tflint plugin for ${RULESET} ... ${REPOSITORY}"
  mkdir -p ${TFLINT_PLUGIN_DIR}
  curl -L "$(curl -Ls ${REPOSITORY}/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" -o ${PLUGIN}.zip && unzip ${PLUGIN}.zip -d "${TFLINT_PLUGIN_DIR}" && rm ${PLUGIN}.zip
  echo '::endgroup::'
done

Hey!

Apologies for getting back to you so late, I had no time to allocate to this 😞 But I am back now! 🎉

This is a great feature to add, thank you for the idea! I work mainly in AWS so I did not even think of doing this.

I'll work on this after I do a general cleanup and implement #32. Did you experiment with the code example you provided? Do you have any ideas on how I could test that all the specified rulesets were correctly installed and can be used?