kitchen_hooks 1.5.5 → 1.5.6

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: de9b45ecc75ea9db7978e4a39238acc8b640b723
4
- data.tar.gz: 8e95dd39e38199cba2024dd230249f0043795683
3
+ metadata.gz: 6a1d5107cae4e7385d9eaedc0b4d03ee1214d254
4
+ data.tar.gz: 99d466d56fbfe8364614ca8e46c8c3ac9890bf31
5
5
  SHA512:
6
- metadata.gz: d2950c8af1f35ec2ab5c27eef6d1e7f17704e51d3eb966d4ee6067b55a710669ca07f3e298303b2ea5f1a505474b2f60d88dd4b2bce921f72dab476bf80e2ab4
7
- data.tar.gz: 3db27dfd022ed749f4c6f09104d33140c1b85cf51d3a897fbc026f7e12d7844d71933bb69c215d4331dd4142ec1d125fdc5ca953978e9c64d841bb8d0231c140
6
+ metadata.gz: d9b299caa2e7b337ca016f0bd2a04d61e7010ce3767c31f8c6ff9976891ec000620e6e2dfae902867245fc6c1370bdeba13b6f9088a1ae9cc60f89b78474f609
7
+ data.tar.gz: 87f4f6ea67fd3ffc02c8fcc597ff6c96041303f07729f29575b9d97a9d070de9213963fbc422e97789f590efefa8ef064d0228bb9a7299cf753f104606de2f7b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.5
1
+ 1.5.6
@@ -128,7 +128,7 @@ module KitchenHooks
128
128
  possible_error = begin
129
129
  perform_kitchen_upload event, knives
130
130
  rescue Exception => e
131
- report_error e, 'Could not perform kitchen upload: <i>%s</i>' % e.message
131
+ report_error e, 'Could not perform kitchen upload: <i>%s</i>' % e.message.lines.first
132
132
  end
133
133
  mark event, 'kitchen upload', possible_error
134
134
  end
@@ -138,7 +138,7 @@ module KitchenHooks
138
138
  possible_error = begin
139
139
  perform_cookbook_upload event, knives
140
140
  rescue Exception => e
141
- report_error e, 'Could not perform cookbook upload: <i>%s</i>' % e.message
141
+ report_error e, 'Could not perform cookbook upload: <i>%s</i>' % e.message.lines.first
142
142
  end
143
143
  mark event, 'cookbook upload', possible_error
144
144
  end
@@ -148,7 +148,7 @@ module KitchenHooks
148
148
  possible_error = begin
149
149
  perform_constraint_application event, knives
150
150
  rescue Exception => e
151
- report_error e, 'Could not apply constraints: <i>%s</i>' % e.message
151
+ report_error e, 'Could not apply constraints: <i>%s</i>' % e.message.lines.first
152
152
  end
153
153
  mark event, 'constraint application', possible_error
154
154
  end
@@ -57,10 +57,10 @@ module KitchenHooks
57
57
  tmp_clone event, :latest_commit do |clone|
58
58
  Dir.chdir clone do
59
59
  logger.info 'Uploading data_bags'
60
- with_each_knife 'upload data_bags --chef-repo-path .', knives
60
+ with_each_knife_do 'upload data_bags --chef-repo-path .', knives
61
61
 
62
62
  logger.info 'Uploading roles'
63
- with_each_knife 'upload roles --chef-repo-path .', knives
63
+ with_each_knife_do 'upload roles --chef-repo-path .', knives
64
64
 
65
65
  logger.info 'Uploading environments'
66
66
  Dir['environments/*'].each do |e|
@@ -90,7 +90,7 @@ module KitchenHooks
90
90
  end
91
91
 
92
92
  logger.info 'Uploading cookbook'
93
- with_each_knife "cookbook upload #{cookbook_name event} -o .. --freeze", knives
93
+ with_each_knife_do "cookbook upload #{cookbook_name event} -o .. --freeze", knives
94
94
  end
95
95
 
96
96
  berksfile = File::join clone, 'Berksfile'
@@ -109,22 +109,45 @@ module KitchenHooks
109
109
  end
110
110
 
111
111
 
112
+ def berkshelf_config knife
113
+ ridley = Ridley::from_chef_config knife
114
+ config = {
115
+ chef: {
116
+ node_name: ridley.client_name,
117
+ client_key: ridley.client_key,
118
+ chef_server_url: ridley.server_url
119
+ },
120
+ ssl: {
121
+ verify: false
122
+ }
123
+ }
124
+ config_path = File.join tmp, "#{SecureRandom.hex}-berkshelf.json"
125
+ File.open(config_path, 'w') do |f|
126
+ f.puts JSON::pretty_generate config
127
+ end
128
+ return config_path
129
+ end
130
+
131
+
112
132
  def berks_upload berksfile, knife, options={}
113
133
  logger.debug 'started berks_upload berksfile=%s, knife=%s' % [
114
134
  berksfile.inspect, knife.inspect
115
135
  ]
116
- ridley = Ridley::from_chef_config knife
117
- options.merge! \
118
- berksfile: berksfile,
119
- debug: true,
120
- freeze: true,
121
- validate: true,
122
- server_url: ridley.server_url,
123
- client_name: ridley.client_name,
124
- client_key: ridley.client_key
125
- berksfile = Berkshelf::Berksfile.from_options(options)
126
- berksfile.install
127
- berksfile.upload [], options
136
+ config_path = berkshelf_config(knife)
137
+
138
+ cmd = "berks install --debug --berksfile %s" % [
139
+ Shellwords::escape(berksfile)
140
+ ]
141
+ logger.debug "berks_install: %s" % cmd
142
+ system cmd
143
+
144
+ cmd = "berks upload --debug --berksfile %s --config %s" % [
145
+ Shellwords::escape(berksfile), Shellwords::escape(config_path)
146
+ ]
147
+ logger.debug "berks_upload: %s" % cmd
148
+ system cmd
149
+
150
+ FileUtils.rm_rf config_path
128
151
  logger.debug 'finished berks_upload: %s' % berksfile
129
152
  end
130
153
 
@@ -155,9 +178,13 @@ module KitchenHooks
155
178
  end
156
179
 
157
180
 
181
+ def with_each_knife_do command, knives
182
+ with_each_knife "knife #{command} --config %{knife}", knives
183
+ end
184
+
158
185
  def with_each_knife command, knives
159
186
  knives.map do |k|
160
- cmd = "knife #{command} --config #{Shellwords::escape k}"
187
+ cmd = command % { knife: Shellwords::escape(k) }
161
188
  logger.debug 'with_each_knife: %s' % cmd
162
189
  `#{cmd}`
163
190
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Wong