Skip to content

Commit

Permalink
html output: make it nice
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Menet committed Jun 5, 2019
1 parent 4396785 commit 762bf24
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions renderHTML.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,61 @@ import (

func RenderExecutionPlanAsHTML(plan [][]*Workspace) string {
tmplSrc := `<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Execution Plan</title>
<style type="text/css">
.manual {
padding-left: 40px;
border-left: solid gray 3px;
}
pre {
padding: 5px;
background-color: #777;
color: white;
overflow-x: auto;
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
}
th, td {
border-bottom: 1px solid #ddd;
padding: 15px;
text-align: left;
}
.container {
max-width: 800px;
width: 90%;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
{{range $tier, $workspaces := .}}
<h1>Tier {{ $tier }}</h1>
<h1>({{$tier}}) Tier {{ $tier }}</h1>
{{range $i, $workspace := $workspaces}}
<h2>Workspace <code>{{$workspace.Root}}</code></h2>
<h2>({{$tier}}.{{$i}}) Workspace <code>{{$workspace.Root}}</code></h2>
{{if $workspace.PreManualRendered}}
<h3>Manual Pre-Work</h3>
<div class="manual">
{{$workspace.PreManualRendered}}
</div>
{{end}}
<h3>Terraform</h3>
<code>
<pre><code>
(cd {{ $workspace.Root }} && terraform apply)
</code>
</code></pre>
{{if $workspace.PostManualRendered}}
<h3>Manual Post-Work</h3>
<div class="manual">
{{$workspace.PostManualRendered}}
{{end}}
{{end}}
{{end}}
</div>
{{end}}{{end}}{{end}}
</div>
</body>
</html>`
var out bytes.Buffer
Expand Down

0 comments on commit 762bf24

Please sign in to comment.