concourse 0.38.0 → 0.39.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +82 -2
- data/lib/concourse.rb +6 -6
- data/lib/concourse/pipeline.rb +21 -2
- data/lib/concourse/version.rb +1 -1
- data/lib/concourse/ytt/ruby.star +15 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd55e825ebdac1ac76b5d97ac48b4ddbf7dc8771e6e6a1855bb38ed9dde92a99
|
4
|
+
data.tar.gz: db17dddab390c5755e8954e30ed4b91bbde773afe7a8a17b0f526368c8af7391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7f87dd6367321ab38c19881905a472b68c987199d6601817468cd171653a41ed37be9cb9f40bec19577c2daabe079eaa380e6b5106f57e50a56febba584720
|
7
|
+
data.tar.gz: 8c489739957e3a872f85345d7376e403464b0545548eaf296d0a549d3056113f8d6a350efc6157cf1e8181791f1184247958a096f46b0198fe1954c0f332346b
|
data/CHANGELOG.md
CHANGED
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
|
-
* [
|
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,7 +124,7 @@ 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
|
-
|
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
|
|
@@ -158,6 +160,71 @@ jobs:
|
|
158
160
|
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
161
|
|
160
162
|
|
163
|
+
### YTT Templating
|
164
|
+
|
165
|
+
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).
|
166
|
+
|
167
|
+
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.
|
168
|
+
|
169
|
+
You can optionally specify a directory containing your YTT configuration files (`.star` files and `.yml` templates) so that you can inject project-specific logic.
|
170
|
+
|
171
|
+
(If you're unfamiliar with YTT, you can [read about it here](https://get-ytt.io/).)
|
172
|
+
|
173
|
+
|
174
|
+
#### Rubies
|
175
|
+
|
176
|
+
These YTT variables are defined by the gem, and can be used in your template:
|
177
|
+
|
178
|
+
```starlark
|
179
|
+
#! ruby.star
|
180
|
+
cruby_versions = {
|
181
|
+
"supported": ["2.4", "2.5", "2.6", "2.7"],
|
182
|
+
"out_of_support": ["2.3", "2.2", "2.1", "2.0.0"],
|
183
|
+
"beta": ["3.0-rc"]
|
184
|
+
}
|
185
|
+
jruby_versions = {
|
186
|
+
"supported": ["9.2"],
|
187
|
+
"out_of_support": ["9.1"],
|
188
|
+
"beta": []
|
189
|
+
}
|
190
|
+
truffleruby_versions = {
|
191
|
+
"supported": ["stable"],
|
192
|
+
"out_of_support": [],
|
193
|
+
"beta": ["nightly"]
|
194
|
+
}
|
195
|
+
```
|
196
|
+
|
197
|
+
Here's a simple example:
|
198
|
+
|
199
|
+
``` yaml
|
200
|
+
# myproject.yml
|
201
|
+
|
202
|
+
#@ load("ruby.star", "cruby_versions")
|
203
|
+
|
204
|
+
---
|
205
|
+
jobs:
|
206
|
+
#@ for ruby_version in cruby_versions["supported"]:
|
207
|
+
- name: #@ "ruby-{}".format(ruby_version)
|
208
|
+
plan:
|
209
|
+
...
|
210
|
+
- task: rake-test
|
211
|
+
config:
|
212
|
+
platform: linux
|
213
|
+
image_resource:
|
214
|
+
type: docker-image
|
215
|
+
source:
|
216
|
+
repository: "ruby"
|
217
|
+
tag: #@ "mri-{}".format(ruby_version)
|
218
|
+
...
|
219
|
+
#@ end
|
220
|
+
```
|
221
|
+
|
222
|
+
|
223
|
+
### Mixing ERB and YTT Templating
|
224
|
+
|
225
|
+
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.
|
226
|
+
|
227
|
+
|
161
228
|
### Secrets
|
162
229
|
|
163
230
|
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 +273,10 @@ Note that when you use the block form:
|
|
206
273
|
* it's not necessary to explicitly call `#create_tasks!`
|
207
274
|
* only the pipelines declared via `#add_pipeline` will be managed
|
208
275
|
|
276
|
+
Note also that `Concourse#add_pipeline` takes additional options:
|
277
|
+
|
278
|
+
* `ytt`: same as the global `ytt` configuration below
|
279
|
+
|
209
280
|
|
210
281
|
## Configuration
|
211
282
|
|
@@ -227,6 +298,15 @@ Concourse.new("myproject", fly_target: "myci").create_tasks! # `fly -t myci <com
|
|
227
298
|
```
|
228
299
|
|
229
300
|
|
301
|
+
### `ytt`: Enable YTT templating
|
302
|
+
|
303
|
+
By default, this option is `false` and pipelines are treated as ERB templates.
|
304
|
+
|
305
|
+
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.
|
306
|
+
|
307
|
+
Setting this to a `String` argument containing a directory path will cause YTT to be invoked with a `-f` option loading that directory.
|
308
|
+
|
309
|
+
|
230
310
|
### `format`: Emit the final pipelines in `fly format-pipeline` canonical format
|
231
311
|
|
232
312
|
If you'd prefer to have your final pipeline files in `fly`'s "canonical format" (via `format-pipeline`), then set this to true!
|
data/lib/concourse.rb
CHANGED
@@ -29,6 +29,7 @@ class Concourse
|
|
29
29
|
attr_reader :fly_args
|
30
30
|
attr_reader :secrets_filename
|
31
31
|
attr_reader :format
|
32
|
+
attr_reader :ytt
|
32
33
|
|
33
34
|
CONCOURSE_DOCKER_COMPOSE = "docker-compose.yml"
|
34
35
|
|
@@ -60,6 +61,7 @@ class Concourse
|
|
60
61
|
@directory = options[:directory] || DEFAULT_DIRECTORY
|
61
62
|
@fly_target = options[:fly_target] || DEFAULT_FLY_TARGET
|
62
63
|
@format = options.has_key?(:format) ? options[:format] : false
|
64
|
+
@ytt = options.has_key?(:ytt) ? options[:ytt] : false
|
63
65
|
@fly_args = options.keys.grep(/^fly_args_/).inject({}) do |hash, key|
|
64
66
|
fly_command = key.to_s.gsub(/^fly_args_/, "").gsub("_", "-")
|
65
67
|
hash[fly_command] = options[key]
|
@@ -74,12 +76,12 @@ class Concourse
|
|
74
76
|
block.call(self)
|
75
77
|
create_tasks!
|
76
78
|
else
|
77
|
-
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})
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
|
-
def add_pipeline(name, erb_filename)
|
82
|
-
@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)
|
83
85
|
end
|
84
86
|
|
85
87
|
def pipeline_subcommands(command)
|
@@ -95,9 +97,7 @@ class Concourse
|
|
95
97
|
end
|
96
98
|
|
97
99
|
def rake_pipeline_generate(pipeline)
|
98
|
-
|
99
|
-
f.write erbify_file(pipeline.erb_filename, working_directory: directory)
|
100
|
-
end
|
100
|
+
pipeline.generate
|
101
101
|
fly "validate-pipeline", "-c #{pipeline.filename}"
|
102
102
|
fly "format-pipeline", "-c #{pipeline.filename} -w" if format
|
103
103
|
end
|
data/lib/concourse/pipeline.rb
CHANGED
@@ -1,12 +1,31 @@
|
|
1
1
|
class Concourse
|
2
2
|
class Pipeline
|
3
|
-
|
3
|
+
include Concourse::Util
|
4
4
|
|
5
|
-
|
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
|
data/lib/concourse/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
cruby_versions = {
|
2
|
+
"supported": ["2.4", "2.5", "2.6", "2.7"],
|
3
|
+
"out_of_support": ["2.3", "2.2", "2.1", "2.0.0"],
|
4
|
+
"beta": ["3.0-rc"]
|
5
|
+
}
|
6
|
+
jruby_versions = {
|
7
|
+
"supported": ["9.2"],
|
8
|
+
"out_of_support": ["9.1"],
|
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.
|
4
|
+
version: 0.39.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-
|
11
|
+
date: 2020-11-16 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.
|
111
|
+
rubygems_version: 3.1.4
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: Rake tasks for Concourse pipelines.
|