puppet-validator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/public/styles.css ADDED
@@ -0,0 +1,99 @@
1
+ body {
2
+ padding: 0 2em;
3
+ }
4
+
5
+ div.line-highlight {
6
+ /* Cannot use opacity, because that affects tooltip children as well */
7
+ background-color: rgba(255, 181, 181, 0.25);
8
+ color: black;
9
+ font-weight: bold;
10
+ }
11
+ div.line-highlight.with-tooltip {
12
+ background-color: rgba(255, 255, 0, 0.25);
13
+ pointer-events: auto;
14
+ }
15
+ div.line-highlight.with-tooltip .marker {
16
+ width: 0px;
17
+ height: 0px;
18
+ border-top: 0.5em solid #000;
19
+ border-left: 0.5em solid transparent;
20
+ position: absolute;
21
+ top: 0;
22
+ right: 0;
23
+ }
24
+ div.line-highlight.with-tooltip .line-highlight-tooltip {
25
+ position: absolute;
26
+ top: -1.75em;
27
+ right: 0;
28
+ background-color: #aaccaa;
29
+ border: 1px solid black;
30
+ border-radius: 5px;
31
+ padding: 0 3px;
32
+ display: none;
33
+ }
34
+ div.line-highlight.with-tooltip:hover .line-highlight-tooltip {
35
+ display: block;
36
+ }
37
+
38
+ div.results {
39
+ width: 65%;
40
+ border: 1px solid black;
41
+ border-radius: 0.25em;
42
+ padding: 0.5em;
43
+ margin: 0 auto;
44
+ }
45
+ div.results.success {
46
+ background-color: #61ff6e;
47
+ }
48
+ div.results.fail {
49
+ background-color: #ffb6b6;
50
+ }
51
+
52
+ div.results p {
53
+ margin: 0;
54
+ }
55
+ div.results div.row:first-of-type {
56
+ margin-top: 0.5em;
57
+ }
58
+
59
+ div.results span.label {
60
+ width: 7em;
61
+ font-weight: bold;
62
+ display: inline-block;
63
+ text-align: right;
64
+ padding-right: 0.5em;
65
+ }
66
+
67
+ div.links {
68
+ margin: 1em auto;
69
+ padding: 0.5em;
70
+ border-top: 1px solid black;
71
+ text-align: center;
72
+ }
73
+ div.links a {
74
+ margin: 0.5em;
75
+ }
76
+
77
+ div.entry {
78
+ width: 80%;
79
+ margin: 0 auto;
80
+ }
81
+ div.entry textarea {
82
+ width: 100%;
83
+ }
84
+
85
+ p.info {
86
+ background: #fefefe url('info.png') no-repeat 5px 5px !important;
87
+ border: 1px solid #efefef;
88
+ padding: 0.5em;
89
+ padding-left: 50px;
90
+ width: 65%;
91
+ margin: 0 auto;
92
+ -moz-border-radius: 0.5em;
93
+ -webkit-border-radius: 0.5em;
94
+ -khtml-border-radius: 0.5em;
95
+ border-radius: 0.5em;
96
+ }
97
+ p.info:first-line {
98
+ font-weight: bold;
99
+ }
@@ -0,0 +1,38 @@
1
+ <html>
2
+ <head>
3
+ <title>Puppet Validator</title>
4
+ <link rel="stylesheet" href="styles.css">
5
+ </head>
6
+ <body>
7
+ <h1>Testing Puppet Code</h1>
8
+ <p>
9
+ This tool will validate the Puppet DSL syntax without compiling a catalog or syncing
10
+ any resources. Be aware that this <em>only validates syntax</em>. If you have
11
+ variables that are incorrectly spelled or have a bad value, your code will still
12
+ be completely valid&mdash;and will not do what you want. See the
13
+ <a href="https://docs.puppetlabs.com/puppet/latest/reference/lang_visual_index.html">Puppet Language Guide</a>
14
+ if you need help understanding the syntax.
15
+ </p>
16
+ <p>
17
+ Some examples of flaws that will not be identified by this tool include:
18
+ <ul>
19
+ <li>Resource declarations with the incorrect name.</li>
20
+ <li>Including classes that do not exist.</li>
21
+ <li>Packages declarations with an incorrect package name.</li>
22
+ <li>File paths which do not exist on the agent.</li>
23
+ <li><code>exec</code> resources which fail to run properly.</li>
24
+ </ul>
25
+ </p>
26
+ <p>
27
+ Other tools do exist which can help make sure your code actually works as intended.
28
+ Some examples are:
29
+ <ul>
30
+ <li><a href="https://github.com/rodjek/puppet-lint">Puppet Lint</a></li>
31
+ <li><a href="http://rspec-puppet.com/tutorial/">rspec-puppet</a></li>
32
+ <li><a href="https://github.com/puppetlabs/puppetlabs_spec_helper">Puppetlabs Spec Helper</a></li>
33
+ <li><a href="https://github.com/puppetlabs/beaker">Beaker</a></li>
34
+ </ul>
35
+ </p>
36
+ <div class="links"><a href="javascript:history.back();">Try Again</a> &bull; <a href="/">Validate More Code</a></div>
37
+ </body>
38
+ </html>
data/views/index.erb ADDED
@@ -0,0 +1,24 @@
1
+ <html>
2
+ <head>
3
+ <title>Puppet Validator</title>
4
+ <link rel="stylesheet" href="styles.css">
5
+ </head>
6
+ <body>
7
+ <h1>Puppet Code Validator</h1>
8
+ <p>Paste Puppet code into the following textbox and check it for validity.</p>
9
+ <form id="code" action="/validate" method="post">
10
+ <div class="entry">
11
+ <textarea name="code" id="textarea" cols="65" rows="25"></textarea>
12
+ <input type="submit" value="Validate">
13
+ <input type="checkbox" name="lint">Include <code>puppet-lint</code> style checks.
14
+ </div>
15
+ </form>
16
+ <p class="info">
17
+ Be aware that this <em>only validates syntax</em>. It will not compile a
18
+ catalog or sync any resources. This means that, for example, it cannot
19
+ identify whether you have used the proper resource types, whether package
20
+ names are correct, or file paths exist. See <a href="/testing.html">more
21
+ information on testing and validating Puppet code.</a>
22
+ </p>
23
+ </body>
24
+ </html>
data/views/result.erb ADDED
@@ -0,0 +1,37 @@
1
+ <html>
2
+ <head>
3
+ <title>Puppet Validator</title>
4
+ <link rel="stylesheet" href="prism-default.css">
5
+ <link rel="stylesheet" href="styles.css">
6
+ <script src="prism.js"></script>
7
+ </head>
8
+ <body>
9
+ <h1>Validation Results</h1>
10
+ <div class="results <%= @status %>">
11
+ <p><%= @message %></p>
12
+ <% if @line %>
13
+ <div class="row">
14
+ <span class="label">Line Number:</span><span class="message"><%= @line %></span>
15
+ </div>
16
+ <% end %>
17
+ <% if @column %>
18
+ <div class="row">
19
+ <span class="label">Column:</span><span class="message"><%= @column %></span>
20
+ </div>
21
+ <% end %>
22
+ <% if @lint_warnings %>
23
+ <hr />
24
+ <p>See inline <code>puppet-lint</code> warnings.</p>
25
+ <% end %>
26
+ </div>
27
+ <pre data-line='<%= @highlights %>' class="line-numbers language-puppet"><code class="line-numbers language-puppet"><%= @code %></code></pre>
28
+ <div class="links"><a href="javascript:history.back();">Try Again</a> &bull; <a href="/">Validate More Code</a></div>
29
+ <p class="info">
30
+ Be aware that this has <em>only validated syntax</em>. It will not compile a
31
+ catalog or sync any resources. This means that, for example, it cannot
32
+ identify whether you have used the proper resource types, whether package
33
+ names are correct, or file paths exist. See <a href="/testing.html">more
34
+ information on testing and validating Puppet code.</a>
35
+ </p>
36
+ </body>
37
+ </html>
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-validator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Ford
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: puppet
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: puppet-lint
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ description: |2
56
+ Puppet Validator is a simple web service that accepts arbitrary code submissions and
57
+ validates it the way `puppet parser validate` would. It can optionally also
58
+ run `puppet-lint` checks on the code and display both results together.
59
+ email: binford2k@gmail.com
60
+ executables:
61
+ - puppet-validator
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - LICENSE
66
+ - README.md
67
+ - bin/puppet-validator
68
+ - config.ru
69
+ - lib/puppet-validator.rb
70
+ - public/info.png
71
+ - public/prism-default.css
72
+ - public/prism.js
73
+ - public/styles.css
74
+ - public/testing.html
75
+ - views/index.erb
76
+ - views/result.erb
77
+ homepage: https://github.com/puppetlabs/puppet-validator/
78
+ licenses: []
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Puppet code validator as a service
100
+ test_files: []
101
+ has_rdoc: false