JT
05/23/2023, 2:52 PMATLANTIS_MARKDOWN_TEMPLATE_OVERRIDES_DIR
single_project_plan_success.tmpl:
## everything is the same as in main branch and then at bottom adding this
# TF Terragrunt Path
```diff
{{ .Env.TERRAGRUNT_TFPATH }}
```
repo.yaml:
repos:
- id: "/.*/"
workflow: terragrunt
workflows:
terragrunt:
plan:
steps:
- env:
name: TERRAGRUNT_TFPATH
command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
- run: terragrunt plan -input=false -out=$PLANFILE
- run: terragrunt show -json $PLANFILE > $SHOWFILE
ross strickland
05/23/2023, 2:55 PMenv
os function from sprig? https://masterminds.github.io/sprig/os.htmlJT
05/23/2023, 2:57 PMross strickland
05/23/2023, 2:57 PMJT
05/23/2023, 2:59 PMross strickland
05/23/2023, 3:05 PMJT
05/23/2023, 3:06 PMross strickland
05/23/2023, 3:37 PMsingle_project_plan_success.tmpl
?JT
05/23/2023, 3:38 PM/home/atlantis/templates
directory, it contains two templates only
single_project_plan_success.tmpl
and plan_success_wrapped.tmpl
I've copied and pasted their code from hereross strickland
05/23/2023, 3:39 PMJT
05/23/2023, 3:40 PMatlantis plan
{{ define "planSuccessWrapped" -}}
<details><summary>Show Output</summary>
```diff
{{ if .EnableDiffMarkdownFormat }}{{ .DiffMarkdownFormattedTerraformOutput }}{{ else }}{{ .TerraformOutput }}{{ end }}
{{ if .PlanWasDeleted -}}
This plan was not saved because one or more projects failed and automerge requires all plans pass.
{{ else -}}
{{ if not .DisableApply -}}
* ▶️ To apply this plan, comment:
* {{ .ApplyCmd }}
{{ end -}}
{{ if not .DisableRepoLocking -}}
* 🚮 To delete this plan click [here]({{ .LockURL }})
{{ end -}}
* 🔁 To plan this project again, comment:
* {{ .RePlanCmd }}
{{ end -}}
</details>
{{ .PlanSummary -}}
{{ template "diverged" . -}}
{{ end -}}
TF is neat```
Won't show TF is neat
at the bottomross strickland
05/23/2023, 3:41 PMTF is neat
outside of the define block?JT
05/23/2023, 3:42 PMross strickland
05/23/2023, 3:43 PM{{ define "template" }}
...
...
{{ end }}
anything outside of that will not be included in the rendered outputJT
05/23/2023, 4:02 PM{{ define "singleProjectPlanSuccess" -}}
{{ $result := index .Results 0 -}}
Ran {{ .Command }} for {{ if $result.ProjectName }}project: `{{ $result.ProjectName }}` {{ end }}dir: `{{ $result.RepoRelDir }}` workspace: `{{ $result.Workspace }}`
{{ $result.Rendered }}
{{ if ne .DisableApplyAll true }}
---
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `{{ .ExecutableName }} apply`
* :put_litter_in_its_place: To delete all plans and locks for the PR, comment:
* `{{ .ExecutableName }} unlock`
{{ end -}}
{{- template "log" . -}}
### TFGrunt Path Output
```diff
{{ .Env.TERRAGRUNT_TFPATH }}
{{ end -}}```
but going back to the original question about the env var, I get the following issue:
ailed to render template, this is a bug: template: single_project_plan_success.tmpl:17:9: executing "singleProjectPlanSuccess" at <.Env.TERRAGRUNT_TFPATH>: can't evaluate field Env in type events.resultData
ross strickland
05/23/2023, 4:11 PM.Env
is passed to the templates currently. can you try using the sprig function to access the OS ENV vars?JT
05/23/2023, 4:12 PMross strickland
05/23/2023, 4:19 PM{{ env "ENVVAR" }}
though it might require using that to set a variable and the referencing that var.JT
05/23/2023, 4:40 PMross strickland
05/23/2023, 4:56 PMJT
05/23/2023, 5:01 PM{{ env "TERRAGRUNT_TFPATH" }}
```diff
```
ross strickland
05/23/2023, 5:02 PMJT
05/23/2023, 5:06 PMrepos:
- id: "/.*/"
workflow: terragrunt
workflows:
terragrunt:
plan:
steps:
- env:
name: TERRAGRUNT_TFPATH
command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
Trying to use it in the template like this:
{{ define "singleProjectPlanSuccess" -}}
{{ $result := index .Results 0 -}}
Ran {{ .Command }} for {{ if $result.ProjectName }}project: `{{ $result.ProjectName }}` {{ end }}dir: `{{ $result.RepoRelDir }}` workspace: `{{ $result.Workspace }}`
{{ $result.Rendered }}
{{ if ne .DisableApplyAll true }}
---
* :fast_forward: To **apply** all unapplied plans from this pull request, comment:
* `{{ .ExecutableName }} apply`
* :put_litter_in_its_place: To delete all plans and locks for the PR, comment:
* `{{ .ExecutableName }} unlock`
{{ end -}}
{{- template "log" . -}}
```diff
{{ env "TERRAGRUNT_TFPATH" }}
{{ end -}}```ross strickland
05/23/2023, 5:58 PMrepos:
- id: "/.*/"
workflow: terragrunt
workflows:
terragrunt:
plan:
steps:
- init
- plan
- run: 'echo "TERRAGRUNT_TFPATH: terraform${ATLANTIS_TERRAFORM_VERSION}"'
... the run command could be crafted to form the message you want to display more clearly.JT
05/23/2023, 6:30 PMecho "FOO" > /tmp/run-output.txt
and then grab it from within the templateross strickland
05/23/2023, 6:47 PMJT
05/23/2023, 7:02 PMross strickland
05/23/2023, 7:03 PMATLANTIS_TERRAFORM_VERSION
env var is available in the process scope for rendering templates?JT
05/23/2023, 7:47 PMross strickland
05/23/2023, 7:54 PM