concourse 0.23.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50517da26e0d7eb88bb231814b9a664ee17bc5e08c278eb2724e472797832867
4
- data.tar.gz: 7c0ce4a2fc2844bf187ba242d47c62c5b1ab684ef85d6194520c90807b10b8c3
3
+ metadata.gz: 69454c7a7cfcaa97aa0ae0e60154643107ec31e27f4870fb2c03e3cb5cf8e53a
4
+ data.tar.gz: b2d936d3806d0725a78549f984b5d25bd0bb02bb171d6cbcb13b47ecf0c61bf3
5
5
  SHA512:
6
- metadata.gz: c19043e491bd57cfc3f57babcc494ac0eee2e35e501f3a45e076af6655c8b94940f89ece2d7b067f762039a0723031e3329c2b635525927bf0a40202158727be
7
- data.tar.gz: fb3024061b013b796d65e68757cb9aade22126868d7c3c29be367c0ac39142da96c3024575c7753f5c3909f67d53104cb25c5eb1fd85a8a283c99b8ddc41c7f2
6
+ metadata.gz: 279c5aea4104ccb041bbfa02700625356dc31dbdf2e21f0c9f2cdd928883108f55f149609f06cc7e7a174434abc899760e744c50423ebca1753ab514fae52130
7
+ data.tar.gz: d298b46e242c2230984d7b7e503fd82ab6fd4ff6aa6d1b2803e6fd9731fa5733f1ac27ae53f7a6050c73269d9fb193b5f18f7f0b0581f2f194e6e07b52f03f93
@@ -1,5 +1,18 @@
1
1
  # concourse-gem changelog
2
2
 
3
+ ## 0.24.0 / 2019-01-24
4
+
5
+ ### Features
6
+
7
+ * `$LOAD_PATH` includes the concourse directory, so that `require` will find relative filepaths.
8
+ * `erbify_file` method may be called to recursively include yaml erb templates.
9
+
10
+
11
+ ### Breaking changes
12
+
13
+ * `#erbify` has been removed in favor of `#erbify_file`
14
+
15
+
3
16
  ## 0.23.0 / 2019-01-19
4
17
 
5
18
  ### Features
data/README.md CHANGED
@@ -16,7 +16,8 @@ If you're not familiar with Concourse CI, you can read up on it at https://conco
16
16
  * [Add to your `Rakefile`](#add-to-your-rakefile)
17
17
  * [Set up your Concourse pipeline](#set-up-your-concourse-pipeline)
18
18
  - [Concourse pipeline configuration](#concourse-pipeline-configuration)
19
- * [ERB Templating and `RUBIES`](#erb-templating-and-rubies)
19
+ * [ERB Templating](#erb-templating)
20
+ * [`RUBIES`](#rubies)
20
21
  * [Secrets](#secrets)
21
22
  * [Multiple pipelines](#multiple-pipelines)
22
23
  - [Configuration](#configuration)
@@ -76,12 +77,31 @@ The `concourse:init` task will do a few different things for you:
76
77
 
77
78
  ## Concourse pipeline configuration
78
79
 
79
- ### ERB Templating and `RUBIES`
80
+ ### ERB Templating
80
81
 
81
82
  Your Concourse pipeline configuration file, `<myproject>.yml` (or whatever you've configured with the `:pipeline_erb_filename` parameter), will be treated like an ERB template.
82
83
 
84
+ The concourse directory is added the `$LOAD_PATH` and so local ruby files may be `require`d if you so desire. Also note that you can include other yaml erb snippets with the method `erbify_file`.
85
+
86
+ An example using both of these features:
87
+
88
+ ``` yaml
89
+ % require "common_prelude" # will find "common_prelude.rb" in the concourse directory
90
+
91
+ resources:
92
+ <%= erbify_file "common_resources.yml" -%> # will find this file in the concourse directory and recursively erbify it
93
+ - name: resource_unique_to_this_pipeline
94
+ type: git
95
+ source:
96
+ uri: <%= $common_prelude_defined_uri_prefix %>/username/projectname.git
97
+ branch: master
98
+ ```
99
+
83
100
  (If you're unfamiliar with ERB and how you can mix Ruby into the document, you can [read about it here](https://www.stuartellis.name/articles/erb/).)
84
101
 
102
+
103
+ ### `RUBIES`
104
+
85
105
  The ruby variable `RUBIES` is defined in the ERB binding during pipeline file generation. This variable looks like:
86
106
 
87
107
  ``` ruby
@@ -211,33 +231,33 @@ Tasks to manage a local pipeline file, generated from an ERB template:
211
231
 
212
232
  ```
213
233
  rake concourse:clean # remove generated pipeline files
214
- rake concourse:generate # generate and validate the pipeline files for myproject
234
+ rake concourse:generate # generate and validate all pipeline files
215
235
  ```
216
236
 
217
237
  A task to update your pipeline configuration:
218
238
 
219
239
  ```
220
- rake concourse:set # upload the pipeline files for myproject
240
+ rake concourse:set # upload all pipeline files
221
241
  ```
222
242
 
223
243
  Tasks to publicly expose or hide your pipeline:
224
244
 
225
245
  ```
226
- rake concourse:expose # expose the myproject pipelines
227
- rake concourse:hide # hide the myproject pipelines
246
+ rake concourse:expose # expose all pipelines
247
+ rake concourse:hide # hide all pipelines
228
248
  ```
229
249
 
230
250
  Tasks to pause and unpause your pipeline:
231
251
 
232
252
  ```
233
- rake concourse:pause # pause the myproject pipelines
234
- rake concourse:unpause # unpause the myproject pipelines
253
+ rake concourse:pause # pause all pipelines
254
+ rake concourse:unpause # unpause all pipelines
235
255
  ```
236
256
 
237
257
  And, should you ever need to [nuke the site from orbit][ripley], a task to destroy your pipeline:
238
258
 
239
259
  ```
240
- rake concourse:destroy # destroy the myproject pipelines
260
+ rake concourse:destroy # destroy all pipelines
241
261
  ```
242
262
 
243
263
  [ripley]: https://www.youtube.com/watch?v=aCbfMkh940Q
@@ -248,7 +268,7 @@ rake concourse:destroy # destroy the myproject pipelines
248
268
  You can see a list of all the tasks defined in your pipelines:
249
269
 
250
270
  ```
251
- rake concourse:tasks # list all the available tasks from the myproject pipelines
271
+ rake concourse:tasks # list all available tasks from all pipelines
252
272
  ```
253
273
 
254
274
  You'll see output suitable for the `concourse:task` rake task, formatted as `job-name/task-name`, looking something like:
@@ -81,6 +81,13 @@ class Concourse
81
81
  ensure_in_gitignore secrets_filename
82
82
  end
83
83
 
84
+ def rake_pipeline_generate pipeline
85
+ File.open pipeline.filename, "w" do |f|
86
+ f.write erbify_file(pipeline.erb_filename, working_directory: directory)
87
+ end
88
+ sh "fly validate-pipeline -c #{pipeline.filename}"
89
+ end
90
+
84
91
  def create_tasks!
85
92
  unless Dir.exist? directory
86
93
  mkdir_p directory
@@ -112,10 +119,7 @@ class Concourse
112
119
  pipelines.each do |pipeline|
113
120
  desc "generate and validate the #{pipeline.name} pipeline file"
114
121
  task "generate:#{pipeline.name}" do
115
- File.open pipeline.filename, "w" do |f|
116
- f.write erbify(File.read(pipeline.erb_filename))
117
- end
118
- sh "fly validate-pipeline -c #{pipeline.filename}"
122
+ rake_pipeline_generate pipeline
119
123
  end
120
124
  end
121
125
 
@@ -159,7 +163,7 @@ class Concourse
159
163
  #
160
164
  # task commands
161
165
  #
162
- desc "list all the available tasks from the #{project_name} pipelines"
166
+ desc "list all available tasks from all pipelines"
163
167
  task "tasks" => "generate" do
164
168
  tasks = []
165
169
 
@@ -20,7 +20,7 @@ class Concourse
20
20
 
21
21
  def sh command
22
22
  running "(in #{Dir.pwd}) #{command}"
23
- super command, verbose: false
23
+ Rake.sh command, verbose: false
24
24
  end
25
25
 
26
26
  def running message
@@ -31,8 +31,17 @@ class Concourse
31
31
  print bold, green, "NOTE: ", reset, message, "\n"
32
32
  end
33
33
 
34
- def erbify document_string, *args
35
- ERB.new(document_string, nil, "%-").result(binding)
34
+ def erbify_file filename, working_directory: nil
35
+ raise "ERROR: erbify_file: could not find file `#{filename}`" unless File.exist?(filename)
36
+ template = File.read(filename)
37
+
38
+ if working_directory.nil?
39
+ working_directory = "." # so chdir is a no-op below
40
+ else
41
+ fqwd = File.expand_path(working_directory)
42
+ $LOAD_PATH << fqwd unless $LOAD_PATH.include?(fqwd) # so "require" can load relative paths
43
+ end
44
+ Dir.chdir(working_directory) { ERB.new(template, nil, "%-").result(binding) }
36
45
  end
37
46
 
38
47
  def each_job pipeline
@@ -2,5 +2,5 @@ require "rake"
2
2
  require "erb"
3
3
 
4
4
  class Concourse
5
- VERSION = "0.23.0"
5
+ VERSION = "0.24.0"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2019-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor