knife-essentials 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,15 @@ module ChefFS
26
26
  # TODO this only works on the file system. And it can't be broken into
27
27
  # pieces.
28
28
  begin
29
- Chef::CookbookUploader.new(other_cookbook_version, other.parent.file_path).upload_cookbook
29
+ uploader = Chef::CookbookUploader.new(other_cookbook_version, other.parent.file_path)
30
+ # Chef 11 changes this API
31
+ if uploader.respond_to?(:upload_cookbook)
32
+ puts "upload_cookbook"
33
+ uploader.upload_cookbook
34
+ else
35
+ puts "upload_cookbooks"
36
+ uploader.upload_cookbooks
37
+ end
30
38
  rescue Net::HTTPServerException => e
31
39
  case e.response.code
32
40
  when "409"
@@ -27,6 +27,16 @@ module ChefFS
27
27
  @exists
28
28
  end
29
29
 
30
+ def create_child(name, file_contents)
31
+ json = Chef::JSONCompat.from_json(file_contents).to_hash
32
+ id = name[0,name.length-5]
33
+ if json.include?('id') && json['id'] != id
34
+ raise "ID in #{path_for_printing}/#{name} must be '#{id}' (is '#{json['id']}')"
35
+ end
36
+ rest.post_rest(api_path, json)
37
+ _make_child_entry(name, true)
38
+ end
39
+
30
40
  def _make_child_entry(name, exists = nil)
31
41
  DataBagItem.new(name, self, exists)
32
42
  end
@@ -36,13 +36,13 @@ module ChefFS
36
36
  end
37
37
  end
38
38
 
39
+ # NOTE if you change this significantly, you will likely need to change
40
+ # DataBagDir.create_child as well.
39
41
  def create_child(name, file_contents)
40
42
  json = Chef::JSONCompat.from_json(file_contents).to_hash
41
43
  base_name = name[0,name.length-5]
42
44
  if json.include?('name') && json['name'] != base_name
43
45
  raise "Name in #{path_for_printing}/#{name} must be '#{base_name}' (is '#{json['name']}')"
44
- elsif json.include?('id') && json['id'] != base_name
45
- raise "Name in #{path_for_printing}/#{name} must be '#{base_name}' (is '#{json['id']}')"
46
46
  end
47
47
  rest.post_rest(api_path, json)
48
48
  _make_child_entry(name, true)
@@ -1,4 +1,4 @@
1
1
  module ChefFS
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-02 00:00:00.000000000Z
12
+ date: 2012-08-07 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Universal knife verbs that work with your Chef repository
15
15
  email: jkeiser@opscode.com