rudder 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/docs/Rudder/DSL.html CHANGED
@@ -143,7 +143,7 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
143
143
  <li class="public ">
144
144
  <span class="summary_signature">
145
145
 
146
- <a href="#eval_from_file-class_method" title="eval_from_file (class method)">.<strong>eval_from_file</strong>(path) &#x21d2; Rudder::DSL::Pipeline </a>
146
+ <a href="#eval_from_file-class_method" title="eval_from_file (class method)">.<strong>eval_from_file</strong>(path, vars: {}) &#x21d2; Rudder::DSL::Pipeline </a>
147
147
 
148
148
 
149
149
 
@@ -168,7 +168,7 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
168
168
  <li class="public ">
169
169
  <span class="summary_signature">
170
170
 
171
- <a href="#from_file-class_method" title="from_file (class method)">.<strong>from_file</strong>(path) &#x21d2; Rudder::DSL::Pipeline </a>
171
+ <a href="#from_file-class_method" title="from_file (class method)">.<strong>from_file</strong>(path, vars: {}) &#x21d2; Rudder::DSL::Pipeline </a>
172
172
 
173
173
 
174
174
 
@@ -225,7 +225,7 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
225
225
  <div class="method_details first">
226
226
  <h3 class="signature first" id="eval_from_file-class_method">
227
227
 
228
- .<strong>eval_from_file</strong>(path) &#x21d2; <tt><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Rudder::DSL::Pipeline</a></span></tt>
228
+ .<strong>eval_from_file</strong>(path, vars: {}) &#x21d2; <tt><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Rudder::DSL::Pipeline</a></span></tt>
229
229
 
230
230
 
231
231
 
@@ -256,6 +256,23 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
256
256
  &mdash;
257
257
  <div class='inline'>
258
258
  <p>to the <span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Pipeline</a></span> definition</p>
259
+ </div>
260
+
261
+ </li>
262
+
263
+ <li>
264
+
265
+ <span class='name'>vars</span>
266
+
267
+
268
+ <span class='type'></span>
269
+
270
+
271
+
272
+ &mdash;
273
+ <div class='inline'>
274
+ <p>optional [Hash&lt;(Symbol, String), Any&gt;] of <code>Concourse</code>
275
+ variables</p>
259
276
  </div>
260
277
 
261
278
  </li>
@@ -287,15 +304,15 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
287
304
  <pre class="lines">
288
305
 
289
306
 
290
- 50
291
- 51
292
- 52</pre>
307
+ 52
308
+ 53
309
+ 54</pre>
293
310
  </td>
294
311
  <td>
295
- <pre class="code"><span class="info file"># File 'lib/rudder/dsl.rb', line 50</span>
312
+ <pre class="code"><span class="info file"># File 'lib/rudder/dsl.rb', line 52</span>
296
313
 
297
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_eval_from_file'>eval_from_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
298
- <span class='const'><span class='object_link'><a href="../Rudder.html" title="Rudder (module)">Rudder</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Rudder::DSL (module)">DSL</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Pipeline</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DSL/Pipeline.html#initialize-instance_method" title="Rudder::DSL::Pipeline#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_eval'><span class='object_link'><a href="DSL/Pipeline.html#eval-instance_method" title="Rudder::DSL::Pipeline#eval (method)">eval</a></span></span>
314
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_eval_from_file'>eval_from_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>vars:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
315
+ <span class='const'><span class='object_link'><a href="../Rudder.html" title="Rudder (module)">Rudder</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Rudder::DSL (module)">DSL</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Pipeline</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DSL/Pipeline.html#initialize-instance_method" title="Rudder::DSL::Pipeline#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>vars:</span> <span class='id identifier rubyid_vars'>vars</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_eval'><span class='object_link'><a href="DSL/Pipeline.html#eval-instance_method" title="Rudder::DSL::Pipeline#eval (method)">eval</a></span></span>
299
316
  <span class='kw'>end</span></pre>
300
317
  </td>
301
318
  </tr>
@@ -305,7 +322,7 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
305
322
  <div class="method_details ">
306
323
  <h3 class="signature " id="from_file-class_method">
307
324
 
308
- .<strong>from_file</strong>(path) &#x21d2; <tt><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Rudder::DSL::Pipeline</a></span></tt>
325
+ .<strong>from_file</strong>(path, vars: {}) &#x21d2; <tt><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Rudder::DSL::Pipeline</a></span></tt>
309
326
 
310
327
 
311
328
 
@@ -335,6 +352,23 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
335
352
  &mdash;
336
353
  <div class='inline'>
337
354
  <p>to the <span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Pipeline</a></span> definition</p>
355
+ </div>
356
+
357
+ </li>
358
+
359
+ <li>
360
+
361
+ <span class='name'>vars</span>
362
+
363
+
364
+ <span class='type'></span>
365
+
366
+
367
+
368
+ &mdash;
369
+ <div class='inline'>
370
+ <p>optional [Hash&lt;(Symbol, String), Any&gt;] of <code>Concourse</code>
371
+ variables</p>
338
372
  </div>
339
373
 
340
374
  </li>
@@ -366,15 +400,15 @@ See <a href="https://concourse-ci.org/pipeline-groups.html" target="_parent" tit
366
400
  <pre class="lines">
367
401
 
368
402
 
369
- 39
370
403
  40
371
- 41</pre>
404
+ 41
405
+ 42</pre>
372
406
  </td>
373
407
  <td>
374
- <pre class="code"><span class="info file"># File 'lib/rudder/dsl.rb', line 39</span>
408
+ <pre class="code"><span class="info file"># File 'lib/rudder/dsl.rb', line 40</span>
375
409
 
376
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_file'>from_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
377
- <span class='const'><span class='object_link'><a href="../Rudder.html" title="Rudder (module)">Rudder</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Rudder::DSL (module)">DSL</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Pipeline</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DSL/Pipeline.html#initialize-instance_method" title="Rudder::DSL::Pipeline#initialize (method)">new</a></span></span> <span class='id identifier rubyid_path'>path</span>
410
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_file'>from_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>vars:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
411
+ <span class='const'><span class='object_link'><a href="../Rudder.html" title="Rudder (module)">Rudder</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Rudder::DSL (module)">DSL</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="DSL/Pipeline.html" title="Rudder::DSL::Pipeline (class)">Pipeline</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="DSL/Pipeline.html#initialize-instance_method" title="Rudder::DSL::Pipeline#initialize (method)">new</a></span></span> <span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>vars:</span> <span class='id identifier rubyid_vars'>vars</span>
378
412
  <span class='kw'>end</span></pre>
379
413
  </td>
380
414
  </tr>
@@ -446,7 +480,7 @@ pipelines</p>
446
480
  </div>
447
481
 
448
482
  <div id="footer">
449
- Generated on Fri Aug 16 17:25:43 2019 by
483
+ Generated on Wed Nov 6 21:05:08 2019 by
450
484
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
451
485
  0.9.20 (ruby-2.5.1).
452
486
  </div>
data/docs/Rudder.html CHANGED
@@ -118,7 +118,7 @@
118
118
  <dt id="VERSION-constant" class="">VERSION =
119
119
 
120
120
  </dt>
121
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.2.1</span><span class='tstring_end'>&#39;</span></span></pre></dd>
121
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.2.2</span><span class='tstring_end'>&#39;</span></span></pre></dd>
122
122
 
123
123
  </dl>
124
124
 
@@ -140,7 +140,7 @@
140
140
  <li class="public ">
141
141
  <span class="summary_signature">
142
142
 
143
- <a href="#compile-class_method" title="compile (class method)">.<strong>compile</strong>(path) &#x21d2; Hash </a>
143
+ <a href="#compile-class_method" title="compile (class method)">.<strong>compile</strong>(path, vars: {}) &#x21d2; Hash </a>
144
144
 
145
145
 
146
146
 
@@ -199,7 +199,7 @@ handle <code>output</code>.</p>
199
199
  <div class="method_details first">
200
200
  <h3 class="signature first" id="compile-class_method">
201
201
 
202
- .<strong>compile</strong>(path) &#x21d2; <tt>Hash</tt>
202
+ .<strong>compile</strong>(path, vars: {}) &#x21d2; <tt>Hash</tt>
203
203
 
204
204
 
205
205
 
@@ -230,6 +230,23 @@ Hash</p>
230
230
  &mdash;
231
231
  <div class='inline'>
232
232
  <p>the path to the <code>Rudder</code> definition</p>
233
+ </div>
234
+
235
+ </li>
236
+
237
+ <li>
238
+
239
+ <span class='name'>vars</span>
240
+
241
+
242
+ <span class='type'></span>
243
+
244
+
245
+
246
+ &mdash;
247
+ <div class='inline'>
248
+ <p>optional [Hash&lt;(Symbol, String), Any&gt;] of <code>Concourse</code>
249
+ variables</p>
233
250
  </div>
234
251
 
235
252
  </li>
@@ -261,15 +278,15 @@ Hash</p>
261
278
  <pre class="lines">
262
279
 
263
280
 
264
- 20
265
281
  21
266
- 22</pre>
282
+ 22
283
+ 23</pre>
267
284
  </td>
268
285
  <td>
269
- <pre class="code"><span class="info file"># File 'lib/rudder.rb', line 20</span>
286
+ <pre class="code"><span class="info file"># File 'lib/rudder.rb', line 21</span>
270
287
 
271
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compile'>compile</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
272
- <span class='const'><span class='object_link'><a href="" title="Rudder (module)">Rudder</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Rudder/DSL.html" title="Rudder::DSL (module)">DSL</a></span></span><span class='period'>.</span><span class='id identifier rubyid_eval_from_file'><span class='object_link'><a href="Rudder/DSL.html#eval_from_file-class_method" title="Rudder::DSL.eval_from_file (method)">eval_from_file</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_h'><span class='object_link'><a href="Rudder/DSL/Pipeline.html#to_h-instance_method" title="Rudder::DSL::Pipeline#to_h (method)">to_h</a></span></span>
288
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compile'>compile</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>vars:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
289
+ <span class='const'><span class='object_link'><a href="" title="Rudder (module)">Rudder</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Rudder/DSL.html" title="Rudder::DSL (module)">DSL</a></span></span><span class='period'>.</span><span class='id identifier rubyid_eval_from_file'><span class='object_link'><a href="Rudder/DSL.html#eval_from_file-class_method" title="Rudder::DSL.eval_from_file (method)">eval_from_file</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='label'>vars:</span> <span class='id identifier rubyid_vars'>vars</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_h'><span class='object_link'><a href="Rudder/DSL/Pipeline.html#to_h-instance_method" title="Rudder::DSL::Pipeline#to_h (method)">to_h</a></span></span>
273
290
  <span class='kw'>end</span></pre>
274
291
  </td>
275
292
  </tr>
@@ -352,12 +369,12 @@ handle <code>output</code></p>
352
369
  <pre class="lines">
353
370
 
354
371
 
355
- 32
356
372
  33
357
- 34</pre>
373
+ 34
374
+ 35</pre>
358
375
  </td>
359
376
  <td>
360
- <pre class="code"><span class="info file"># File 'lib/rudder.rb', line 32</span>
377
+ <pre class="code"><span class="info file"># File 'lib/rudder.rb', line 33</span>
361
378
 
362
379
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_pipeline'>pipeline</span><span class='comma'>,</span> <span class='id identifier rubyid_output'>output</span><span class='rparen'>)</span>
363
380
  <span class='id identifier rubyid_output'>output</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_pipeline'>pipeline</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span><span class='rparen'>)</span><span class='rparen'>)</span>
@@ -372,7 +389,7 @@ handle <code>output</code></p>
372
389
  </div>
373
390
 
374
391
  <div id="footer">
375
- Generated on Fri Aug 16 17:25:43 2019 by
392
+ Generated on Wed Nov 6 21:05:08 2019 by
376
393
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
377
394
  0.9.20 (ruby-2.5.1).
378
395
  </div>
data/docs/_index.html CHANGED
@@ -201,7 +201,7 @@
201
201
  </div>
202
202
 
203
203
  <div id="footer">
204
- Generated on Fri Aug 16 17:25:42 2019 by
204
+ Generated on Wed Nov 6 21:05:08 2019 by
205
205
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
206
206
  0.9.20 (ruby-2.5.1).
207
207
  </div>
@@ -71,8 +71,8 @@ src="https://img.shields.io/badge/License-MIT-yellow.svg"></a></p>
71
71
  href="https://concourse-ci.org/">Concourse CI</a> pipelines.</p>
72
72
 
73
73
  <p>Rubygems release docs can be found above, or head over to <a
74
- href="https://jhmcstanton.github.io/rudder">jhmcstanton.github.io/rudder</a>
75
- for the latest docs from HEAD.</p>
74
+ href="https://rudder.jhmcstanton.com">rudder.jhmcstanton.com</a> for the
75
+ latest docs from HEAD.</p>
76
76
 
77
77
  <h2 id="label-Goals">Goals</h2>
78
78
 
@@ -190,7 +190,7 @@ href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
190
190
  </div></div>
191
191
 
192
192
  <div id="footer">
193
- Generated on Fri Aug 16 17:25:43 2019 by
193
+ Generated on Wed Nov 6 21:05:08 2019 by
194
194
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
195
195
  0.9.20 (ruby-2.5.1).
196
196
  </div>
data/docs/index.html CHANGED
@@ -71,8 +71,8 @@ src="https://img.shields.io/badge/License-MIT-yellow.svg"></a></p>
71
71
  href="https://concourse-ci.org/">Concourse CI</a> pipelines.</p>
72
72
 
73
73
  <p>Rubygems release docs can be found above, or head over to <a
74
- href="https://jhmcstanton.github.io/rudder">jhmcstanton.github.io/rudder</a>
75
- for the latest docs from HEAD.</p>
74
+ href="https://rudder.jhmcstanton.com">rudder.jhmcstanton.com</a> for the
75
+ latest docs from HEAD.</p>
76
76
 
77
77
  <h2 id="label-Goals">Goals</h2>
78
78
 
@@ -190,7 +190,7 @@ href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
190
190
  </div></div>
191
191
 
192
192
  <div id="footer">
193
- Generated on Fri Aug 16 17:25:43 2019 by
193
+ Generated on Wed Nov 6 21:05:08 2019 by
194
194
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
195
195
  0.9.20 (ruby-2.5.1).
196
196
  </div>
@@ -356,6 +356,14 @@
356
356
  </li>
357
357
 
358
358
 
359
+ <li class="even ">
360
+ <div class="item">
361
+ <span class='object_link'><a href="Rudder/DSL/Pipeline.html#vars-instance_method" title="Rudder::DSL::Pipeline#vars (method)">#vars</a></span>
362
+ <small>Rudder::DSL::Pipeline</small>
363
+ </div>
364
+ </li>
365
+
366
+
359
367
 
360
368
  </ul>
361
369
  </div>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Fri Aug 16 17:25:43 2019 by
103
+ Generated on Wed Nov 6 21:05:08 2019 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.20 (ruby-2.5.1).
106
106
  </div>
Binary file
@@ -0,0 +1,6 @@
1
+ # Vars Example
2
+
3
+ It is occasionally useful to be able to include a Concourse vars file while
4
+ generating a pipeline with Rudder. This is a simple example of doing so.
5
+
6
+ ![Vars Pipeline](../images/vars/vars.png)
@@ -0,0 +1,4 @@
1
+ some_values:
2
+ - first
3
+ - second
4
+ - third
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ vals = vars[:some_values]
4
+
5
+ resource :timer, :time do
6
+ # The source field can also be assigned via a method
7
+ source(interval: '5m')
8
+ end
9
+
10
+ vals.each do |val|
11
+ job "echo #{val}" do
12
+ plan << { get: :timer, trigger: true }
13
+ plan << { task: 'print', config: {
14
+ platform: 'linux',
15
+ image_resource: { type: 'docker-image', source: { repository: 'busybox' }},
16
+ run: {
17
+ path: 'echo',
18
+ args: ['Value: ', val]
19
+ }
20
+ }
21
+ }
22
+ end
23
+ end
data/exe/rudder CHANGED
@@ -10,7 +10,7 @@ name = File.basename __FILE__
10
10
 
11
11
  # TODO: Figure out a nice way to join these options with fly's without
12
12
  # tieing them together
13
- options = {}
13
+ options = { }
14
14
  optparse = OptionParser.new do |opts|
15
15
  opts.banner = "Usage: #{name} [options]"
16
16
 
@@ -22,6 +22,10 @@ optparse = OptionParser.new do |opts|
22
22
  options[:rudder] = c
23
23
  end
24
24
 
25
+ opts.on('-l', '--load-vars-from CONCOURSE_VARS', 'Path to the CONCOURSE_VARS yaml file') do |v|
26
+ options[:vars] = v
27
+ end
28
+
25
29
  opts.on('-v', '--version', 'Show version') do
26
30
  options[:version] = true
27
31
  end
@@ -39,7 +43,11 @@ unless options[:rudder]
39
43
  exit 1
40
44
  end
41
45
 
42
- pipeline = Rudder.compile(options[:rudder])
46
+ vars = {}
47
+ vars_path = options[:vars]
48
+ vars = YAML.load_file(vars_path) if vars_path
49
+
50
+ pipeline = Rudder.compile(options[:rudder], vars: vars)
43
51
 
44
52
  output = STDOUT
45
53
  if options[:output]
@@ -139,6 +139,31 @@ module Rudder
139
139
  # }
140
140
  # }
141
141
  # end
142
+ #
143
+ # === Loading Concourse Variables
144
+ # Occasionally it is helpful to have access to concourse variable
145
+ # when generating a pipeline, for example, when a Rudder pipeline
146
+ # should be parameterized on some value already stored in a Concourse
147
+ # parameter file. Rudder supports loading a concourse vars file from
148
+ # the {Rudder} command line. These are exposed to the pipeline dsl
149
+ # through the +vars+ accessor.
150
+ #
151
+ # @example Loading Concourse Variables
152
+ # #
153
+ # # vars_pipeline.rb
154
+ # #
155
+ # # Assuming a variables file of the form:
156
+ # #
157
+ # # my_branch: awesome-feature
158
+ # #
159
+ #
160
+ # my_branch = vars[:my_branch] # <--- Pulls in the variable here
161
+ #
162
+ # resource :my_git_repo, :git do
163
+ # source[:uri] = 'https://github.com/my/repo.git'
164
+ # source[:branch] = my_branch
165
+ # end
166
+ # ...
142
167
  class Pipeline
143
168
  include Rudder::DSL::Util
144
169
  # {Hash} of names to {Rudder::DSL::Resource}
@@ -153,6 +178,9 @@ module Rudder
153
178
  # {Hash} of names to {Rudder::DSL::Group}
154
179
  # @return [Hash<(String, Symbol), Rudder::DSL::Group>]
155
180
  attr_accessor :groups
181
+ # {Hash} of concourse variables
182
+ # @return [Hash<Symbol, (String,Float,Hash,Array)>]
183
+ attr_accessor :vars
156
184
 
157
185
  ##
158
186
  # All pipelines require:
@@ -179,9 +207,12 @@ module Rudder
179
207
  # map of Group names to their definitions.
180
208
  # @param resources_types [Hash<(String, Symbol), Rudder::DSL::ResourceType]
181
209
  # map of Resource Type names to their definitions.
210
+ # @param vars [Hash<(String, Symbol), (String,Float,Hash,Array)]
211
+ # map of var names to corresponding concourse variable
212
+ # value
182
213
  #
183
214
  def initialize(file_path = nil, resources: {}, jobs: {},
184
- groups: {}, resource_types: {})
215
+ groups: {}, resource_types: {}, vars: {})
185
216
  @resources = resources
186
217
  @jobs = jobs
187
218
  @groups = groups
@@ -196,6 +227,9 @@ module Rudder
196
227
  # rubocop:enable Layout/AlignHash, Layout/SpaceBeforeComma
197
228
  @pipelines = {}
198
229
  @file_path = file_path
230
+ @vars = vars.map do |k, v|
231
+ [k.to_sym, v]
232
+ end.to_h
199
233
  end
200
234
 
201
235
  ##
data/lib/rudder/dsl.rb CHANGED
@@ -34,10 +34,11 @@ module Rudder
34
34
  # at the +path+
35
35
  #
36
36
  # @param path [String] to the {Rudder::DSL::Pipeline} definition
37
+ # @param vars optional [Hash<(Symbol, String), Any>] of +Concourse+ variables
37
38
  # @return [Rudder::DSL::Pipeline] from +path+, unevaluated
38
39
  #
39
- def self.from_file(path)
40
- Rudder::DSL::Pipeline.new path
40
+ def self.from_file(path, vars: {})
41
+ Rudder::DSL::Pipeline.new path, vars: vars
41
42
  end
42
43
 
43
44
  ##
@@ -45,10 +46,11 @@ module Rudder
45
46
  # at the +path+
46
47
  #
47
48
  # @param path [String] to the {Rudder::DSL::Pipeline} definition
49
+ # @param vars optional [Hash<(Symbol, String), Any>] of +Concourse+ variables
48
50
  # @return [Rudder::DSL::Pipeline] from +path+, fully evaluated
49
51
  #
50
- def self.eval_from_file(path)
51
- Rudder::DSL::Pipeline.new(path).eval
52
+ def self.eval_from_file(path, vars: {})
53
+ Rudder::DSL::Pipeline.new(path, vars: vars).eval
52
54
  end
53
55
  end
54
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rudder
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/rudder.rb CHANGED
@@ -15,10 +15,11 @@ module Rudder
15
15
  # to a {Hash}
16
16
  #
17
17
  # @param path [String] the path to the +Rudder+ definition
18
+ # @param vars optional [Hash<(Symbol, String), Any>] of +Concourse+ variables
18
19
  # @return [Hash] Concourse YAML friendly hash
19
20
  #
20
- def self.compile(path)
21
- Rudder::DSL.eval_from_file(path).to_h
21
+ def self.compile(path, vars: {})
22
+ Rudder::DSL.eval_from_file(path, vars: vars).to_h
22
23
  end
23
24
 
24
25
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim McStanton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2019-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,6 +101,7 @@ files:
101
101
  - bin/console
102
102
  - bin/setup
103
103
  - docker-compose.yml
104
+ - docs/CNAME
104
105
  - docs/Rudder.html
105
106
  - docs/Rudder/DSL.html
106
107
  - docs/Rudder/DSL/Component.html
@@ -142,6 +143,7 @@ files:
142
143
  - examples/images/shared/borrows.png
143
144
  - examples/images/shared/common.png
144
145
  - examples/images/shared/wrapper.png
146
+ - examples/images/vars/vars.png
145
147
  - examples/includes/README.md
146
148
  - examples/includes/includes_pipeline.rb
147
149
  - examples/includes/jobs/log.rb
@@ -150,6 +152,9 @@ files:
150
152
  - examples/shared/borrows_pipeline.rb
151
153
  - examples/shared/common_pipeline.rb
152
154
  - examples/shared/wrapper_pipeline.rb
155
+ - examples/vars/README.md
156
+ - examples/vars/vars.yml
157
+ - examples/vars/vars_pipeline.rb
153
158
  - exe/rudder
154
159
  - lib/rudder.rb
155
160
  - lib/rudder/dsl.rb
@@ -168,10 +173,10 @@ licenses:
168
173
  - MIT
169
174
  metadata:
170
175
  homepage_uri: https://github.com/jhmcstanton/rudder
171
- changelog_uri: https://github.com/jhmcstanton/rudder/blob/0.2.2/CHANGELOG.md
176
+ changelog_uri: https://github.com/jhmcstanton/rudder/blob/0.3.0/CHANGELOG.md
172
177
  source_code_uri: https://github.com/jhmcstanton/rudder
173
178
  bug_tracker_uri: https://github.com/jhmcstanton/rudder/issues
174
- documentation_uri: https://www.rubydoc.info/gems/rudder/0.2.2
179
+ documentation_uri: https://www.rubydoc.info/gems/rudder/0.3.0
175
180
  post_install_message:
176
181
  rdoc_options: []
177
182
  require_paths: