conjur-debify 1.0.0 → 1.1.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: 45c3f31195f67e19a4a873ae02840341359c7cae
4
- data.tar.gz: d9c911de42f4f6d74b8c914ea6b0270847aba71c
3
+ metadata.gz: 6ae28b40382a96cd6b228e7e502dbfd6ce85abdf
4
+ data.tar.gz: a4988e1ee9958bfc0dd3a0c36adff325c53af22b
5
5
  SHA512:
6
- metadata.gz: 68eabdc03f12982d3f617138c65ee2692574a87ec868b28d5cac1d31457803ca27870686f24509b8c1d145c018e77d9154d93aa68dda97443c1a1767ba91fba7
7
- data.tar.gz: 6100c22bdac5930aca377b2191822da5c229965a197f5a4cb6fdee002ab52bb1ec32045bd24b9f99cad3ef755531ac83271fbc4f28057c7323792eeee656023a
6
+ metadata.gz: 03f604f27e8180ee7b3dbc686b23a7e489732ba75439432f3840c26180451c813cabd29ea3dad407d9cc1e25140a79862936e8e0df130ac0bb8b977f78c3ff5e
7
+ data.tar.gz: 8904097e5befe3e5f3e2b463e58578e1d2b7f8db9e643019fea1bd023c5f2b1447db72491fb1ed575cf448a98041338bf4761a8a1af1ec63ba4b5d01bd96b54e
@@ -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 -v 0.0.1 -d ../../example --no-pull example test.sh`
19
+ When I run `env DEBUG=true GLI_DEBUG=true debify test -t 4.7-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"
@@ -5,6 +5,16 @@ require 'gli'
5
5
 
6
6
  include GLI::App
7
7
 
8
+ config_file '.debifyrc'
9
+
10
+ desc 'Set an environment variable (e.g. TERM=xterm) when starting a container'
11
+ flag [:env], :multiple => true
12
+
13
+ desc 'Mount local bundle to reuse gems from previous installation'
14
+ default_value true
15
+ switch [:'local-bundle']
16
+
17
+
8
18
  Docker.options[:read_timeout] = 300
9
19
 
10
20
  # This is used to turn on DEBUG notices.
@@ -33,11 +43,17 @@ module DebugMixin
33
43
  debug a.last
34
44
  else
35
45
  a.each do |line|
36
- line = JSON.parse(line)
37
- line.keys.each do |k|
38
- debug line[k]
39
- end
40
- end
46
+ begin
47
+ line = JSON.parse(line)
48
+ line.keys.each do |k|
49
+ debug line[k]
50
+ end
51
+ rescue JSON::ParserError
52
+ # Docker For Mac is spitting out invalid JSON, so just print
53
+ # out the line if parsing fails.
54
+ debug line
55
+ end
56
+ end
41
57
  end
42
58
  end
43
59
 
@@ -324,7 +340,10 @@ command "test" do |c|
324
340
 
325
341
  c.desc "Specify the deb version; by default, it's computed from the Git tag"
326
342
  c.flag [ :v, :version ]
327
-
343
+
344
+ c.desc "Specify link for test container"
345
+ c.flag [ :l, :link ], :multiple => true
346
+
328
347
  c.action do |global_options,cmd_options,args|
329
348
  raise "project-name is required" unless project_name = args.shift
330
349
  raise "test-script is required" unless test_script = args.shift
@@ -387,13 +406,17 @@ RUN touch /etc/service/conjur/down
387
406
  "CONJUR_ADMIN_PASSWORD=secret",
388
407
  ],
389
408
  'Binds' => [
390
- [ dir, "/src/#{project_name}" ].join(':'),
391
- [ vendor_dir, "/src/#{project_name}/vendor" ].join(':'),
392
- [ dot_bundle_dir, "/src/#{project_name}/.bundle" ].join(':')
409
+ [ dir, "/src/#{project_name}" ].join(':')
393
410
  ]
394
411
  }
395
412
  options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
396
-
413
+ options['Links'] = cmd_options[:link] if cmd_options[:link] && !cmd_options[:link].empty?
414
+ if global_options[:'local-bundle']
415
+ options['Binds']
416
+ .push([ vendor_dir, "/src/#{project_name}/vendor" ].join(':'))
417
+ .push([ dot_bundle_dir, "/src/#{project_name}/.bundle" ].join(':'))
418
+ end
419
+
397
420
  container = Docker::Container.create(options)
398
421
 
399
422
  begin
@@ -411,8 +434,13 @@ RUN touch /etc/service/conjur/down
411
434
  break if exitcode == 0 && status =~ /^run\:/
412
435
  sleep 1
413
436
  end
414
-
415
- container_command container, "/opt/conjur/evoke/bin/test-install", project_name
437
+
438
+ # If we're not using shared gems, run dev-install instead of
439
+ # test-install. Even having to reinstall all the gems is
440
+ # better than dealing with Docker For Mac's current file
441
+ # sharing performance.
442
+ install_cmd = global_options[:'local-bundle'] ? 'test-install' : 'dev-install'
443
+ container_command container, "/opt/conjur/evoke/bin/#{install_cmd}", project_name
416
444
 
417
445
  DebugMixin.debug_write "Starting conjur\n"
418
446
 
@@ -423,6 +451,7 @@ RUN touch /etc/service/conjur/down
423
451
  system "./#{test_script} #{container.id}"
424
452
  exit_now! "#{test_script} failed with exit code #{$?.exitstatus}", $?.exitstatus unless $?.exitstatus == 0
425
453
  ensure
454
+ DebugMixin.debug_write "deleting container"
426
455
  container.delete(force: true) unless cmd_options[:keep]
427
456
  end
428
457
  end
@@ -438,7 +467,7 @@ variables setup for the local environment (appliance URL, cert path, admin usern
438
467
  password, etc). The project source tree is also mounted into the container, at
439
468
  /src/<project-name>, where <project-name> is taken from the name of the current working directory.
440
469
 
441
- Once in the containter, use "/opt/conjur/evoke/bin/dev-install" to install the development bundle of your project.
470
+ Once in the container, use "/opt/conjur/evoke/bin/dev-install" to install the development bundle of your project.
442
471
  DESC
443
472
  command "sandbox" do |c|
444
473
  c.desc "Set the current working directory"
@@ -452,12 +481,23 @@ command "sandbox" do |c|
452
481
  c.flag [ :t, "image-tag"]
453
482
 
454
483
  c.desc "Bind another source directory into the container. Use <src>:<dest>, where both are full paths."
455
- c.flag [ :"bind" ]
484
+ c.flag [ :"bind" ], :multiple => true
456
485
 
457
486
  c.desc "'docker pull' the Conjur container image"
458
487
  c.default_value false
459
488
  c.switch [ :pull ]
460
489
 
490
+ c.desc "Specify link for container"
491
+ c.flag [ :l, :link ], :multiple => true
492
+
493
+ c.desc 'Run dev-install in /src/<project-name>'
494
+ c.default_value false
495
+ c.switch [:'dev-install']
496
+
497
+ c.desc 'Kill previous sandbox container'
498
+ c.default_value false
499
+ c.switch [:kill]
500
+
461
501
  c.action do |global_options,cmd_options,args|
462
502
  raise "Receive extra command-line arguments" if args.shift
463
503
 
@@ -491,21 +531,37 @@ command "sandbox" do |c|
491
531
  "CONJUR_ENV=appliance",
492
532
  "CONJUR_AUTHN_API_KEY=secret",
493
533
  "CONJUR_ADMIN_PASSWORD=secret",
494
- ],
534
+ ] + global_options[:env],
495
535
  'Binds' => [
496
536
  [ File.expand_path(".ssh/id_rsa", ENV['HOME']), "/root/.ssh/id_rsa", 'ro' ].join(':'),
497
537
  [ dir, "/src/#{project_name}" ].join(':'),
498
- [ vendor_dir, "/src/#{project_name}/vendor" ].join(':'),
499
- [ dot_bundle_dir, "/src/#{project_name}/.bundle" ].join(':')
500
538
  ] + Array(cmd_options[:bind])
501
539
  }
540
+ if global_options[:'local-bundle']
541
+ options['Binds']
542
+ .push([ vendor_dir, "/src/#{project_name}/vendor" ].join(':'))
543
+ .push([ dot_bundle_dir, "/src/#{project_name}/.bundle" ].join(':'))
544
+ end
545
+
502
546
  options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
547
+ options['Links'] = cmd_options[:link] unless cmd_options[:link].empty?
548
+
549
+ if cmd_options[:kill]
550
+ previous = Docker::Container.get(options['name']) rescue nil
551
+ previous.delete(:force => true) if previous
552
+ end
503
553
 
504
554
  container = Docker::Container.create(options)
505
555
  $stdout.puts container.id
506
556
  container.start
507
557
 
508
558
  wait_for_conjur appliance_image, container
559
+
560
+ if cmd_options[:'dev-install']
561
+ container_command(container, "/opt/conjur/evoke/bin/dev-install", project_name)
562
+ container_command(container, 'sv', 'restart', "conjur/#{project_name}")
563
+ end
564
+
509
565
  end
510
566
  end
511
567
  end
@@ -1,5 +1,5 @@
1
1
  module Conjur
2
2
  module Debify
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-debify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-28 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli