aboutsummaryrefslogtreecommitdiff
path: root/app/views/terraform_http_backend/show.html.erb
blob: e1675416c30af22377d5c0fe4e686f96e48a9d5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<%#

GOV.UK Mini Environment Admin
Copyright © 2018  Christopher Baines <mail@cbaines.net>

This file is part of the GOV.UK Mini Environment Admin.

The GOV.UK Mini Environment Admin is free software: you can
redistribute it and/or modify it under the terms of the GNU Affero
General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later
version.

The GOV.UK Mini Environment Admin is distributed in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public
License along with the GOV.UK Mini Environment Admin.  If not, see
<http://www.gnu.org/licenses/>.

%>

<a class="pull-right" href="<%= terraform_states_path %>">
  View all terraform states
</a>

<div class="row">
  <div class="col-md-8">
    <h1>
      Terraform state:
      <span style="font-family: monospace;">
        <%= @state.state_id %>
      </span>
    </h1>

    <br>
    <table class="table">
      <tbody>
        <tr>
          <td>Created at</td>
          <td><%= @state.created_at %></td>
        </tr>
        <tr>
          <td>Terraform version</td>
          <td><%= @state.data['terraform_version'] %></td>
        </tr>
      </tbody>
    </table>

  </div>

  <div class="col-md-4" style="max-height: 400px; overflow-y: auto;">
    <% historical_states = TerraformState
                             .where(state_id: @state.state_id)
                             .order(:id)
                             .to_a
    %>

    <h3>History (<%= pluralize(historical_states.count, 'states') %>)</h3>

    <table class="table">
      <thead>
        <tr>
          <th>#</th>
          <th>Created at</th>
          <th></th>
        </tr>
      </thead>
      <tbody>

        <% historical_states.each_with_index do |historical_state, index| %>
          <% current = (@state.id == historical_state.id) %>

          <tr>
            <td>
              <%= index %>
              <% if current %>
                <strong>(current)</strong>
              <% end %>
            </td>
            <td>
              <%= historical_state.created_at %>
            </td>
            <td>
              <% unless current %>
                <a href="<%= terraform_http_backend_show_by_index_path(
                         historical_state.state_id,
                         index
                         )
                         %>">
                  View
                </a>
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>

<h2>Modules</h2>

<% @state.data.fetch('modules', []).each do |module_data| %>

  <h3>Path: <%= module_data['path'] %></h3>

  <h3>Outputs</h3>
  <table class="table">
  <% module_data['outputs'].each do |(key, output)| %>
    <tr>
      <td><%= key %></td>
      <td><%= output['value'] %></td>
    </tr>
  <% end %>
  </table>

  <h3>Resources</h3>
  <table class="table">
    <% module_data['resources'].each do |(name, resource)| %>
    <tr>
      <td><%= name.gsub('.', '.<wbr/>').html_safe %></td>
      <td>
        <table class="table" style="table-layout: fixed;">
          <thead>
            <tr>
              <th>Key</th>
              <th>Value</th>
            </tr>
          </thead>
          <tbody>
            <% resource['primary']['attributes'].each do |(name, value)| %>
              <tr>
                <td class="col-md-6"><strong><%= name %></strong></td>
                <td class="col-md-6"
                    style="white-space: pre-wrap; overflow-wrap: break-word; word-break: break-all;"
                ><%= value %></td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </td>
    </tr>
  <% end %>
  </table>
<% end %>