jackal-kitchen 0.1.0 → 0.1.2

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: d226c76d54712b52e6c65bd61c088c17b784286c
4
- data.tar.gz: 9bb59b0be25e5cb108dc1a0d2aaabf94df69a9c0
3
+ metadata.gz: 8db32bb5a094463ef9b831ce269aa49c1ece5251
4
+ data.tar.gz: 377afbeca4b98319ce323057611f42824da6b5a2
5
5
  SHA512:
6
- metadata.gz: f1cd57f4ef6381fed5963b2bf91ee5e3765b6f4f738670384f8b77cf397701deaf1fbb64cb88934402aee1101af73ff1d5242636f04ef6130620145840da62b4
7
- data.tar.gz: fe5c54f0c7f94010abc8034acc30093547492aa49888444ab8956dcfac8ab589a6f631b3c49cc44d4e6ae275a2f5513b73b59348bd76fdd7d1cc226cd16e68a4
6
+ metadata.gz: a7f8364e3758a1732dc655c38e103d31964e576828362f0c52abd5a606fe4488a7319e18f3098f934940d1fc20e5ec91dca8007c8d6b0b834ada2594b0b5493d
7
+ data.tar.gz: eba823497bf372af71dba9fd192c988ce79e3f6d30433584c41eec124e9589ee563f6bd69843422301059cf3eaa71a1d4d9ce23f0b49ed5f0013a7e54980c725
@@ -33,14 +33,16 @@ module Jackal
33
33
  working_dir = working_path = Dir.mktmpdir
34
34
  begin
35
35
  maybe_clean_bundle do
36
- setup_command("git clone #{repo} cookbook", working_path, payload)
36
+ run_command("git clone #{repo} cookbook", working_path, payload)
37
37
  working_path = File.join(working_path, 'cookbook')
38
- setup_command("git checkout #{ref}", working_path, payload)
39
- setup_command("bundle install", working_path, payload)
40
- kitchen_command("bundle exec kitchen test", working_path, payload)
38
+ run_command("git checkout #{ref}", working_path, payload)
39
+ insert_kitchen_lxc(working_path)
40
+ insert_kitchen_local(working_path)
41
+ run_command("bundle install --path /tmp/.kitchen-jackal-vendor", working_path, payload)
42
+ run_command("bundle exec kitchen test", working_path, payload)
41
43
  end
42
44
  rescue => e
43
- raise
45
+ error "Command failed! #{e.class}: #{e}"
44
46
  ensure
45
47
  FileUtils.rm_rf(working_dir)
46
48
  end
@@ -48,34 +50,41 @@ module Jackal
48
50
  end
49
51
  end
50
52
 
53
+ def insert_kitchen_local(path)
54
+ File.open(File.join(path, '.kitchen.local.yml'), 'w') do |file|
55
+ file.puts '---'
56
+ file.puts 'driver:'
57
+ file.puts ' name: lxc'
58
+ file.puts ' use_sudo: false'
59
+ if(config[:ssh_key])
60
+ file.puts " ssh_key: #{config[:ssh_key]}"
61
+ end
62
+ end
63
+ end
64
+
65
+ # Update gemfile to include kitchen-lxc driver
66
+ #
67
+ # @param path [String] working directory
68
+ def insert_kitchen_lxc(path)
69
+ gemfile = File.join(path, 'Gemfile')
70
+ if(File.exists?(gemfile))
71
+ content = File.readlines(gemfile)
72
+ else
73
+ content = ['source "https://rubygems.org"']
74
+ end
75
+ content << 'gem "kitchen-lxc"'
76
+ File.open(gemfile, 'w') do |file|
77
+ file.puts content.join("\n")
78
+ end
79
+ end
80
+
51
81
  # Run a command
52
82
  #
53
83
  # @param command [String] command to execute
54
84
  # @param working_path [String] local working path
55
85
  # @param payload [Smash] current payload
56
86
  # @return [TrueClass]
57
- def setup_command(command, working_path, payload)
58
- cmd_input = Shellwords.shellsplit(command)
59
- process = ChildProcess.build(*cmd_input)
60
- stdout = File.open(File.join(working_path, 'stdout'), 'w+')
61
- stderr = File.open(File.join(working_path, 'stderr'), 'w+')
62
- process.io.stdout = stdout
63
- process.io.stderr = stderr
64
- process.cwd = working_path
65
- process.start
66
- status = process.wait
67
- if status == 0
68
- info "Setup command '#{command}' completed sucessfully"
69
- payload.set(:data, :kitchen, :result, command, :success)
70
- true
71
- else
72
- error "Command '#{command}' failed"
73
- payload.set(:data, :kitchen, :result, command, :fail)
74
- raise "Failed to execute setup command '#{command}'"
75
- end
76
- end
77
-
78
- def kitchen_command(command, working_path, payload)
87
+ def run_command(command, working_path, payload)
79
88
  cmd_input = Shellwords.shellsplit(command)
80
89
  process = ChildProcess.build(*cmd_input)
81
90
  stdout = File.open(File.join(working_path, 'stdout'), 'w+')
@@ -91,8 +100,12 @@ module Jackal
91
100
  true
92
101
  else
93
102
  error "Command '#{command}' failed"
103
+ stderr.rewind
94
104
  payload.set(:data, :kitchen, :result, command, :fail)
95
- raise "Failed to execute command '#{command}'"
105
+ payload.set(:data, :kitchen, :error, stderr.read)
106
+ stdout.rewind
107
+ stderr.rewind
108
+ raise "Command failure! (#{command}). STDOUT: #{stdout.read} STDERR: #{stderr.read}"
96
109
  end
97
110
  end
98
111
 
@@ -1,5 +1,5 @@
1
1
  module Jackal
2
2
  module Kitchen
3
- VERSION = Gem::Version.new('0.1.0')
3
+ VERSION = Gem::Version.new('0.1.2')
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jackal-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Goddard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jackal