concourse 0.35.0 → 0.40.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0e735d8ab6d592e3bc060b06f9b4e26dcef1312d05289910fa310658edd1f1e
4
- data.tar.gz: 6011194849c21c817ac5e089c350bac9adbff6179b3f5de7449748c45b7df474
3
+ metadata.gz: d7a68a94db3a3d48f5cb12aaa4425f0b6d7f10eb9064d6baa4142096b5845b0c
4
+ data.tar.gz: a5ea2a78272347f1dd3a3f47c41ebb7762eebaaada5243816a08b39742e31d66
5
5
  SHA512:
6
- metadata.gz: ab27e018c417be11f6a5f11cddb7f7ddfb93cf55186f9a331f974ecc789dd3f0f749132faec345933d04fe52bd4b618a3e33e3b015429dce86f72a42b2a947ba
7
- data.tar.gz: 90daa7b65136f480da999018e97d5b9f344b940faa7df7308541c1ae7e5de1f34abcdbf05c6fe143c46cd93a9d8674801eb5c9b227e27beda9b1ccfc7c9593d8
6
+ metadata.gz: acbba3ce3c68a8ffc965be062b04c032357e168386a0d266023f43ec5c4fe77c4f9057c8026e31423bbb310485e345b926ae942fb65f5f21202800fa1cb0ca74
7
+ data.tar.gz: 82707abc4ac5c9faea068b1076b1ffd820a9e0a4c928ca2bc80d4a49f8694da2c397c3206af2a4e867070686a60f82f4198f6121a98f57bb9fa15da9ed1632bd
@@ -1,5 +1,30 @@
1
1
  # concourse-gem changelog
2
2
 
3
+ ## v0.40.0 / 2020-12-19
4
+
5
+ * remove ruby 2.4, which has reached EOL
6
+
7
+
8
+ ## v0.39.0 / 2020-11-16
9
+
10
+ * add support for [YTT](https://get-ytt.io/) pipeline templates
11
+
12
+
13
+ ## v0.38.0 / 2020-10-01
14
+
15
+ * add ruby 3.0-rc
16
+
17
+
18
+ ## v0.37.0 / 2020-10-01
19
+
20
+ * add TruffleRuby ("truffle") as a known Ruby
21
+
22
+
23
+ ## v0.36.0 / 2020-09-07
24
+
25
+ * remove generated pipelines from rake's "CLOBBER" global (generated pipelines have been recommended for checkin to source control since v0.26.0)
26
+
27
+
3
28
  ## v0.35.0 / 2020-09-07
4
29
 
5
30
  * remove "clean" rake task (generated pipelines have been recommended for checkin to source control since v0.26.0)
data/README.md CHANGED
@@ -22,12 +22,14 @@ Here's an example pipeline maintained by this gem:
22
22
  - [Real-world Examples](#real-world-examples)
23
23
  - [Concourse pipeline configuration](#concourse-pipeline-configuration)
24
24
  * [ERB Templating](#erb-templating)
25
- * [`RUBIES`](#rubies)
25
+ * [YTT Templating](#ytt-templating)
26
+ * [Mixing ERB and YTT Templating](#mixing-erb-and-ytt-templating)
26
27
  * [Secrets](#secrets)
27
28
  * [Multiple pipelines](#multiple-pipelines)
28
29
  - [Configuration](#configuration)
29
30
  * [`directory`: Concourse subdirectory name](#directory-concourse-subdirectory-name)
30
31
  * [`fly_target`: Concourse `fly` target name](#fly_target-concourse-fly-target-name)
32
+ * [`ytt`: boolean, or a YTT configuration directory name](#ytt-boolean-or-a-ytt-configuration-directory-name)
31
33
  * [`format`: Emit the final pipelines in `fly format-pipeline` canonical format](#format-emit-the-final-pipelines-in-fly-format-pipeline-canonical-format)
32
34
  * [`pipeline_erb_filename`: Pipeline filename](#pipeline_erb_filename-pipeline-filename)
33
35
  * [`secrets_filename`: Secrets filename](#secrets_filename-secrets-filename)
@@ -122,17 +124,18 @@ resources:
122
124
  (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/).)
123
125
 
124
126
 
125
- ### `RUBIES`
127
+ #### `RUBIES`
126
128
 
127
129
  The ruby variable `RUBIES` is defined in the ERB binding during pipeline file generation. This variable looks like:
128
130
 
129
131
  ``` ruby
130
132
  # these numbers/names align with public docker image names
131
133
  RUBIES = {
132
- mri: %w[2.3 2.4 2.5 2.6], # docker repository: "ruby"
133
- jruby: %w[9.1 9.2], # docker repository: "jruby"
134
- rbx: %w[latest], # docker repository: "rubinius/docker"
135
- windows: %w[2.3 2.4 2.5 2.6] # windows-ruby-dev-tools-release
134
+ mri: %w[2.5 2.6 2.7 3.0-rc], # docker repository: "ruby"
135
+ jruby: %w[9.2], # docker repository: "jruby"
136
+ rbx: %w[latest], # docker repository: "rubinius/docker"
137
+ windows: %w[2.3 2.4 2.5 2.6], # windows-ruby-dev-tools-release
138
+ truffle: %w[stable nightly] # docker repository: flavorjones/truffleruby
136
139
  }
137
140
  ```
138
141
 
@@ -158,6 +161,71 @@ jobs:
158
161
  Note that the `windows` rubies are not Docker images, since Concourse's Houdini backend doesn't use Docker. Instead, these are implicitly referring to the supported ruby versions installed by the BOSH release at https://github.com/flavorjones/windows-ruby-dev-tools-release
159
162
 
160
163
 
164
+ ### YTT Templating
165
+
166
+ As of v0.39.0, YTT templates are also supported. It's off by default, but you can enable it by passing `ytt: true` to the `Concourse.new` or `Concourse#add_pipeline` calls in your Rakefile (see below for more context).
167
+
168
+ Your Concourse pipeline configuration file, `<myproject>.yml` (or whatever you've configured with the `:pipeline_erb_filename` parameter), will be treated like a YTT template.
169
+
170
+ You can optionally specify a directory containing your YTT configuration files (`.star` files and `.yml` templates) so that you can inject project-specific logic.
171
+
172
+ (If you're unfamiliar with YTT, you can [read about it here](https://get-ytt.io/).)
173
+
174
+
175
+ #### Rubies
176
+
177
+ These YTT variables are defined by the gem, and can be used in your template:
178
+
179
+ ```starlark
180
+ #! ruby.star
181
+ cruby_versions = {
182
+ "out_of_support": ["2.4", "2.3", "2.2", "2.1", "2.0.0"],
183
+ "supported": ["2.5", "2.6", "2.7"],
184
+ "beta": ["3.0-rc"]
185
+ }
186
+ jruby_versions = {
187
+ "out_of_support": ["9.1"],
188
+ "supported": ["9.2"],
189
+ "beta": []
190
+ }
191
+ truffleruby_versions = {
192
+ "supported": ["stable"],
193
+ "out_of_support": [],
194
+ "beta": ["nightly"]
195
+ }
196
+ ```
197
+
198
+ Here's a simple example:
199
+
200
+ ``` yaml
201
+ # myproject.yml
202
+
203
+ #@ load("ruby.star", "cruby_versions")
204
+
205
+ ---
206
+ jobs:
207
+ #@ for ruby_version in cruby_versions["supported"]:
208
+ - name: #@ "ruby-{}".format(ruby_version)
209
+ plan:
210
+ ...
211
+ - task: rake-test
212
+ config:
213
+ platform: linux
214
+ image_resource:
215
+ type: docker-image
216
+ source:
217
+ repository: "ruby"
218
+ tag: #@ "mri-{}".format(ruby_version)
219
+ ...
220
+ #@ end
221
+ ```
222
+
223
+
224
+ ### Mixing ERB and YTT Templating
225
+
226
+ Why would you do this? Well, if you really want to, I'll tell you a secret: we treat the YTT templates as though they're *also* ERB templates. So go crazy.
227
+
228
+
161
229
  ### Secrets
162
230
 
163
231
  You can use a separate file to keep your pipeline variables secret. By default, `concourse/private.yml` will be used. This filename can also be configured (see below)
@@ -206,6 +274,10 @@ Note that when you use the block form:
206
274
  * it's not necessary to explicitly call `#create_tasks!`
207
275
  * only the pipelines declared via `#add_pipeline` will be managed
208
276
 
277
+ Note also that `Concourse#add_pipeline` takes additional options:
278
+
279
+ * `ytt`: same as the global `ytt` configuration below
280
+
209
281
 
210
282
  ## Configuration
211
283
 
@@ -227,6 +299,15 @@ Concourse.new("myproject", fly_target: "myci").create_tasks! # `fly -t myci <com
227
299
  ```
228
300
 
229
301
 
302
+ ### `ytt`: Enable YTT templating
303
+
304
+ By default, this option is `false` and pipelines are treated as ERB templates.
305
+
306
+ Setting this to `true` will run the file through first ERB (which will be a no-op if you're not using ERB) and then through YTT.
307
+
308
+ Setting this to a `String` argument containing a directory path will cause YTT to be invoked with a `-f` option loading that directory.
309
+
310
+
230
311
  ### `format`: Emit the final pipelines in `fly format-pipeline` canonical format
231
312
 
232
313
  If you'd prefer to have your final pipeline files in `fly`'s "canonical format" (via `format-pipeline`), then set this to true!
@@ -349,7 +430,7 @@ rake concourse:task[job_task,fly_execute_args] # fly execute the specified task
349
430
 
350
431
  where:
351
432
 
352
- * _required_: `job_task` is formatted as `job-name/task-name`, for example, `ruby-2.4/rake-test`. (See `concourse:tasks` for a list of all available task names.)
433
+ * _required_: `job_task` is formatted as `job-name/task-name`, for example, `ruby-2.7/rake-test`. (See `concourse:tasks` for a list of all available task names.)
353
434
  * _optional_: `fly_execute_args` will default to map the project directory to a resource with the project name, e.g. `--input=myproject=.`, so your pipeline must name the input resource appropriately in order to use the default.
354
435
 
355
436
 
@@ -390,7 +471,7 @@ You can view that Concourse deployment at `http://127.0.0.1:8080` using the cred
390
471
  To target that local cluster, simply prepend the `concourse:local` task on the command line. For example, to `fly execute` a task on the local cluster:
391
472
 
392
473
  ``` sh
393
- rake concourse:local concourse:task[ruby-2.4/rake-task]
474
+ rake concourse:local concourse:task[ruby-2.7/rake-task]
394
475
  ```
395
476
 
396
477
  Or to push your pipelines to that local cluster:
@@ -11,10 +11,11 @@ class Concourse
11
11
 
12
12
  # these numbers/names align with public docker image names
13
13
  RUBIES = {
14
- mri: %w[2.4 2.5 2.6 2.7], # docker repository: "ruby"
14
+ mri: %w[2.5 2.6 2.7 3.0-rc], # docker repository: "ruby"
15
15
  jruby: %w[9.2], # docker repository: "jruby"
16
16
  rbx: %w[latest], # docker repository: "rubinius/docker"
17
17
  windows: %w[2.3 2.4 2.5 2.6], # windows-ruby-dev-tools-release
18
+ truffle: %w[stable nightly] # docker repository: flavorjones/truffleruby
18
19
  }
19
20
 
20
21
  DEFAULT_DIRECTORY = "concourse"
@@ -28,6 +29,7 @@ class Concourse
28
29
  attr_reader :fly_args
29
30
  attr_reader :secrets_filename
30
31
  attr_reader :format
32
+ attr_reader :ytt
31
33
 
32
34
  CONCOURSE_DOCKER_COMPOSE = "docker-compose.yml"
33
35
 
@@ -59,6 +61,7 @@ class Concourse
59
61
  @directory = options[:directory] || DEFAULT_DIRECTORY
60
62
  @fly_target = options[:fly_target] || DEFAULT_FLY_TARGET
61
63
  @format = options.has_key?(:format) ? options[:format] : false
64
+ @ytt = options.has_key?(:ytt) ? options[:ytt] : false
62
65
  @fly_args = options.keys.grep(/^fly_args_/).inject({}) do |hash, key|
63
66
  fly_command = key.to_s.gsub(/^fly_args_/, "").gsub("_", "-")
64
67
  hash[fly_command] = options[key]
@@ -73,12 +76,12 @@ class Concourse
73
76
  block.call(self)
74
77
  create_tasks!
75
78
  else
76
- add_pipeline(@project_name, (options[:pipeline_erb_filename] || "#{project_name}.yml"))
79
+ add_pipeline(@project_name, (options[:pipeline_erb_filename] || "#{project_name}.yml"), {ytt: ytt})
77
80
  end
78
81
  end
79
82
 
80
- def add_pipeline(name, erb_filename)
81
- @pipelines << Concourse::Pipeline.new(name, @directory, erb_filename)
83
+ def add_pipeline(name, erb_filename, options={})
84
+ @pipelines << Concourse::Pipeline.new(name, @directory, erb_filename, options)
82
85
  end
83
86
 
84
87
  def pipeline_subcommands(command)
@@ -94,9 +97,7 @@ class Concourse
94
97
  end
95
98
 
96
99
  def rake_pipeline_generate(pipeline)
97
- File.open pipeline.filename, "w" do |f|
98
- f.write erbify_file(pipeline.erb_filename, working_directory: directory)
99
- end
100
+ pipeline.generate
100
101
  fly "validate-pipeline", "-c #{pipeline.filename}"
101
102
  fly "format-pipeline", "-c #{pipeline.filename} -w" if format
102
103
  end
@@ -133,8 +134,6 @@ class Concourse
133
134
  end
134
135
 
135
136
  pipelines.each do |pipeline|
136
- CLOBBER.include pipeline.filename if defined?(CLOBBER)
137
-
138
137
  unless File.exist? pipeline.erb_filename
139
138
  warn "WARNING: concourse template #{pipeline.erb_filename.inspect} does not exist, run `rake concourse:init`"
140
139
  end
@@ -1,12 +1,31 @@
1
1
  class Concourse
2
2
  class Pipeline
3
- attr_reader :name, :directory, :erb_filename, :filename
3
+ include Concourse::Util
4
4
 
5
- def initialize name, directory, erb_filename
5
+ attr_reader :name, :directory, :erb_filename, :filename, :ytt
6
+
7
+ def initialize name, directory, erb_filename, options={}
6
8
  @name = name
7
9
  @directory = directory
8
10
  @erb_filename = File.join(@directory, erb_filename)
9
11
  @filename = File.join(@directory, erb_filename + ".generated")
12
+ @ytt = options.key?(:ytt) ? options[:ytt] : false
13
+ end
14
+
15
+ def generate
16
+ Tempfile.create(["pipeline", ".yml"]) do |f|
17
+ f.write erbify_file(erb_filename, working_directory: directory)
18
+ f.close
19
+
20
+ if ytt
21
+ ytt_args = ["-f #{f.path}"]
22
+ ytt_args << "-f #{File.expand_path(File.join(File.dirname(__FILE__), "ytt"))}"
23
+ ytt_args << "-f #{File.join(directory, ytt)}" if ytt.is_a?(String)
24
+ sh ["ytt", ytt_args, "> #{filename}"].flatten.join(" ")
25
+ else
26
+ FileUtils.mv f.path, filename, force: true
27
+ end
28
+ end
10
29
  end
11
30
  end
12
31
  end
@@ -2,5 +2,5 @@ require "rake"
2
2
  require "erb"
3
3
 
4
4
  class Concourse
5
- VERSION = "0.35.0"
5
+ VERSION = "0.40.0"
6
6
  end
@@ -0,0 +1,15 @@
1
+ cruby_versions = {
2
+ "out_of_support": ["2.4", "2.3", "2.2", "2.1", "2.0.0"],
3
+ "supported": ["2.5", "2.6", "2.7"],
4
+ "beta": ["3.0-rc"]
5
+ }
6
+ jruby_versions = {
7
+ "out_of_support": ["9.1"],
8
+ "supported": ["9.2"],
9
+ "beta": []
10
+ }
11
+ truffleruby_versions = {
12
+ "supported": ["stable"],
13
+ "out_of_support": [],
14
+ "beta": ["nightly"]
15
+ }
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.35.0
4
+ version: 0.40.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: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -88,6 +88,7 @@ files:
88
88
  - lib/concourse/pipeline.rb
89
89
  - lib/concourse/util.rb
90
90
  - lib/concourse/version.rb
91
+ - lib/concourse/ytt/ruby.star
91
92
  homepage: https://github.com/flavorjones/concourse-gem
92
93
  licenses:
93
94
  - MIT
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
110
  requirements: []
110
- rubygems_version: 3.1.2
111
+ rubygems_version: 3.1.4
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: Rake tasks for Concourse pipelines.