kitchen_hooks 2.0.1 → 2.0.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: 0ba01245e85b486d5f099f93e5f0ae885b9e3b8b
4
- data.tar.gz: 43545a336ce67ed90d2811feabf492241c473dd3
3
+ metadata.gz: ba54f91fdcaa672cb23cc618b70e3ce6146f7f5e
4
+ data.tar.gz: 11d5dbebc002f951ed058746c9dd04a4c7a3dcd5
5
5
  SHA512:
6
- metadata.gz: 92b6f867be7b41dd6656f0eea50fc93959029b65fb533aea29ba31c8a2f597cd2fc5757bc30a8d15aa445b94f4544ac43507435abb319bfb1379a29de97697d7
7
- data.tar.gz: 8d4d64798df6bf7e8170375f475efd22b21d8898c4879f37b9615cf1045caceb2084d4b93227dbbab9e345dfdeda1ca753adceaa5c4de28e1be8718b3f0e9465
6
+ metadata.gz: 3e5b28855dc3075f3ccb71c927d8dcd850d7b2542cdb6db1324a43d3be67d8e1953229901f5c56991bab810d884229150cccb075b9f88cec11ab04ab096d9439
7
+ data.tar.gz: 12859577b41a687be8f2d37af00dcd220cbfcefc9066185dfdd97ae615cf305b02d0b40564e74c5cf1cc12d282668af012e709b2fa472d6297045a12a989d392
data/Readme.md CHANGED
@@ -100,6 +100,7 @@ The configuration file is just JSON. Hopefully it's obvious:
100
100
  "token": "your_v1_api_token"
101
101
  },
102
102
  "git_protocol": "daemon",
103
+ "cookbook_upload_method": "berkshelf",
103
104
  "knives": {
104
105
  "user": "~/.chef/knife.rb",
105
106
  "system": "/etc/chef/knife.rb",
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -65,6 +65,7 @@ module KitchenHooks
65
65
  @@hipchat_room = config['hipchat']['room'] || raise('No HipChat "room" provided')
66
66
  end
67
67
  @@git_protocol = config.fetch('git_protocol', 'daemon')
68
+ @@cookbook_upload_method = config.fetch('cookbook_upload_method', 'berkshelf')
68
69
  @@knives = config['knives'].map do |_, knife|
69
70
  Pathname.new(knife).expand_path.realpath.to_s
70
71
  end
@@ -208,7 +209,11 @@ module KitchenHooks
208
209
  if tagged_commit_to_cookbook?(event) &&
209
210
  tag_name(event) =~ /^v?\d+/ # Cookbooks tagged with a version
210
211
  possible_error = begin
211
- perform_cookbook_upload event, knives
212
+ if @@cookbook_upload_method == 'berkshelf'
213
+ perform_cookbook_upload event, knives
214
+ else
215
+ perform_knife_cookbook_upload event, knives
216
+ end
212
217
  rescue Exception => e
213
218
  report_error e, 'Could not perform cookbook upload: <i>%s</i>' % e.message.lines.first
214
219
  end
@@ -113,6 +113,39 @@ module KitchenHooks
113
113
  end
114
114
 
115
115
 
116
+ def self.perform_knife_cookbook_upload event, knives
117
+ $stdout.puts 'started perform_cookbook_upload event=%s, knives=%s' % [
118
+ event['after'], knives.inspect
119
+ ]
120
+
121
+ tmp_clone event, :tagged_commit do |clone|
122
+ tagged_version = tag_name(event).delete('v')
123
+ if File.exist? File.join(clone, 'VERSION')
124
+ cookbook_version = File.read(File.join(clone, 'VERSION')).strip
125
+ else
126
+ cookbook_version = File.foreach(File.join(clone, 'metadata.rb')).grep(/version/)[0][/\"(.*)\"/,1]
127
+ end
128
+ unless tagged_version == cookbook_version
129
+ raise 'Tagged version does not match cookbook version'
130
+ end
131
+
132
+ Dir.chdir clone do
133
+ $stdout.puts 'Uploading cookbook'
134
+ begin
135
+ with_each_knife_do "cookbook upload #{cookbook_name event} -o .. --freeze", knives
136
+ rescue => e
137
+ unless e.to_s =~ /frozen/i # Ignore frozen cookbooks already uploaded
138
+ raise "Knife exited unsuccessfully: #{e}"
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ $stdout.puts "finished cookbook_upload: #{event['after']}"
145
+ return # no error
146
+ end
147
+
148
+
116
149
  def self.perform_cookbook_upload event, knives
117
150
  $stdout.puts 'started perform_cookbook_upload event=%s, knives=%s' % [
118
151
  event['after'], knives.inspect
@@ -149,16 +182,6 @@ module KitchenHooks
149
182
  end
150
183
 
151
184
  Dir.chdir clone do
152
- # N.B. Knife uploading the cookbook should be unnecessary thanks to Berkshelf...
153
- # $stdout.puts 'Uploading cookbook'
154
- # begin
155
- # with_each_knife_do "cookbook upload #{cookbook_name event} -o .. --freeze", knives
156
- # rescue => e
157
- # unless e.to_s =~ /frozen/i # Ignore frozen cookbooks already uploaded
158
- # raise "Knife exited unsuccessfully: #{e}"
159
- # end
160
- # end
161
-
162
185
  if commit_to_realm? event
163
186
  $stdout.puts 'Uploading bundled roles, environments, and data bags'
164
187
  kitchen_upload knives
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hipchat