atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

workflows.default.plan.steps - run - printf output gets truncated at first whitespace

Open camilosantana opened this issue 7 years ago • 3 comments

code sample has intentional yaml-invalid line-breaks for easier readability

workflows:
  default:
    plan:
      steps:
        - run: <arbitrary prior steps>
        ...
        ...
        - run: echo data.aws_region.default.name | \
                terraform${ATLANTIS_TERRAFORM_VERSION} console || \
                printf 'your main.tf file does not provide default region.\ncheck \
                https://github.com/company/project#maintf-examples on how to add \
                expected "data" statement.\n\n'
        - run: tflint --deep --aws-region=$(echo data.aws_region.default.name | \
                terraform${ATLANTIS_TERRAFORM_VERSION} console)
        ...
        ...

I would like to provide some helper text for when certain steps fail. Instead of getting all the output, I'm only seeing the first word. then a carriage return and the output to next steps. I was expecting the first step to fail the plan.

Resource 'data.aws_region.default' not found for variable 'data.aws_region.default.name'
your ### <-- here's the fault. also expecting fail here but steps continue...
Resource 'data.aws_region.default' not found for variable 'data.aws_region.default.name'

What would the best step (unintentional pun) be here?

Would it be best to ... ?

  • run script and return expected exit code instead of this bash one-liner
  • use echo statement instead (assuming echo outs to different stream)
  • or peruse the code in this repo and see if there's anything obvious

camilosantana avatar Mar 04 '19 18:03 camilosantana

This is due to the way we're parsing run steps. Add a \ to ' and a \ to your \n and it should work:

- run: mkdir a/b/c || printf \'your main.tf file does not provide default region.\\ncheck\'

lkysow avatar Mar 06 '19 18:03 lkysow

Closing since I tested this and it works and I haven't heard back.

lkysow avatar Mar 14 '19 19:03 lkysow

confirmed this works. thank you

camilosantana avatar Mar 20 '19 00:03 camilosantana