diff --git a/server/events/markdown_renderer.go b/server/events/markdown_renderer.go index 88d56b582..18a38cc3c 100644 --- a/server/events/markdown_renderer.go +++ b/server/events/markdown_renderer.go @@ -204,7 +204,7 @@ var multiProjectPlanTmpl = template.Must(template.New("").Funcs(sprig.TxtFuncMap "{{end}}\n" + "{{ range $i, $result := .Results }}" + "### {{add $i 1}}. workspace: `{{$result.Workspace}}` dir: `{{$result.RepoRelDir}}`\n" + - "{{$result.Rendered}}\n" + + "{{$result.Rendered}}\n\n" + "---\n{{end}}{{ if gt (len .Results) 0 }}* :fast_forward: To **apply** all unapplied plans from this pull request, comment:\n" + " * `atlantis apply`{{end}}" + logTmpl)) @@ -215,7 +215,7 @@ var multiProjectApplyTmpl = template.Must(template.New("").Funcs(sprig.TxtFuncMa "{{end}}\n" + "{{ range $i, $result := .Results }}" + "### {{add $i 1}}. workspace: `{{$result.Workspace}}` dir: `{{$result.RepoRelDir}}`\n" + - "{{$result.Rendered}}\n" + + "{{$result.Rendered}}\n\n" + "---\n{{end}}" + logTmpl)) var planSuccessUnwrappedTmpl = template.Must(template.New("").Parse( @@ -227,7 +227,7 @@ var planSuccessWrappedTmpl = template.Must(template.New("").Parse( "```diff\n" + "{{.TerraformOutput}}\n" + "```\n\n" + - planNextSteps + + planNextSteps + "\n" + "")) // planNextSteps are instructions appended after successful plans as to what @@ -250,7 +250,7 @@ var applyWrappedSuccessTmpl = template.Must(template.New("").Parse( var unwrappedErrTmplText = "**{{.Command}} Error**\n" + "```\n" + "{{.Error}}\n" + - "```\n" + "```" var wrappedErrTmplText = "**{{.Command}} Error**\n" + "
Show Output\n\n" + "```\n" + @@ -259,7 +259,7 @@ var wrappedErrTmplText = "**{{.Command}} Error**\n" + var unwrappedErrTmpl = template.Must(template.New("").Parse(unwrappedErrTmplText)) var unwrappedErrWithLogTmpl = template.Must(template.New("").Parse(unwrappedErrTmplText + logTmpl)) var wrappedErrTmpl = template.Must(template.New("").Parse(wrappedErrTmplText)) -var failureTmplText = "**{{.Command}} Failed**: {{.Failure}}\n" +var failureTmplText = "**{{.Command}} Failed**: {{.Failure}}" var failureTmpl = template.Must(template.New("").Parse(failureTmplText)) var failureWithLogTmpl = template.Must(template.New("").Parse(failureTmplText + logTmpl)) var logTmpl = "{{if .Verbose}}\n
Log\n

\n\n```\n{{.Log}}```\n

{{end}}\n" diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go index 11ee9230a..db98850a6 100644 --- a/server/events/markdown_renderer_test.go +++ b/server/events/markdown_renderer_test.go @@ -36,13 +36,13 @@ func TestRenderErr(t *testing.T) { "apply error", events.ApplyCommand, err, - "**Apply Error**\n```\nerr\n```\n\n", + "**Apply Error**\n```\nerr\n```\n", }, { "plan error", events.PlanCommand, err, - "**Plan Error**\n```\nerr\n```\n\n", + "**Plan Error**\n```\nerr\n```\n", }, } @@ -76,13 +76,13 @@ func TestRenderFailure(t *testing.T) { "apply failure", events.ApplyCommand, "failure", - "**Apply Failed**: failure\n\n", + "**Apply Failed**: failure\n", }, { "plan failure", events.PlanCommand, "failure", - "**Plan Failed**: failure\n\n", + "**Plan Failed**: failure\n", }, } @@ -113,7 +113,7 @@ func TestRenderErrAndFailure(t *testing.T) { Failure: "failure", } s := r.Render(res, events.PlanCommand, "", false, models.Github) - Equals(t, "**Plan Error**\n```\nerror\n```\n\n", s) + Equals(t, "**Plan Error**\n```\nerror\n```\n", s) } func TestRenderProjectResults(t *testing.T) { @@ -223,6 +223,7 @@ $$$ * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: * $atlantis plan -d path -w workspace$ + --- ### 2. workspace: $workspace$ dir: $path2$ $$$diff @@ -234,6 +235,7 @@ $$$ * :put_litter_in_its_place: To **delete** this plan click [here](lock-url2) * :repeat: To **plan** this project again, comment: * $atlantis plan -d path2 -w workspace$ + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: * $atlantis apply$ @@ -263,11 +265,13 @@ $$$ $$$diff success $$$ + --- ### 2. workspace: $workspace$ dir: $path2$ $$$diff success2 $$$ + --- `, @@ -290,7 +294,6 @@ $$$ error $$$ - `, }, { @@ -308,7 +311,6 @@ $$$ **Plan Failed**: failure - `, }, { @@ -352,6 +354,7 @@ $$$ * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: * $atlantis plan -d path -w workspace$ + --- ### 2. workspace: $workspace$ dir: $path2$ **Plan Failed**: failure @@ -398,6 +401,7 @@ $$$ $$$diff success $$$ + --- ### 2. workspace: $workspace$ dir: $path2$ **Apply Failed**: failure @@ -443,6 +447,7 @@ $$$ $$$diff success $$$ + --- ### 2. workspace: $workspace$ dir: $path2$ **Apply Failed**: failure @@ -568,7 +573,8 @@ $$$ * $atlantis apply -d .$ * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * $atlantis plan -d .$
+ * $atlantis plan -d .$ + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: @@ -662,7 +668,6 @@ $$$ ` + c.Output + ` $$$ - ` } @@ -768,7 +773,8 @@ $$$ * $applycmd$ * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * $replancmd$ + * $replancmd$ + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: @@ -822,7 +828,7 @@ $$$ } } -func TestRenderProjectResults_MultiProjectWrapped(t *testing.T) { +func TestRenderProjectResults_MultiProjectApplyWrapped(t *testing.T) { mr := events.MarkdownRenderer{} tfOut := strings.Repeat("line\n", 13) rendered := mr.Render(events.CommandResult{ @@ -850,6 +856,7 @@ $$$diff ` + tfOut + ` $$$ + --- ### 2. workspace: $production$ dir: $.$
Show Output @@ -858,9 +865,78 @@ $$$diff ` + tfOut + ` $$$
+ --- ` expWithBackticks := strings.Replace(exp, "$", "`", -1) Equals(t, expWithBackticks, rendered) } + +func TestRenderProjectResults_MultiProjectPlanWrapped(t *testing.T) { + mr := events.MarkdownRenderer{} + tfOut := strings.Repeat("line\n", 13) + rendered := mr.Render(events.CommandResult{ + ProjectResults: []events.ProjectResult{ + { + RepoRelDir: ".", + Workspace: "staging", + PlanSuccess: &events.PlanSuccess{ + TerraformOutput: tfOut, + LockURL: "staging-lock-url", + ApplyCmd: "staging-apply-cmd", + RePlanCmd: "staging-replan-cmd", + }, + }, + { + RepoRelDir: ".", + Workspace: "production", + PlanSuccess: &events.PlanSuccess{ + TerraformOutput: tfOut, + LockURL: "production-lock-url", + ApplyCmd: "production-apply-cmd", + RePlanCmd: "production-replan-cmd", + }, + }, + }, + }, events.PlanCommand, "log", false, models.Github) + exp := `Ran Plan for 2 projects: +1. workspace: $staging$ dir: $.$ +1. workspace: $production$ dir: $.$ + +### 1. workspace: $staging$ dir: $.$ +
Show Output + +$$$diff +` + tfOut + ` +$$$ + +* :arrow_forward: To **apply** this plan, comment: + * $staging-apply-cmd$ +* :put_litter_in_its_place: To **delete** this plan click [here](staging-lock-url) +* :repeat: To **plan** this project again, comment: + * $staging-replan-cmd$ +
+ +--- +### 2. workspace: $production$ dir: $.$ +
Show Output + +$$$diff +` + tfOut + ` +$$$ + +* :arrow_forward: To **apply** this plan, comment: + * $production-apply-cmd$ +* :put_litter_in_its_place: To **delete** this plan click [here](production-lock-url) +* :repeat: To **plan** this project again, comment: + * $production-replan-cmd$ +
+ +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * $atlantis apply$ +` + expWithBackticks := strings.Replace(exp, "$", "`", -1) + Equals(t, expWithBackticks, rendered) +} diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt b/server/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt index 9575b3954..f49f7697b 100644 --- a/server/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt +++ b/server/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt @@ -29,7 +29,9 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d staging` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d staging` + * `atlantis plan -d staging` + + --- ### 2. workspace: `default` dir: `production`
Show Output @@ -58,7 +60,9 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d production` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d production`
+ * `atlantis plan -d production` + + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: * `atlantis apply` diff --git a/server/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt b/server/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt index b4c07debb..f9ea53e1a 100644 --- a/server/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt +++ b/server/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d staging` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d staging` + * `atlantis plan -d staging` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/modules/exp-output-plan-production.txt b/server/testfixtures/test-repos/modules/exp-output-plan-production.txt index 2663533f5..a8ec51fce 100644 --- a/server/testfixtures/test-repos/modules/exp-output-plan-production.txt +++ b/server/testfixtures/test-repos/modules/exp-output-plan-production.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d production` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d production` + * `atlantis plan -d production` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/modules/exp-output-plan-staging.txt b/server/testfixtures/test-repos/modules/exp-output-plan-staging.txt index b4c07debb..f9ea53e1a 100644 --- a/server/testfixtures/test-repos/modules/exp-output-plan-staging.txt +++ b/server/testfixtures/test-repos/modules/exp-output-plan-staging.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d staging` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d staging` + * `atlantis plan -d staging` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt b/server/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt index 2ff971241..6f0a00c64 100644 --- a/server/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt +++ b/server/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt @@ -15,6 +15,7 @@ var = fromconfig workspace = default ``` + --- ### 2. workspace: `staging` dir: `.` ```diff @@ -29,5 +30,6 @@ var = fromfile workspace = staging ``` + --- diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt b/server/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt index 96f67411c..8aed4aa38 100644 --- a/server/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt +++ b/server/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt @@ -29,7 +29,9 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d .` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d .` + * `atlantis plan -d .` + + --- ### 2. workspace: `staging` dir: `.`
Show Output @@ -58,7 +60,9 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -w staging` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -w staging`
+ * `atlantis plan -w staging` + + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: * `atlantis apply` diff --git a/server/testfixtures/test-repos/simple/exp-output-apply-var-all.txt b/server/testfixtures/test-repos/simple/exp-output-apply-var-all.txt index c966228cd..58cc65388 100644 --- a/server/testfixtures/test-repos/simple/exp-output-apply-var-all.txt +++ b/server/testfixtures/test-repos/simple/exp-output-apply-var-all.txt @@ -15,6 +15,7 @@ var = default_workspace workspace = default ``` + --- ### 2. workspace: `new_workspace` dir: `.` ```diff @@ -29,5 +30,6 @@ var = new_workspace workspace = new_workspace ``` + --- diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt index 47ead80b7..fe37e6a38 100644 --- a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt +++ b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -w new_workspace` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -w new_workspace -- -var var=new_workspace` + * `atlantis plan -w new_workspace -- -var var=new_workspace` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt index 66a713365..883283375 100644 --- a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt +++ b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d .` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d . -- -var var=overridden` + * `atlantis plan -d . -- -var var=overridden` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt index e62374cfc..947b524ff 100644 --- a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt +++ b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d .` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d . -- -var var=default_workspace` + * `atlantis plan -d . -- -var var=default_workspace` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/simple/exp-output-autoplan.txt b/server/testfixtures/test-repos/simple/exp-output-autoplan.txt index a90037810..d77057248 100644 --- a/server/testfixtures/test-repos/simple/exp-output-autoplan.txt +++ b/server/testfixtures/test-repos/simple/exp-output-autoplan.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -d .` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -d .` + * `atlantis plan -d .` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt b/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt index f5d3f30db..a84b94c2c 100644 --- a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt +++ b/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -p default` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -p default` + * `atlantis plan -p default` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt b/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt index e4da1e6e9..d1d191e9e 100644 --- a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt +++ b/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt @@ -26,7 +26,8 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -p staging` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -p staging` + * `atlantis plan -p staging` + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: diff --git a/server/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt b/server/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt index a00bdd198..00cc07c8e 100644 --- a/server/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt +++ b/server/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt @@ -31,7 +31,9 @@ workspace=default * `atlantis apply -p default` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -p default` + * `atlantis plan -p default` + + --- ### 2. workspace: `default` dir: `.`
Show Output @@ -60,7 +62,9 @@ Plan: 1 to add, 0 to change, 0 to destroy. * `atlantis apply -p staging` * :put_litter_in_its_place: To **delete** this plan click [here](lock-url) * :repeat: To **plan** this project again, comment: - * `atlantis plan -p staging`
+ * `atlantis plan -p staging` + + --- * :fast_forward: To **apply** all unapplied plans from this pull request, comment: * `atlantis apply`