conjur-debify 3.0.3.pre.216 → 3.0.3.pre.1914
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -9
- data/Dockerfile +1 -1
- data/Jenkinsfile +31 -165
- data/README.md +1 -1
- data/VERSION +1 -1
- data/features/package.feature +7 -7
- data/image-tags +1 -4
- data/lib/conjur/debify/action/publish.rb +34 -53
- data/lib/conjur/debify.rb +315 -328
- data/push-image.sh +2 -8
- data/tag-image.sh +6 -0
- metadata +3 -3
- data/push-manifest.sh +0 -14
data/lib/conjur/debify.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "conjur/debify/version"
|
2
2
|
require 'docker'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'gli'
|
5
5
|
require 'json'
|
6
6
|
require 'base64'
|
7
7
|
require 'tmpdir'
|
8
|
-
require 'rbconfig'
|
9
8
|
|
10
9
|
require 'conjur/debify/utils'
|
11
10
|
|
@@ -14,53 +13,56 @@ require 'active_support/core_ext'
|
|
14
13
|
|
15
14
|
include GLI::App
|
16
15
|
|
17
|
-
DEFAULT_FILE_TYPE =
|
16
|
+
DEFAULT_FILE_TYPE = "deb"
|
18
17
|
|
19
18
|
config_file '.debifyrc'
|
20
19
|
|
21
20
|
desc 'Set an environment variable (e.g. TERM=xterm) when starting a container'
|
22
|
-
flag [:env], multiple
|
21
|
+
flag [:env], :multiple => true
|
23
22
|
|
24
23
|
desc 'Mount local bundle to reuse gems from previous installation'
|
25
24
|
default_value true
|
26
25
|
switch [:'local-bundle']
|
27
26
|
|
27
|
+
|
28
28
|
Docker.options[:read_timeout] = 300
|
29
29
|
|
30
30
|
# This is used to turn on DEBUG notices.
|
31
31
|
module DebugMixin
|
32
32
|
DEBUG = ENV['DEBUG'].nil? ? true : ENV['DEBUG'].downcase == 'true'
|
33
33
|
|
34
|
-
def debug
|
35
|
-
DebugMixin.debug
|
34
|
+
def debug *a
|
35
|
+
DebugMixin.debug *a
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.debug
|
39
|
-
|
38
|
+
def self.debug *a
|
39
|
+
$stderr.puts *a if DEBUG
|
40
40
|
end
|
41
41
|
|
42
|
-
def debug_write
|
43
|
-
DebugMixin.debug_write
|
42
|
+
def debug_write *a
|
43
|
+
DebugMixin.debug_write *a
|
44
44
|
end
|
45
45
|
|
46
|
-
def self.debug_write
|
47
|
-
$stderr.write
|
46
|
+
def self.debug_write *a
|
47
|
+
$stderr.write *a if DEBUG
|
48
48
|
end
|
49
49
|
|
50
50
|
# you can give this to various docker methods to print output if debug is on
|
51
|
-
def self.docker_debug
|
51
|
+
def self.docker_debug *a
|
52
52
|
if a.length == 2 && a[0].is_a?(Symbol)
|
53
53
|
debug a.last
|
54
54
|
else
|
55
55
|
a.each do |line|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
begin
|
57
|
+
line = JSON.parse(line)
|
58
|
+
line.keys.each do |k|
|
59
|
+
debug line[k]
|
60
|
+
end
|
61
|
+
rescue JSON::ParserError
|
62
|
+
# Docker For Mac is spitting out invalid JSON, so just print
|
63
|
+
# out the line if parsing fails.
|
64
|
+
debug line
|
59
65
|
end
|
60
|
-
rescue JSON::ParserError
|
61
|
-
# Docker For Mac is spitting out invalid JSON, so just print
|
62
|
-
# out the line if parsing fails.
|
63
|
-
debug line
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
@@ -76,38 +78,20 @@ subcommand_option_handling :normal
|
|
76
78
|
arguments :strict
|
77
79
|
|
78
80
|
def detect_version
|
79
|
-
if File.exist?(
|
80
|
-
base_version = File.read(
|
81
|
+
if File.exist?("VERSION") && !(base_commit = `git log --pretty='%h' VERSION | head -n 1`.strip).empty?
|
82
|
+
base_version = File.read("VERSION").strip
|
81
83
|
commits_since = `git log #{base_commit}..HEAD --pretty='%h'`.split("\n").size
|
82
84
|
hash = `git rev-parse --short HEAD`.strip
|
83
|
-
[[base_version, commits_since].join('.'), hash].join(
|
85
|
+
[[base_version, commits_since].join('.'), hash].join("-")
|
84
86
|
else
|
85
87
|
`git describe --long --tags --abbrev=7 --match 'v*.*.*' | sed -e 's/^v//'`.strip.tap do |version|
|
86
|
-
raise
|
88
|
+
raise "No Git version (tag) for project" if version.empty?
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
91
|
-
def detect_architecture
|
92
|
-
architecture = RbConfig::CONFIG['arch']
|
93
|
-
result_map = {}
|
94
|
-
|
95
|
-
case architecture
|
96
|
-
when /x86_64|amd64/
|
97
|
-
result_map['deb'] = 'amd64'
|
98
|
-
result_map['rpm'] = 'x86_64'
|
99
|
-
when /arm64|aarch64/
|
100
|
-
result_map['deb'] = 'arm64'
|
101
|
-
result_map['rpm'] = 'aarch64'
|
102
|
-
else
|
103
|
-
raise "Unsupported architecture type: #{architecture}"
|
104
|
-
end
|
105
|
-
|
106
|
-
result_map
|
107
|
-
end
|
108
|
-
|
109
93
|
def git_files
|
110
|
-
files = (`git ls-files -z`.split("\x0") +
|
94
|
+
files = (`git ls-files -z`.split("\x0") + ['Gemfile.lock', 'VERSION']).uniq
|
111
95
|
# Since submodule directories are listed, but are not files, we remove them.
|
112
96
|
# Currently, `conjur-project-config` is the only submodule in Conjur, and it
|
113
97
|
# can safely be removed because it's a developer-only tool. If we add another
|
@@ -118,46 +102,46 @@ end
|
|
118
102
|
|
119
103
|
def login_to_registry(appliance_image_id)
|
120
104
|
config_file = File.expand_path('~/.docker/config.json')
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
105
|
+
if File.exist? config_file
|
106
|
+
json_config = JSON.parse(File.read(config_file))
|
107
|
+
registry = appliance_image_id.split('/')[0]
|
108
|
+
|
109
|
+
json_auth = json_config['auths'][registry]['auth']
|
110
|
+
if json_auth
|
111
|
+
username, password = Base64.decode64(json_auth).split(':')
|
112
|
+
Docker.authenticate! username: username, password: password, serveraddress: registry
|
113
|
+
end
|
114
|
+
end
|
131
115
|
end
|
132
116
|
|
133
|
-
desc
|
134
|
-
long_desc
|
135
|
-
|
117
|
+
desc "Clean current working directory of non-Git-managed files"
|
118
|
+
long_desc <<DESC
|
119
|
+
Reliable builds depend on having a clean working directory.
|
136
120
|
|
137
|
-
|
138
|
-
|
121
|
+
Because debify runs some commands in volume-mounted Docker containers,
|
122
|
+
it is capable of creating root-owned files.
|
139
123
|
|
140
|
-
|
141
|
-
|
142
|
-
|
124
|
+
This command will delete all files in the working directory that are not
|
125
|
+
git-managed. The command is designed to run in Jenkins. Therefore, it will
|
126
|
+
only perform file deletion if:
|
143
127
|
|
144
|
-
|
145
|
-
|
128
|
+
* The current user, as provided by Etc.getlogin, is 'jenkins'
|
129
|
+
* The BUILD_NUMBER environment variable is set
|
146
130
|
|
147
|
-
|
131
|
+
File deletion can be compelled using the "force" option.
|
148
132
|
DESC
|
149
|
-
arg_name
|
150
|
-
command
|
151
|
-
c.desc
|
152
|
-
c.flag [:d,
|
133
|
+
arg_name "project-name -- <fpm-arguments>"
|
134
|
+
command "clean" do |c|
|
135
|
+
c.desc "Set the current working directory"
|
136
|
+
c.flag [:d, "dir"]
|
153
137
|
|
154
138
|
c.desc "Ignore (don't delete) a file or directory"
|
155
|
-
c.flag
|
139
|
+
c.flag [:i, :ignore]
|
156
140
|
|
157
141
|
c.desc "Force file deletion even if if this doesn't look like a Jenkins environment"
|
158
142
|
c.switch [:force]
|
159
143
|
|
160
|
-
c.action do |
|
144
|
+
c.action do |global_options, cmd_options, args|
|
161
145
|
def looks_like_jenkins?
|
162
146
|
require 'etc'
|
163
147
|
Etc.getlogin == 'jenkins' && ENV['BUILD_NUMBER']
|
@@ -165,10 +149,12 @@ command 'clean' do |c|
|
|
165
149
|
|
166
150
|
require 'set'
|
167
151
|
perform_deletion = cmd_options[:force] || looks_like_jenkins?
|
168
|
-
|
169
|
-
|
152
|
+
if !perform_deletion
|
153
|
+
$stderr.puts "No --force, and this doesn't look like Jenkins. I won't actually delete anything"
|
154
|
+
end
|
155
|
+
@ignore_list = Array(cmd_options[:ignore]) + ['.', '..', '.git']
|
170
156
|
|
171
|
-
def ignore_file?
|
157
|
+
def ignore_file? f
|
172
158
|
@ignore_list.find { |ignore| f.index(ignore) == 0 }
|
173
159
|
end
|
174
160
|
|
@@ -182,16 +168,16 @@ command 'clean' do |c|
|
|
182
168
|
end
|
183
169
|
find_files.compact!
|
184
170
|
delete_files = (find_files - git_files)
|
185
|
-
delete_files.delete_if
|
171
|
+
delete_files.delete_if { |file|
|
186
172
|
File.directory?(file) || ignore_file?(file)
|
187
|
-
|
173
|
+
}
|
188
174
|
if perform_deletion
|
189
|
-
image = Docker::Image.create 'fromImage' =>
|
175
|
+
image = Docker::Image.create 'fromImage' => "alpine:3.3"
|
190
176
|
options = {
|
191
|
-
'Cmd' => [
|
177
|
+
'Cmd' => ["sh", "-c", "while true; do sleep 1; done"],
|
192
178
|
'Image' => image.id,
|
193
179
|
'Binds' => [
|
194
|
-
[dir,
|
180
|
+
[dir, "/src"].join(':'),
|
195
181
|
]
|
196
182
|
}
|
197
183
|
options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
|
@@ -202,10 +188,10 @@ command 'clean' do |c|
|
|
202
188
|
puts file
|
203
189
|
|
204
190
|
file = "/src/#{file}"
|
205
|
-
cmd = [
|
191
|
+
cmd = ["rm", "-f", file]
|
206
192
|
|
207
|
-
|
208
|
-
|
193
|
+
stdout, stderr, status = container.exec cmd, &DebugMixin::DOCKER
|
194
|
+
$stderr.puts "Failed to delete #{file}" unless status == 0
|
209
195
|
end
|
210
196
|
ensure
|
211
197
|
container.delete force: true
|
@@ -230,77 +216,80 @@ def copy_packages_from_container(container, package_name, dev_package_name)
|
|
230
216
|
end
|
231
217
|
end
|
232
218
|
|
233
|
-
desc
|
234
|
-
long_desc
|
235
|
-
|
219
|
+
desc "Build a debian package for a project"
|
220
|
+
long_desc <<DESC
|
221
|
+
The package is built using fpm (https://github.com/jordansissel/fpm).
|
236
222
|
|
237
|
-
|
223
|
+
The project directory is required to contain:
|
238
224
|
|
239
|
-
|
240
|
-
|
225
|
+
* A Gemfile and Gemfile.lock
|
226
|
+
* A shell script called debify.sh
|
241
227
|
|
242
|
-
|
243
|
-
|
244
|
-
|
228
|
+
debify.sh is invoked by the package build process to create any custom
|
229
|
+
files, other than the project source tree. For example, config files can be
|
230
|
+
created in /opt/conjur/etc.
|
245
231
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
232
|
+
The distrib folder in the project source tree is intended to create scripts
|
233
|
+
for package pre-install, post-install etc. The distrib folder is not included
|
234
|
+
in the deb package, so its contents should be copied to the file system or
|
235
|
+
packaged using fpm arguments.
|
250
236
|
|
251
|
-
|
252
|
-
|
237
|
+
All arguments to this command which follow the double-dash are propagated to
|
238
|
+
the fpm command.
|
253
239
|
DESC
|
254
|
-
arg_name
|
255
|
-
command
|
256
|
-
c.desc
|
257
|
-
c.flag [:d,
|
240
|
+
arg_name "project-name -- <fpm-arguments>"
|
241
|
+
command "package" do |c|
|
242
|
+
c.desc "Set the current working directory"
|
243
|
+
c.flag [:d, "dir"]
|
258
244
|
|
259
|
-
c.desc
|
260
|
-
c.flag
|
245
|
+
c.desc "Set the output file type of the fpm command (e.g rpm)"
|
246
|
+
c.flag [:o, :output]
|
261
247
|
|
262
248
|
c.desc "Specify the deb version; by default, it's read from the VERSION file"
|
263
|
-
c.flag
|
249
|
+
c.flag [:v, :version]
|
264
250
|
|
265
|
-
c.desc
|
251
|
+
c.desc "Specify a custom Dockerfile.fpm"
|
266
252
|
c.flag [:dockerfile]
|
267
253
|
|
268
|
-
c.desc
|
254
|
+
c.desc "Specify files to add to the FPM image that are not included from the git repo"
|
269
255
|
c.flag [:'additional-files']
|
270
256
|
|
271
|
-
c.desc
|
272
|
-
c.default_value
|
273
|
-
c.flag
|
257
|
+
c.desc "Image name"
|
258
|
+
c.default_value "cyberark/phusion-ruby-fips"
|
259
|
+
c.flag [:i, :image]
|
274
260
|
|
275
|
-
c.desc
|
276
|
-
c.default_value
|
277
|
-
c.flag
|
261
|
+
c.desc "Image tag, e.g. 4.5-stable, 4.6-stable"
|
262
|
+
c.default_value "latest"
|
263
|
+
c.flag [:t, :'image-tag']
|
278
264
|
|
279
|
-
c.action do |
|
280
|
-
raise
|
265
|
+
c.action do |global_options, cmd_options, args|
|
266
|
+
raise "project-name is required" unless project_name = args.shift
|
281
267
|
|
282
268
|
fpm_args = []
|
283
|
-
|
284
|
-
|
285
|
-
|
269
|
+
if (delimeter = args.shift) == '--'
|
270
|
+
fpm_args = args.dup
|
271
|
+
else
|
272
|
+
raise "Unexpected argument '#{delimeter}'"
|
273
|
+
end
|
286
274
|
|
287
275
|
dir = cmd_options[:dir] || '.'
|
288
276
|
pwd = File.dirname(__FILE__)
|
289
277
|
|
290
278
|
additional_files = []
|
291
|
-
|
279
|
+
if cmd_options[:'additional-files']
|
280
|
+
additional_files = cmd_options[:'additional-files'].split(',').map(&:strip)
|
281
|
+
end
|
292
282
|
|
293
283
|
dockerfile = File.read(File.expand_path('fpm/Dockerfile.template', File.dirname(__FILE__)))
|
294
|
-
replace_image = dockerfile.gsub(
|
295
|
-
File.open(File.expand_path('fpm/Dockerfile', File.dirname(__FILE__)),
|
284
|
+
replace_image = dockerfile.gsub("@@image@@", cmd_options[:'image'] + ":" + cmd_options[:'image-tag'])
|
285
|
+
File.open(File.expand_path('fpm/Dockerfile', File.dirname(__FILE__)), "w") { |file| file.puts replace_image }
|
296
286
|
|
297
287
|
begin
|
298
288
|
tries ||= 2
|
299
|
-
fpm_image = Docker::Image.build_from_dir File.expand_path('fpm', File.dirname(__FILE__)),
|
300
|
-
|
301
|
-
rescue StandardError
|
289
|
+
fpm_image = Docker::Image.build_from_dir File.expand_path('fpm', File.dirname(__FILE__)), architecture: "x86_64", tag: "debify-fpm", &DebugMixin::DOCKER
|
290
|
+
rescue
|
302
291
|
image_id = File.readlines(File.expand_path('fpm/Dockerfile', File.dirname(__FILE__)))
|
303
|
-
.find { |line| line =~ /^FROM/ }
|
292
|
+
.find { | line | line =~ /^FROM/ }
|
304
293
|
.split(' ')
|
305
294
|
.last
|
306
295
|
login_to_registry image_id
|
@@ -325,13 +314,13 @@ command 'package' do |c|
|
|
325
314
|
end
|
326
315
|
|
327
316
|
# rename specified dockerfile to 'Dockerfile' during copy, incase name is different
|
328
|
-
dockerfile_path = cmd_options[:dockerfile] || File.expand_path(
|
329
|
-
temp_dockerfile = File.join(temp_dir,
|
317
|
+
dockerfile_path = cmd_options[:dockerfile] || File.expand_path("debify/Dockerfile.fpm", pwd)
|
318
|
+
temp_dockerfile = File.join(temp_dir, "Dockerfile")
|
330
319
|
|
331
320
|
# change image variable in specified Dockerfile
|
332
321
|
dockerfile = File.read(dockerfile_path)
|
333
|
-
replace_image = dockerfile.gsub(
|
334
|
-
File.open(temp_dockerfile,
|
322
|
+
replace_image = dockerfile.gsub("@@image@@", fpm_image.id)
|
323
|
+
File.open(temp_dockerfile, "w") { |file| file.puts replace_image }
|
335
324
|
|
336
325
|
# build image from project being debified dir
|
337
326
|
image = Docker::Image.build_from_dir temp_dir, &DebugMixin::DOCKER
|
@@ -350,22 +339,30 @@ command 'package' do |c|
|
|
350
339
|
}
|
351
340
|
options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
|
352
341
|
|
353
|
-
file_path, dev_file_path = determine_file_path(file_type, detect_architecture, project_name, version)
|
354
|
-
|
355
342
|
container = Docker::Container.create options
|
356
343
|
begin
|
357
344
|
DebugMixin.debug_write "Packaging #{project_name} in container #{container.id}\n"
|
358
|
-
container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true)
|
359
|
-
warn "#{chunk}"
|
360
|
-
end
|
345
|
+
container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true) { |stream, chunk| $stderr.puts "#{chunk}" }
|
361
346
|
status = container.wait
|
362
347
|
raise "Failed to package #{project_name}" unless status['StatusCode'] == 0
|
363
348
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
349
|
+
if file_type == "deb"
|
350
|
+
# Copy deb packages
|
351
|
+
copy_packages_from_container(
|
352
|
+
container,
|
353
|
+
"conjur-#{project_name}_#{version}_amd64.deb",
|
354
|
+
"conjur-#{project_name}-dev_#{version}_amd64.deb"
|
355
|
+
)
|
356
|
+
elsif file_type == "rpm"
|
357
|
+
# Copy rpm packages
|
358
|
+
# The rpm builder replaces dashes with underscores in the version
|
359
|
+
rpm_version = version.tr('-', '_')
|
360
|
+
copy_packages_from_container(
|
361
|
+
container,
|
362
|
+
"conjur-#{project_name}-#{rpm_version}-1.x86_64.rpm",
|
363
|
+
"conjur-#{project_name}-dev-#{rpm_version}-1.x86_64.rpm"
|
364
|
+
)
|
365
|
+
end
|
369
366
|
ensure
|
370
367
|
container.delete(force: true)
|
371
368
|
end
|
@@ -373,50 +370,30 @@ command 'package' do |c|
|
|
373
370
|
end
|
374
371
|
end
|
375
372
|
|
376
|
-
def
|
377
|
-
|
378
|
-
architecture = architecture_map[file_type]
|
379
|
-
file_path = "conjur-#{project_name}_#{version}_#{architecture}.#{file_type}"
|
380
|
-
dev_file_path = "conjur-#{project_name}-dev_#{version}_#{architecture}.#{file_type}"
|
381
|
-
elsif file_type == 'rpm'
|
382
|
-
architecture = architecture_map[file_type]
|
383
|
-
|
384
|
-
# The rpm builder replaces dashes with underscores in the version
|
385
|
-
version = version.tr('-', '_')
|
386
|
-
|
387
|
-
file_path = "conjur-#{project_name}-#{version}-1.#{architecture}.#{file_type}"
|
388
|
-
dev_file_path = "conjur-#{project_name}-dev-#{version}-1.#{architecture}.#{file_type}"
|
389
|
-
else
|
390
|
-
raise "Unrecognized file type: #{file_type}, must be one of the following: deb, rpm"
|
391
|
-
end
|
392
|
-
|
393
|
-
[file_path, dev_file_path]
|
394
|
-
end
|
395
|
-
|
396
|
-
def container_command(container, *args)
|
397
|
-
stdout, _, exitcode = container.exec args, &DebugMixin::DOCKER
|
373
|
+
def container_command container, *args
|
374
|
+
stdout, stderr, exitcode = container.exec args, &DebugMixin::DOCKER
|
398
375
|
exit_now! "Command failed : #{args.join(' ')}", exitcode unless exitcode == 0
|
399
376
|
stdout
|
400
377
|
end
|
401
378
|
|
402
|
-
def wait_for_conjur
|
379
|
+
def wait_for_conjur appliance_image, container
|
403
380
|
container_command container, '/opt/conjur/evoke/bin/wait_for_conjur'
|
404
|
-
rescue
|
405
|
-
|
381
|
+
rescue
|
382
|
+
$stderr.puts container.logs(stdout: true, stderr: true)
|
406
383
|
raise
|
407
384
|
end
|
408
385
|
|
409
386
|
def network_options(cmd)
|
410
|
-
cmd.desc
|
411
|
-
cmd.flag
|
387
|
+
cmd.desc "Specify link for test container"
|
388
|
+
cmd.flag [:l, :link], :multiple => true
|
412
389
|
|
413
390
|
cmd.desc 'Attach to the specified network'
|
414
|
-
cmd.flag
|
391
|
+
cmd.flag [:n, :net]
|
415
392
|
end
|
416
393
|
|
417
394
|
def short_id(id)
|
418
395
|
if id =~ /\A[0-9a-f]{64}\z/ # 64 hex digits, docker only allows lower case letters in ids
|
419
|
-
|
396
|
+
$stderr.puts "Warning: found full container id, using short id instead (#{id[0..11]} for #{id})"
|
420
397
|
id[0..11]
|
421
398
|
else
|
422
399
|
id
|
@@ -453,59 +430,59 @@ def add_network_config(container_config, cmd_options)
|
|
453
430
|
end
|
454
431
|
end
|
455
432
|
|
456
|
-
desc
|
457
|
-
long_desc
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
433
|
+
desc "Test a Conjur debian package in a Conjur appliance container"
|
434
|
+
long_desc <<DESC
|
435
|
+
First, a Conjur appliance container is created and started. By default, the
|
436
|
+
container image is registry.tld/conjur-appliance-cuke-master. An image tag
|
437
|
+
MUST be supplied. This image is configured with all the CONJUR_ environment
|
438
|
+
variables setup for the local environment (appliance URL, cert path, admin username and
|
439
|
+
password, etc). The project source tree is also mounted into the container, at
|
440
|
+
/src/<project-name>.
|
464
441
|
|
465
|
-
|
466
|
-
|
442
|
+
This command then waits for Conjur to initialize and be healthy. It proceeds by
|
443
|
+
installing the conjur-<project-name>_<version>_amd64.deb from the project working directory.
|
467
444
|
|
468
|
-
|
469
|
-
|
470
|
-
|
445
|
+
Then the evoke "test-install" command is used to install the test code in the
|
446
|
+
/src/<project-name>. Basically, the development bundle is installed and the database
|
447
|
+
configuration (if any) is setup.
|
471
448
|
|
472
|
-
|
473
|
-
|
449
|
+
Finally, a test script from the project source tree is run, again with the container
|
450
|
+
id as the program argument.
|
474
451
|
|
475
|
-
|
452
|
+
Then the Conjur container is deleted (use --keep to leave it running).
|
476
453
|
DESC
|
477
|
-
arg_name
|
478
|
-
command
|
479
|
-
c.desc
|
480
|
-
c.flag
|
454
|
+
arg_name "project-name test-script"
|
455
|
+
command "test" do |c|
|
456
|
+
c.desc "Set the current working directory"
|
457
|
+
c.flag [:d, :dir]
|
481
458
|
|
482
|
-
c.desc
|
459
|
+
c.desc "Keep the Conjur appliance container after the command finishes"
|
483
460
|
c.default_value false
|
484
|
-
c.switch
|
461
|
+
c.switch [:k, :keep]
|
485
462
|
|
486
|
-
c.desc
|
487
|
-
c.default_value
|
488
|
-
c.flag
|
463
|
+
c.desc "Image name"
|
464
|
+
c.default_value "registry.tld/conjur-appliance-cuke-master"
|
465
|
+
c.flag [:i, :image]
|
489
466
|
|
490
|
-
c.desc
|
491
|
-
c.flag [:t,
|
467
|
+
c.desc "Image tag, e.g. 4.5-stable, 4.6-stable"
|
468
|
+
c.flag [:t, "image-tag"]
|
492
469
|
|
493
470
|
c.desc "'docker pull' the Conjur container image"
|
494
471
|
c.default_value true
|
495
472
|
c.switch [:pull]
|
496
473
|
|
497
474
|
c.desc "Specify the deb version; by default, it's read from the VERSION file"
|
498
|
-
c.flag
|
475
|
+
c.flag [:v, :version]
|
499
476
|
|
500
|
-
c.desc
|
501
|
-
c.flag [:'volumes-from'], multiple
|
477
|
+
c.desc "Specify volume for test container"
|
478
|
+
c.flag [:'volumes-from'], :multiple => true
|
502
479
|
|
503
480
|
network_options(c)
|
504
481
|
|
505
482
|
c.action do |global_options, cmd_options, args|
|
506
|
-
raise
|
507
|
-
raise
|
508
|
-
raise
|
483
|
+
raise "project-name is required" unless project_name = args.shift
|
484
|
+
raise "test-script is required" unless test_script = args.shift
|
485
|
+
raise "Received extra command-line arguments" if args.shift
|
509
486
|
|
510
487
|
dir = cmd_options[:dir] || '.'
|
511
488
|
dir = File.expand_path(dir)
|
@@ -514,8 +491,8 @@ command 'test' do |c|
|
|
514
491
|
raise "Directory #{dir} does not contain a .deb file" unless Dir["#{dir}/*.deb"].length >= 1
|
515
492
|
|
516
493
|
Dir.chdir dir do
|
517
|
-
image_tag = cmd_options[
|
518
|
-
appliance_image_id = [cmd_options[:image], image_tag].join(
|
494
|
+
image_tag = cmd_options["image-tag"] or raise "image-tag is required"
|
495
|
+
appliance_image_id = [cmd_options[:image], image_tag].join(":")
|
519
496
|
version = cmd_options[:version] || detect_version
|
520
497
|
package_name = "conjur-#{project_name}_#{version}_amd64.deb"
|
521
498
|
dev_package_name = "conjur-#{project_name}-dev_#{version}_amd64.deb"
|
@@ -525,23 +502,24 @@ command 'test' do |c|
|
|
525
502
|
begin
|
526
503
|
tries ||= 2
|
527
504
|
Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
|
528
|
-
rescue
|
505
|
+
rescue
|
529
506
|
login_to_registry appliance_image_id
|
530
507
|
retry unless (tries -= 1).zero?
|
531
508
|
end
|
532
509
|
|
510
|
+
|
533
511
|
def build_test_image(appliance_image_id, project_name, packages)
|
534
|
-
packages = packages.join
|
535
|
-
dockerfile =
|
536
|
-
|
512
|
+
packages = packages.join " "
|
513
|
+
dockerfile = <<-DOCKERFILE
|
514
|
+
FROM #{appliance_image_id}
|
537
515
|
|
538
|
-
|
516
|
+
COPY #{packages} /tmp/
|
539
517
|
|
540
|
-
|
541
|
-
|
542
|
-
|
518
|
+
RUN if dpkg --list | grep conjur-#{project_name}; then dpkg --force all --purge conjur-#{project_name}; fi
|
519
|
+
RUN if [ -f /opt/conjur/etc/#{project_name}.conf ]; then rm /opt/conjur/etc/#{project_name}.conf; fi
|
520
|
+
RUN cd /tmp; dpkg --install #{packages}
|
543
521
|
|
544
|
-
|
522
|
+
RUN touch /etc/service/conjur/down
|
545
523
|
DOCKERFILE
|
546
524
|
Dir.mktmpdir do |tmpdir|
|
547
525
|
tmpfile = Tempfile.new('Dockerfile', tmpdir)
|
@@ -550,7 +528,7 @@ command 'test' do |c|
|
|
550
528
|
tar_cmd = "tar -cvzh -C #{tmpdir} #{dockerfile_name} -C #{Dir.pwd} #{packages}"
|
551
529
|
tar = open("| #{tar_cmd}")
|
552
530
|
begin
|
553
|
-
Docker::Image.build_from_tar(tar, dockerfile
|
531
|
+
Docker::Image.build_from_tar(tar, :dockerfile => dockerfile_name, &DebugMixin::DOCKER)
|
554
532
|
ensure
|
555
533
|
tar.close
|
556
534
|
end
|
@@ -563,7 +541,7 @@ command 'test' do |c|
|
|
563
541
|
begin
|
564
542
|
tries ||= 2
|
565
543
|
appliance_image = build_test_image(appliance_image_id, project_name, packages)
|
566
|
-
rescue
|
544
|
+
rescue
|
567
545
|
login_to_registry appliance_image_id
|
568
546
|
retry unless (tries -= 1).zero?
|
569
547
|
end
|
@@ -575,11 +553,11 @@ command 'test' do |c|
|
|
575
553
|
options = {
|
576
554
|
'Image' => appliance_image.id,
|
577
555
|
'name' => project_name,
|
578
|
-
'Env' =>
|
579
|
-
CONJUR_AUTHN_LOGIN=admin
|
580
|
-
CONJUR_ENV=appliance
|
581
|
-
CONJUR_AUTHN_API_KEY=SEcret12!!!!
|
582
|
-
CONJUR_ADMIN_PASSWORD=SEcret12!!!!
|
556
|
+
'Env' => [
|
557
|
+
"CONJUR_AUTHN_LOGIN=admin",
|
558
|
+
"CONJUR_ENV=appliance",
|
559
|
+
"CONJUR_AUTHN_API_KEY=SEcret12!!!!",
|
560
|
+
"CONJUR_ADMIN_PASSWORD=SEcret12!!!!",
|
583
561
|
] + global_options[:env],
|
584
562
|
'HostConfig' => {
|
585
563
|
'Binds' => [
|
@@ -590,10 +568,7 @@ command 'test' do |c|
|
|
590
568
|
host_config = options['HostConfig']
|
591
569
|
|
592
570
|
host_config['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
|
593
|
-
if cmd_options[:'volumes-from'] && !cmd_options[:'volumes-from'].empty?
|
594
|
-
host_config['VolumesFrom'] =
|
595
|
-
cmd_options[:'volumes-from']
|
596
|
-
end
|
571
|
+
host_config['VolumesFrom'] = cmd_options[:'volumes-from'] if cmd_options[:'volumes-from'] && !cmd_options[:'volumes-from'].empty?
|
597
572
|
|
598
573
|
add_network_config(options, cmd_options)
|
599
574
|
|
@@ -603,24 +578,21 @@ command 'test' do |c|
|
|
603
578
|
.push([dot_bundle_dir, "/src/#{project_name}/.bundle"].join(':'))
|
604
579
|
end
|
605
580
|
|
606
|
-
container = Docker::Container.create(options.tap
|
607
|
-
DebugMixin.debug_write "creating container with options #{o.inspect}"
|
608
|
-
end)
|
581
|
+
container = Docker::Container.create(options.tap { |o| DebugMixin.debug_write "creating container with options #{o.inspect}" })
|
609
582
|
|
610
583
|
begin
|
611
584
|
DebugMixin.debug_write "Testing #{project_name} in container #{container.id}\n"
|
612
585
|
|
613
|
-
spawn("docker logs -f #{container.id}",
|
586
|
+
spawn("docker logs -f #{container.id}", [:out, :err] => $stderr).tap do |pid|
|
614
587
|
Process.detach pid
|
615
588
|
end
|
616
589
|
container.start!
|
617
590
|
|
618
591
|
# Wait for pg/main so that migrations can run
|
619
592
|
30.times do
|
620
|
-
stdout,
|
593
|
+
stdout, stderr, exitcode = container.exec %w(sv status pg/main), &DebugMixin::DOCKER
|
621
594
|
status = stdout.join
|
622
|
-
break if exitcode == 0 && status =~ /^run
|
623
|
-
|
595
|
+
break if exitcode == 0 && status =~ /^run\:/
|
624
596
|
sleep 1
|
625
597
|
end
|
626
598
|
|
@@ -633,15 +605,15 @@ command 'test' do |c|
|
|
633
605
|
|
634
606
|
DebugMixin.debug_write "Starting conjur\n"
|
635
607
|
|
636
|
-
container_command container,
|
637
|
-
container_command container,
|
638
|
-
wait_for_conjur container
|
608
|
+
container_command container, "rm", "/etc/service/conjur/down"
|
609
|
+
container_command container, "sv", "start", "conjur"
|
610
|
+
wait_for_conjur appliance_image, container
|
639
611
|
|
640
612
|
system "./#{test_script} #{container.id}"
|
641
613
|
exit_now! "#{test_script} failed with exit code #{$?.exitstatus}", $?.exitstatus unless $?.exitstatus == 0
|
642
614
|
ensure
|
643
615
|
unless cmd_options[:keep] || ENV['KEEP_CONTAINERS']
|
644
|
-
DebugMixin.debug_write
|
616
|
+
DebugMixin.debug_write "deleting container"
|
645
617
|
container.delete(force: true)
|
646
618
|
end
|
647
619
|
end
|
@@ -649,30 +621,30 @@ command 'test' do |c|
|
|
649
621
|
end
|
650
622
|
end
|
651
623
|
|
652
|
-
desc
|
653
|
-
long_desc
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
624
|
+
desc "Setup a development sandbox for a Conjur debian package in a Conjur appliance container"
|
625
|
+
long_desc <<DESC
|
626
|
+
First, a Conjur appliance container is created and started. By default, the
|
627
|
+
container image is registry.tld/conjur-appliance-cuke-master. An image tag
|
628
|
+
MUST be supplied. This image is configured with all the CONJUR_ environment
|
629
|
+
variables setup for the local environment (appliance URL, cert path, admin username and
|
630
|
+
password, etc). The project source tree is also mounted into the container, at
|
631
|
+
/src/<project-name>, where <project-name> is taken from the name of the current working directory.
|
660
632
|
|
661
|
-
|
633
|
+
Once in the container, use "/opt/conjur/evoke/bin/dev-install" to install the development bundle of your project.
|
662
634
|
DESC
|
663
|
-
command
|
664
|
-
c.desc
|
665
|
-
c.flag
|
635
|
+
command "sandbox" do |c|
|
636
|
+
c.desc "Set the current working directory"
|
637
|
+
c.flag [:d, :dir]
|
666
638
|
|
667
|
-
c.desc
|
668
|
-
c.default_value
|
669
|
-
c.flag
|
639
|
+
c.desc "Image name"
|
640
|
+
c.default_value "registry.tld/conjur-appliance-cuke-master"
|
641
|
+
c.flag [:i, :image]
|
670
642
|
|
671
|
-
c.desc
|
672
|
-
c.flag [:t,
|
643
|
+
c.desc "Image tag, e.g. 4.5-stable, 4.6-stable"
|
644
|
+
c.flag [:t, "image-tag"]
|
673
645
|
|
674
|
-
c.desc
|
675
|
-
c.flag [:bind], multiple
|
646
|
+
c.desc "Bind another source directory into the container. Use <src>:<dest>, where both are full paths."
|
647
|
+
c.flag [:"bind"], :multiple => true
|
676
648
|
|
677
649
|
c.desc "'docker pull' the Conjur container image"
|
678
650
|
c.default_value false
|
@@ -680,11 +652,11 @@ command 'sandbox' do |c|
|
|
680
652
|
|
681
653
|
network_options(c)
|
682
654
|
|
683
|
-
c.desc
|
684
|
-
c.flag [:'volumes-from'], multiple
|
655
|
+
c.desc "Specify volume for container"
|
656
|
+
c.flag [:'volumes-from'], :multiple => true
|
685
657
|
|
686
|
-
c.desc
|
687
|
-
c.flag
|
658
|
+
c.desc "Expose a port from the container to host. Use <host>:<container>."
|
659
|
+
c.flag [:p, :port], :multiple => true
|
688
660
|
|
689
661
|
c.desc 'Run dev-install in /src/<project-name>'
|
690
662
|
c.default_value false
|
@@ -695,10 +667,10 @@ command 'sandbox' do |c|
|
|
695
667
|
c.switch [:kill]
|
696
668
|
|
697
669
|
c.desc 'A command to run in the sandbox'
|
698
|
-
c.flag
|
670
|
+
c.flag [:c, :command]
|
699
671
|
|
700
672
|
c.action do |global_options, cmd_options, args|
|
701
|
-
raise
|
673
|
+
raise "Received extra command-line arguments" if args.shift
|
702
674
|
|
703
675
|
dir = cmd_options[:dir] || '.'
|
704
676
|
dir = File.expand_path(dir)
|
@@ -706,23 +678,20 @@ command 'sandbox' do |c|
|
|
706
678
|
raise "Directory #{dir} does not exist or is not a directory" unless File.directory?(dir)
|
707
679
|
|
708
680
|
Dir.chdir dir do
|
709
|
-
image_tag = cmd_options[
|
710
|
-
appliance_image_id = [cmd_options[:image], image_tag].join(
|
681
|
+
image_tag = cmd_options["image-tag"] or raise "image-tag is required"
|
682
|
+
appliance_image_id = [cmd_options[:image], image_tag].join(":")
|
711
683
|
|
712
684
|
appliance_image = if cmd_options[:pull]
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
else
|
724
|
-
Docker::Image.get appliance_image_id
|
725
|
-
end
|
685
|
+
begin
|
686
|
+
tries ||= 2
|
687
|
+
Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
|
688
|
+
rescue
|
689
|
+
login_to_registry appliance_image_id
|
690
|
+
retry unless (tries -= 1).zero?
|
691
|
+
end
|
692
|
+
else
|
693
|
+
Docker::Image.get appliance_image_id
|
694
|
+
end
|
726
695
|
|
727
696
|
project_name = File.basename(Dir.getwd)
|
728
697
|
vendor_dir = File.expand_path("tmp/debify/#{project_name}/vendor", ENV['HOME'])
|
@@ -734,18 +703,18 @@ command 'sandbox' do |c|
|
|
734
703
|
'name' => "#{project_name}-sandbox",
|
735
704
|
'Image' => appliance_image.id,
|
736
705
|
'WorkingDir' => "/src/#{project_name}",
|
737
|
-
'Env' =>
|
738
|
-
CONJUR_AUTHN_LOGIN=admin
|
739
|
-
CONJUR_ENV=appliance
|
740
|
-
CONJUR_AUTHN_API_KEY=SEcret12!!!!
|
741
|
-
CONJUR_ADMIN_PASSWORD=SEcret12!!!!
|
706
|
+
'Env' => [
|
707
|
+
"CONJUR_AUTHN_LOGIN=admin",
|
708
|
+
"CONJUR_ENV=appliance",
|
709
|
+
"CONJUR_AUTHN_API_KEY=SEcret12!!!!",
|
710
|
+
"CONJUR_ADMIN_PASSWORD=SEcret12!!!!",
|
742
711
|
] + global_options[:env]
|
743
712
|
}
|
744
713
|
|
745
714
|
options['HostConfig'] = host_config = {}
|
746
715
|
host_config['Binds'] = [
|
747
|
-
[File.expand_path(
|
748
|
-
[dir, "/src/#{project_name}"].join(':')
|
716
|
+
[File.expand_path(".ssh/id_rsa", ENV['HOME']), "/root/.ssh/id_rsa", 'ro'].join(':'),
|
717
|
+
[dir, "/src/#{project_name}"].join(':'),
|
749
718
|
] + Array(cmd_options[:bind])
|
750
719
|
|
751
720
|
if global_options[:'local-bundle']
|
@@ -763,92 +732,88 @@ command 'sandbox' do |c|
|
|
763
732
|
port_bindings = Hash.new({})
|
764
733
|
cmd_options[:port].each do |mapping|
|
765
734
|
hport, cport = mapping.split(':')
|
766
|
-
port_bindings["#{cport}/tcp"] = [{
|
735
|
+
port_bindings["#{cport}/tcp"] = [{'HostPort' => hport}]
|
767
736
|
end
|
768
737
|
host_config['PortBindings'] = port_bindings
|
769
738
|
end
|
770
739
|
|
771
740
|
if cmd_options[:kill]
|
772
|
-
previous =
|
773
|
-
|
774
|
-
rescue StandardError
|
775
|
-
nil
|
776
|
-
end
|
777
|
-
previous.delete(force: true) if previous
|
741
|
+
previous = Docker::Container.get(options['name']) rescue nil
|
742
|
+
previous.delete(:force => true) if previous
|
778
743
|
end
|
779
744
|
|
780
|
-
container = Docker::Container.create(options.tap
|
781
|
-
DebugMixin.debug_write "creating container with options #{o.inspect}"
|
782
|
-
end)
|
745
|
+
container = Docker::Container.create(options.tap { |o| DebugMixin.debug_write "creating container with options #{o.inspect}" })
|
783
746
|
$stdout.puts container.id
|
784
747
|
container.start!
|
785
748
|
|
786
|
-
wait_for_conjur container
|
749
|
+
wait_for_conjur appliance_image, container
|
787
750
|
|
788
751
|
if cmd_options[:'dev-install']
|
789
|
-
container_command(container,
|
752
|
+
container_command(container, "/opt/conjur/evoke/bin/dev-install", project_name)
|
790
753
|
container_command(container, 'sv', 'restart', "conjur/#{project_name}")
|
791
754
|
end
|
792
755
|
|
793
|
-
|
756
|
+
if cmd_options[:command]
|
757
|
+
container_command(container, '/bin/bash', '-c', cmd_options[:command])
|
758
|
+
end
|
794
759
|
end
|
795
760
|
end
|
796
761
|
end
|
797
762
|
|
798
|
-
desc
|
799
|
-
long_desc
|
800
|
-
|
763
|
+
desc "Publish a debian package to apt repository"
|
764
|
+
long_desc <<DESC
|
765
|
+
Publishes a deb created with `debify package` to our private apt repository.
|
801
766
|
|
802
|
-
|
767
|
+
"distribution" should match the major/minor version of the Conjur appliance you want to install to.
|
803
768
|
|
804
|
-
|
805
|
-
|
769
|
+
The package name is a required option. The package version can be specified as a CLI option, or it will
|
770
|
+
be auto-detected from Git.
|
806
771
|
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
772
|
+
--component should be 'stable' if run after package tests pass or 'testing' if the package is not yet ready for release.
|
773
|
+
If you don't specify the component, it will be set to 'testing' unless the current git branch is 'master' or 'origin/master'.
|
774
|
+
The git branch is first detected from the env var GIT_BRANCH or BRANCH_NAME, and then by checking `git rev-parse --abbrev-ref HEAD`
|
775
|
+
(which won't give you the answer you want when detached).
|
811
776
|
|
812
777
|
DESC
|
813
|
-
arg_name
|
814
|
-
command
|
815
|
-
c.desc
|
816
|
-
c.flag
|
778
|
+
arg_name "distribution project-name"
|
779
|
+
command "publish" do |c|
|
780
|
+
c.desc "Set the current working directory"
|
781
|
+
c.flag [:d, :dir]
|
817
782
|
|
818
783
|
c.desc "Specify the deb package version; by default, it's computed automatically"
|
819
|
-
c.flag
|
784
|
+
c.flag [:v, :version]
|
820
785
|
|
821
786
|
c.desc "Component to publish to, either 'stable' or the name of the git branch"
|
822
|
-
c.flag
|
787
|
+
c.flag [:c, :component]
|
823
788
|
|
824
|
-
c.desc
|
825
|
-
c.default_value
|
826
|
-
c.flag
|
789
|
+
c.desc "Artifactory URL to publish to"
|
790
|
+
c.default_value "https://conjurinc.jfrog.io/conjurinc"
|
791
|
+
c.flag [:u, :url]
|
827
792
|
|
828
|
-
c.desc
|
829
|
-
c.default_value
|
830
|
-
c.flag
|
793
|
+
c.desc "Artifactory Debian repo to publish package to"
|
794
|
+
c.default_value "debian-private"
|
795
|
+
c.flag [:r, :repo]
|
831
796
|
|
832
|
-
c.desc
|
833
|
-
c.default_value
|
797
|
+
c.desc "Artifactory RPM repo to publish package to"
|
798
|
+
c.default_value "redhat-private"
|
834
799
|
c.flag ['rpm-repo']
|
835
800
|
|
836
|
-
c.action do |
|
801
|
+
c.action do |global_options, cmd_options, args|
|
837
802
|
require 'conjur/debify/action/publish'
|
838
|
-
raise
|
839
|
-
raise
|
840
|
-
raise
|
803
|
+
raise "distribution is required" unless distribution = args.shift
|
804
|
+
raise "project-name is required" unless project_name = args.shift
|
805
|
+
raise "Received extra command-line arguments" if args.shift
|
841
806
|
|
842
807
|
Conjur::Debify::Action::Publish.new(distribution, project_name, cmd_options).run
|
843
808
|
end
|
844
809
|
end
|
845
810
|
|
846
|
-
desc
|
847
|
-
command
|
848
|
-
c.desc
|
849
|
-
c.flag
|
850
|
-
c.action do |
|
851
|
-
raise
|
811
|
+
desc "Auto-detect and print the repository version"
|
812
|
+
command "detect-version" do |c|
|
813
|
+
c.desc "Set the current working directory"
|
814
|
+
c.flag [:d, :dir]
|
815
|
+
c.action do |global_options, cmd_options, args|
|
816
|
+
raise "Received extra command-line arguments" if args.shift
|
852
817
|
|
853
818
|
dir = cmd_options[:dir] || '.'
|
854
819
|
dir = File.expand_path(dir)
|
@@ -865,11 +830,33 @@ desc 'Show the given configuration'
|
|
865
830
|
arg_name 'configuration'
|
866
831
|
command 'config' do |c|
|
867
832
|
c.action do |_, _, args|
|
868
|
-
raise 'no configuration provided' unless
|
869
|
-
raise
|
833
|
+
raise 'no configuration provided' unless config = args.shift
|
834
|
+
raise "Received extra command-line arguments" if args.shift
|
870
835
|
|
871
836
|
File.open(File.join('distrib', config)).each do |line|
|
872
837
|
puts line.gsub(/@@DEBIFY_VERSION@@/, Conjur::Debify::VERSION)
|
873
838
|
end
|
874
839
|
end
|
875
840
|
end
|
841
|
+
|
842
|
+
|
843
|
+
pre do |global, command, options, args|
|
844
|
+
# Pre logic here
|
845
|
+
# Return true to proceed; false to abort and not call the
|
846
|
+
# chosen command
|
847
|
+
# Use skips_pre before a command to skip this block
|
848
|
+
# on that command only
|
849
|
+
true
|
850
|
+
end
|
851
|
+
|
852
|
+
post do |global, command, options, args|
|
853
|
+
# Post logic here
|
854
|
+
# Use skips_post before a command to skip this
|
855
|
+
# block on that command only
|
856
|
+
end
|
857
|
+
|
858
|
+
on_error do |exception|
|
859
|
+
# Error logic here
|
860
|
+
# return false to skip default error handling
|
861
|
+
true
|
862
|
+
end
|