conjur-debify 0.7.0 → 0.8.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
  SHA1:
3
- metadata.gz: f7a88bd846714166dd0d608553936e84045ce0af
4
- data.tar.gz: 4dc3afd7a054006c55b33ed0de011c17b8d2626b
3
+ metadata.gz: 90432693c649a1eb23de7b962899831314859166
4
+ data.tar.gz: 3a690c6eecbf7dc1c8874321fad63b27775faa3d
5
5
  SHA512:
6
- metadata.gz: 0fb023e1ed3f7edbe8f5428cedee4c2caf8f8a110031ba5d339268f9deb2100e411c9e28df8e59067c23c207acd515b26f5eab738d1c737e625af597f5f16f19
7
- data.tar.gz: 2eff9c0a810e029252d419b9461a76442cf18e623f28d6e58fe6460b031f98d8948b638839728d782330acad62df50707a6edccabf893a7cdade80fcbeab0e88
6
+ metadata.gz: 7bda53b7b5ba6895e6d0e1ab4b65c39006c6cbec431d14e4b82387148457e9107c70da4acb14a8d8e020b3015f1cf0b35fb35f7d1b5b0b2c0870499611f41312
7
+ data.tar.gz: 26176ae31025c4559be428ff3fdf8c4545689379f876a5a8e9d31559119ee980206de3a0412c226f513cbabed6d9dc2b4541a479579ccedb05d5714c74ea3047
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.8.0
2
+
3
+ * Remove the need for a 'latest' debian
4
+ * Fix bug in the error message for 'detect_version'
5
+ * Use a more reliable way to detect the current branch
6
+ * `publish` : Remove the default value of the 'component' flag
7
+ * `clean` : Don't create a container unless deletions will actually be performed
8
+
1
9
  # 0.7.0
2
10
 
3
11
  * Add `debify clean`
@@ -16,6 +16,6 @@ Feature: Packaging
16
16
  @announce-output
17
17
  Scenario: 'example' project can be tested successfully
18
18
  Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1 example -- --post-install /distrib/postinstall.sh`
19
- When I run `env DEBUG=true GLI_DEBUG=true debify test -t 4.6-stable -d ../../example --no-pull example test.sh`
19
+ When I run `env DEBUG=true GLI_DEBUG=true debify test -t 4.6-stable -v 0.0.1 -d ../../example --no-pull example test.sh`
20
20
  Then the exit status should be 0
21
21
  And the stderr should contain "Test succeeded"
data/lib/conjur/debify.rb CHANGED
@@ -54,7 +54,7 @@ arguments :strict
54
54
 
55
55
  def detect_version
56
56
  `git describe --long --tags --abbrev=7 | sed -e 's/^v//'`.strip.tap do |version|
57
- raise "No Git version (tag) for project '#{project_name}'" if version.empty?
57
+ raise "No Git version (tag) for project" if version.empty?
58
58
  end
59
59
  end
60
60
 
@@ -119,32 +119,34 @@ command "clean" do |c|
119
119
  delete_files.delete_if{|file|
120
120
  File.directory?(file) || ignore_file?(file)
121
121
  }
122
- image = Docker::Image.create 'fromImage' => "alpine:3.3"
123
- options = {
124
- 'Cmd' => [ "sh", "-c", "while true; do sleep 1; done" ],
125
- 'Image' => image.id,
126
- 'Binds' => [
127
- [ dir, "/src" ].join(':'),
128
- ]
129
- }
130
- container = Docker::Container.create options
131
- begin
132
- container.start
133
- delete_files.each do |file|
134
- $stderr.puts file
135
-
136
- file = "/src/#{file}"
137
- cmd = if perform_deletion
138
- [ "rm", "-f", file ]
139
- else
140
- [ "echo", file ]
122
+ if perform_deletion
123
+ image = Docker::Image.create 'fromImage' => "alpine:3.3"
124
+ options = {
125
+ 'Cmd' => [ "sh", "-c", "while true; do sleep 1; done" ],
126
+ 'Image' => image.id,
127
+ 'Binds' => [
128
+ [ dir, "/src" ].join(':'),
129
+ ]
130
+ }
131
+ container = Docker::Container.create options
132
+ begin
133
+ container.start
134
+ delete_files.each do |file|
135
+ puts file
136
+
137
+ file = "/src/#{file}"
138
+ cmd = [ "rm", "-f", file ]
139
+
140
+ stdout, stderr, status = container.exec cmd, &DebugMixin::DOCKER
141
+ $stderr.puts "Failed to delete #{file}" unless status == 0
141
142
  end
142
-
143
- stdout, stderr, status = container.exec cmd, &DebugMixin::DOCKER
144
- $stderr.puts "Failed to delete #{file}" unless status == 0
143
+ ensure
144
+ container.delete force: true
145
+ end
146
+ else
147
+ delete_files.each do |file|
148
+ puts file
145
149
  end
146
- ensure
147
- container.delete force: true
148
150
  end
149
151
  end
150
152
  end
@@ -238,7 +240,6 @@ command "package" do |c|
238
240
  tar = Gem::Package::TarReader.new deb
239
241
  tar.first.tap do |entry|
240
242
  open(entry.full_name, 'wb') {|f| f.write(entry.read)}
241
- FileUtils.ln_sf entry.full_name, entry.full_name.gsub(version, "latest")
242
243
  puts entry.full_name
243
244
  end
244
245
  ensure
@@ -258,7 +259,7 @@ password, etc). The project source tree is also mounted into the container, at
258
259
  /src/<project-name>.
259
260
 
260
261
  This command then waits for Conjur to initialize and be healthy. It proceeds by
261
- installing the conjur-<project-name>_latest_amd64.deb from the project working directory.
262
+ installing the conjur-<project-name>_<version>_amd64.deb from the project working directory.
262
263
 
263
264
  Then the evoke "test-install" command is used to install the test code in the
264
265
  /src/<project-name>. Basically, the development bundle is installed and the database
@@ -285,10 +286,13 @@ command "test" do |c|
285
286
  c.desc "Image tag, e.g. 4.5-stable, 4.6-stable"
286
287
  c.flag [ :t, "image-tag"]
287
288
 
288
- c.desc "Pull the image, even if it's in the Docker engine already"
289
+ c.desc "'docker pull' the Conjur container image"
289
290
  c.default_value true
290
291
  c.switch [ :pull ]
291
-
292
+
293
+ c.desc "Specify the deb version; by default, it's computed from the Git tag"
294
+ c.flag [ :v, :version ]
295
+
292
296
  c.action do |global_options,cmd_options,args|
293
297
  raise "project-name is required" unless project_name = args.shift
294
298
  raise "test-script is required" unless test_script = args.shift
@@ -303,24 +307,25 @@ command "test" do |c|
303
307
  Dir.chdir dir do
304
308
  image_tag = cmd_options["image-tag"] or raise "image-tag is required"
305
309
  appliance_image_id = [ cmd_options[:image], image_tag ].join(":")
310
+ version = cmd_options[:version] || detect_version
311
+ package_name = "conjur-#{project_name}_#{version}_amd64.deb"
306
312
 
307
313
  raise "#{test_script} does not exist or is not a file" unless File.file?(test_script)
308
314
 
309
315
  Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
310
316
 
311
- def build_test_image(appliance_image_id, project_name)
312
- deb = "conjur-#{project_name}_latest_amd64.deb"
317
+ def build_test_image(appliance_image_id, project_name, package_name)
313
318
  dockerfile = <<-DOCKERFILE
314
319
  FROM #{appliance_image_id}
315
320
 
316
- COPY #{deb} /tmp/
321
+ COPY #{package_name} /tmp/
317
322
 
318
323
  RUN rm -rf /opt/conjur/#{project_name}
319
324
  RUN rm -f /opt/conjur/etc/#{project_name}.conf
320
325
  RUN rm -f /usr/local/bin/conjur-#{project_name}
321
326
 
322
327
  RUN dpkg --force all --purge conjur-#{project_name} || true
323
- RUN dpkg --install /tmp/#{deb}
328
+ RUN dpkg --install /tmp/#{package_name}
324
329
 
325
330
  RUN touch /etc/service/conjur/down
326
331
  DOCKERFILE
@@ -328,7 +333,7 @@ RUN touch /etc/service/conjur/down
328
333
  tmpfile = Tempfile.new('Dockerfile', tmpdir)
329
334
  File.write(tmpfile, dockerfile)
330
335
  dockerfile_name = File.basename(tmpfile.path)
331
- tar_cmd = "tar -cvzh -C #{tmpdir} #{dockerfile_name} -C #{Dir.pwd} #{deb}"
336
+ tar_cmd = "tar -cvzh -C #{tmpdir} #{dockerfile_name} -C #{Dir.pwd} #{package_name}"
332
337
  tar = open("| #{tar_cmd}")
333
338
  begin
334
339
  Docker::Image.build_from_tar(tar, :dockerfile => dockerfile_name, &DebugMixin::DOCKER)
@@ -338,7 +343,7 @@ RUN touch /etc/service/conjur/down
338
343
  end
339
344
  end
340
345
 
341
- appliance_image = build_test_image(appliance_image_id, project_name)
346
+ appliance_image = build_test_image(appliance_image_id, project_name, package_name)
342
347
 
343
348
  vendor_dir = File.expand_path("tmp/debify/#{project_name}/vendor", ENV['HOME'])
344
349
  dot_bundle_dir = File.expand_path("tmp/debify/#{project_name}/.bundle", ENV['HOME'])
@@ -448,7 +453,6 @@ command "publish" do |c|
448
453
  c.flag [ :v, :version ]
449
454
 
450
455
  c.desc "Maturity stage of the package, 'testing' or 'stable'"
451
- c.default_value "testing"
452
456
  c.flag [ :c, :component ]
453
457
 
454
458
  c.action do |global_options,cmd_options,args|
@@ -457,10 +461,7 @@ command "publish" do |c|
457
461
  raise "Receive extra command-line arguments" if args.shift
458
462
 
459
463
  def detect_component
460
- branch = ENV['GIT_BRANCH']
461
- unless branch
462
- branch = `git describe --all`
463
- end
464
+ branch = ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.strip
464
465
  if %w(master origin/master).include?(branch)
465
466
  'stable'
466
467
  else
@@ -476,7 +477,6 @@ command "publish" do |c|
476
477
  Dir.chdir dir do
477
478
  version = cmd_options[:version] || detect_version
478
479
  component = cmd_options[:component] || detect_component
479
-
480
480
  package_name = "conjur-#{project_name}_#{version}_amd64.deb"
481
481
 
482
482
  publish_image = Docker::Image.build_from_dir File.expand_path('publish', File.dirname(__FILE__)), tag: "debify-publish", &DebugMixin::DOCKER
@@ -1,5 +1,5 @@
1
1
  module Conjur
2
2
  module Debify
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-debify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin