-
Notifications
You must be signed in to change notification settings - Fork 61
Add formatting check for shell scripts #106
Conversation
A few sh script still seem unformatted (
I would suggest establishing a consistent practice for this. Perhaps we always prefix the inputs from terraform as #!/usr/bin/env
MY_VAR1=${_MY_VAR1}
MY_VAR2=${_MY_VAR2}
echo $${MY_VAR2} Then we can add linting (basically just a script?) that after the initial assignment block, we disallow Or actually, I'd like to turn that upside-down and have us post-process scripts to turn Also, adding |
@mafredri You mean we run |
I added |
Yes, shellcheck on original scripts. However, I'm pretty sure
These are just the two options I came up with, maybe there's more?
That's a good question. I haven't looked at how these files end up in terraform so I don't know the answer to that off the top of my head. |
yes.
for this, I get self-assignment |
I imagine we can use the However, if the shellcheck integration is causing too much trouble, we can punt it for later. |
Removed |
Context
This pull request adds a formatting check for shell scripts. It ensures that the shell scripts follow a consistent formatting style. This helps improve code readability and maintainability. The formatting check is performed using the Prettier plugin for shell scripts.
Possible issues
We must be cautious with these scripts as we populate them with variables from terraform using
templatefile
function. This expects a map of vars passed for all variables used as${VAR}.
To use the variables local to the script, we need to escape them with$${LOCAL_VAR}
; otherwise, terraform tries to replace them and errors out as it can not find a variable with that name in the map.We also need a method to test all module scripts using automated tests.
Suggested by @mafredi