flosell / iam-policy-json-to-terraform

Small tool to convert an IAM Policy in JSON format into a Terraform aws_iam_policy_document
https://flosell.github.io/iam-policy-json-to-terraform/
Apache License 2.0
774 stars 58 forks source link

Remove example shell prefix ("$") #20

Closed alexjurkiewicz closed 3 years ago

alexjurkiewicz commented 3 years ago

Now you can copy the entire line and paste it into your terminal.

flosell commented 3 years ago

Thanks for the proposal! I'd prefer to keep the $ though. While I agree with you that in the case you mentioned, it'd be slightly easier, we'd need to change the format across the whole README to be consistent. Then the picture becomes less clear: The $ sign in some parts of the file indicates which part is the command and which part is the expected output. This shows off the tools functionality for newcomers but is also part of some bare-bones test-script to make sure the commands in the README actually work and continue to work.

nitrocode commented 3 years ago

Current

✗ cat README.md | \
  sed -e 's_git@github.com:_https://github.com/_g' | \
  sed -n "/\`\`\`bash testcase=${x}/,/\`\`\`/p" | \
  sed -e 's/^[[:space:]]*//' | \
  grep '^\$' | \
  sed -e 's/^\$ //g'
go get github.com/flosell/iam-policy-json-to-terraform
echo '{"Statement":[{"Effect":"Allow","Action":["ec2:Describe*"],"Resource":"*"}]}' | iam-policy-json-to-terraform
git clone https://github.com/flosell/iam-policy-json-to-terraform.git
cd iam-policy-json-to-terraform
make tools
make

@flosell what if we did this in scripts/test-readme.sh? Then we could remove the $ signs from the commands in the README.

✗ cat README.md-no-money | \
  sed -e 's_git@github.com:_https://github.com/_g' | \
  sed -n "/\`\`\`bash testcase=${x}/,/\`\`\`/p" | \
  sed -e 's/^[[:space:]]*//' | \
  grep 'testcase=' -A1 | \
  egrep -v 'testcase=|^--' | \
  sed -e 's/^\$ //g'
go get github.com/flosell/iam-policy-json-to-terraform
echo '{"Statement":[{"Effect":"Allow","Action":["ec2:Describe*"],"Resource":"*"}]}' | iam-policy-json-to-terraform
git clone https://github.com/flosell/iam-policy-json-to-terraform.git
cd iam-policy-json-to-terraform
make

Note the contents of README.md-no-money has every command's $ removed except for the last $ make command which shows the output.