chef-api 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef-api/aclable.rb +35 -0
  3. data/lib/chef-api/connection.rb +2 -0
  4. data/lib/chef-api/resource.rb +2 -0
  5. data/lib/chef-api/resources/client.rb +1 -0
  6. data/lib/chef-api/resources/data_bag.rb +1 -1
  7. data/lib/chef-api/resources/group.rb +16 -0
  8. data/lib/chef-api/resources/node.rb +9 -6
  9. data/lib/chef-api/resources/role.rb +1 -0
  10. data/lib/chef-api/version.rb +1 -1
  11. data/templates/errors/abstract_method.erb +5 -0
  12. data/templates/errors/cannot_regenerate_key.erb +1 -0
  13. data/templates/errors/chef_api_error.erb +1 -0
  14. data/templates/errors/file_not_found.erb +1 -0
  15. data/templates/errors/http_bad_request.erb +3 -0
  16. data/templates/errors/http_forbidden_request.erb +3 -0
  17. data/templates/errors/http_gateway_timeout.erb +3 -0
  18. data/templates/errors/http_method_not_allowed.erb +3 -0
  19. data/templates/errors/http_not_acceptable.erb +3 -0
  20. data/templates/errors/http_not_found.erb +3 -0
  21. data/templates/errors/http_server_unavailable.erb +1 -0
  22. data/templates/errors/http_unauthorized_request.erb +3 -0
  23. data/templates/errors/insufficient_file_permissions.erb +1 -0
  24. data/templates/errors/invalid_resource.erb +1 -0
  25. data/templates/errors/invalid_validator.erb +1 -0
  26. data/templates/errors/missing_url_parameter.erb +1 -0
  27. data/templates/errors/not_a_directory.erb +1 -0
  28. data/templates/errors/resource_already_exists.erb +1 -0
  29. data/templates/errors/resource_not_found.erb +1 -0
  30. data/templates/errors/resource_not_mutable.erb +1 -0
  31. data/templates/errors/unknown_attribute.erb +1 -0
  32. metadata +32 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee8604bcf5bcfe321caabd69eaf49850a1cb3a2a2e64f4ba3f1f9f19dbe23b70
4
- data.tar.gz: 792c8bf1f685f45317e80b13b389fd5898e57db767f447bacc5bf5711a47d3af
3
+ metadata.gz: eb60acbcccaaf06781a238fb0698a48492bb89a9f953d19a6fa0ba5861d26e3f
4
+ data.tar.gz: d646e7a1a4d1fae8c62f8cd107df7d2ed7fd6f2c02516b1adef0ea9c07c7bbd0
5
5
  SHA512:
6
- metadata.gz: e0ec7e3b00bbfee5ccb9774803f1db57b8c326e0ba4f63d61e4dceebadd921ff6281f560873ef4a31372e0158fdda4173b0380162e16014171bbf817eaf6d7db
7
- data.tar.gz: a346455a325f6454efd34a6b4fe370e8f37734886e8ad85f00118cc67467c0d473a3140b87d1ca86f2fa9c003159679b5debd5a3527a6e8fdb9ab65d89a7e8ba
6
+ metadata.gz: 9f5050adf73f8f580274b32718524e50b813bb4a70c3c4664b182f95b759cd8f20ccd3604aaad5bb32b10a6d545e3f108d3d4fad5b482c9a08a3209ead137a7c
7
+ data.tar.gz: 9c73fc775086eddb194614d1a0094e84311aeb9d027df08aff68061a9498f9a2af8977486e3664f58311f3d9efe02d09a9bb11c3b889e47062e2427337bb7ec8
@@ -0,0 +1,35 @@
1
+ module ChefAPI
2
+ module AclAble
3
+ def acl_path
4
+ self.resource_path + '/_acl'
5
+ end
6
+
7
+ def load_acl
8
+ data = self.class.connection.get(acl_path)
9
+ # make deep copy
10
+ @orig_acl_data = Marshal.load(Marshal.dump(data))
11
+ data.freeze
12
+ @acl = data
13
+ end
14
+
15
+ def acl
16
+ unless @acl
17
+ self.load_acl
18
+ end
19
+ @acl
20
+ end
21
+
22
+ def save!
23
+ super
24
+ if @acl != @orig_acl_data
25
+ %w(create update grant read delete).each{|action|
26
+ if @acl[action] != @orig_acl_data[action]
27
+ url = "#{self.acl_path}/#{action}"
28
+ self.class.connection.put(url, {action => @acl[action]}.to_json)
29
+ end
30
+ }
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -40,7 +40,9 @@ module ChefAPI
40
40
  proxy :clients, 'Resource::Client'
41
41
  proxy :cookbooks, 'Resource::Cookbook'
42
42
  proxy :data_bags, 'Resource::DataBag'
43
+ proxy :data_bag_item, 'Resource::DataBagItem'
43
44
  proxy :environments, 'Resource::Environment'
45
+ proxy :groups, 'Resource::Group'
44
46
  proxy :nodes, 'Resource::Node'
45
47
  proxy :partial_search, 'Resource::PartialSearch'
46
48
  proxy :principals, 'Resource::Principal'
@@ -1,3 +1,4 @@
1
+ require "chef-api/aclable"
1
2
  module ChefAPI
2
3
  module Resource
3
4
  autoload :Base, 'chef-api/resources/base'
@@ -8,6 +9,7 @@ module ChefAPI
8
9
  autoload :DataBag, 'chef-api/resources/data_bag'
9
10
  autoload :DataBagItem, 'chef-api/resources/data_bag_item'
10
11
  autoload :Environment, 'chef-api/resources/environment'
12
+ autoload :Group, 'chef-api/resources/group'
11
13
  autoload :Node, 'chef-api/resources/node'
12
14
  autoload :Organization, 'chef-api/resources/organization'
13
15
  autoload :PartialSearch, 'chef-api/resources/partial_search'
@@ -1,5 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::Client < Resource::Base
3
+ include ChefAPI::AclAble
3
4
  collection_path '/clients'
4
5
 
5
6
  schema do
@@ -36,7 +36,7 @@ module ChefAPI
36
36
  bag = new(name: name)
37
37
 
38
38
  Util.fast_collect(Dir["#{path}/*.json"]) do |item|
39
- DataBagItem.from_file(item, bag)
39
+ Resource::DataBagItem.from_file(item, bag)
40
40
  end
41
41
  end
42
42
 
@@ -0,0 +1,16 @@
1
+ module ChefAPI
2
+ class Resource::Group < Resource::Base
3
+ collection_path '/groups'
4
+
5
+ schema do
6
+ attribute :groupname, type: String, primary: true, required: true
7
+ attribute :name, type: String
8
+ attribute :orgname, type: String
9
+ attribute :actors, type: Array, default: []
10
+ attribute :users, type: Array, default: []
11
+ attribute :clients, type: Array, default: []
12
+ attribute :groups, type: Array, default: []
13
+ end
14
+ end
15
+ end
16
+
@@ -1,14 +1,17 @@
1
1
  module ChefAPI
2
2
  class Resource::Node < Resource::Base
3
+ include ChefAPI::AclAble
3
4
  collection_path '/nodes'
4
5
 
5
6
  schema do
6
- attribute :name, type: String, primary: true, required: true
7
- attribute :automatic, type: Hash, default: {}
8
- attribute :default, type: Hash, default: {}
9
- attribute :normal, type: Hash, default: {}
10
- attribute :override, type: Hash, default: {}
11
- attribute :run_list, type: Array, default: []
7
+ attribute :name, type: String, primary: true, required: true
8
+ attribute :automatic, type: Hash, default: {}
9
+ attribute :default, type: Hash, default: {}
10
+ attribute :normal, type: Hash, default: {}
11
+ attribute :override, type: Hash, default: {}
12
+ attribute :run_list, type: Array, default: []
13
+ attribute :policy_name, type: String
14
+ attribute :policy_group, type: String
12
15
 
13
16
  # Enterprise Chef attributes
14
17
  attribute :chef_environment, type: String, default: '_default'
@@ -1,5 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::Role < Resource::Base
3
+ include ChefAPI::AclAble
3
4
  collection_path '/roles'
4
5
 
5
6
  schema do
@@ -1,3 +1,3 @@
1
1
  module ChefAPI
2
- VERSION = '0.9.0'
2
+ VERSION = "0.10.0".freeze
3
3
  end
@@ -0,0 +1,5 @@
1
+ '<%= @method %>' is an abstract method. You must override this method in your subclass with the proper implementation and logic. For more information, please see the inline documentation for <%= @method %>. If you are not a developer, this is most likely a bug in the ChefAPI gem. Please file a bug report at:
2
+
3
+ https://github.com/sethvargo/chef-api/issues/new
4
+
5
+ and include the command(s) or code you ran to arrive at this error.
@@ -0,0 +1 @@
1
+ You attempted to regenerate the private key for a Client or User that does not yet exist on the remote Chef Server. You can only regenerate the key for an object that is persisted. Try saving this record this object before regenerating the key.
@@ -0,0 +1 @@
1
+ Oh no! Something really bad happened. I am not sure what actually happened because this is the catch-all error, but you should most definitely report an issue on GitHub at https://github.com/sethvargo/chef-api.
@@ -0,0 +1 @@
1
+ I could not find a file at '<%= @path %>'. Please make sure you have typed the path correctly and that the resource exists at the given path.
@@ -0,0 +1,3 @@
1
+ The Chef Server did not understand the request because it was malformed.
2
+
3
+ <%= @message %>
@@ -0,0 +1,3 @@
1
+ The Chef Server actively refused to fulfill the request.
2
+
3
+ <%= @message %>
@@ -0,0 +1,3 @@
1
+ The Chef Server did not respond in an adequate amount of time.
2
+
3
+ <%= @message %>
@@ -0,0 +1,3 @@
1
+ That HTTP method is not allowed on this URL.
2
+
3
+ <%= @message %>
@@ -0,0 +1,3 @@
1
+ The Chef Server identified this request as unacceptable. This usually means you have not specified the correct Accept or Content-Type headers on the request.
2
+
3
+ <%= @message %>
@@ -0,0 +1,3 @@
1
+ The requested URL does not exist on the Chef Server.
2
+
3
+ <%= @message %>
@@ -0,0 +1 @@
1
+ The Chef Server is currently unavailable or is not currently accepting client connections. Please ensure the server is accessible via ping or telnet on your local network. If this error persists, please contact your network administrator.
@@ -0,0 +1,3 @@
1
+ The Chef Server requires authorization. Please ensure you have specified the correct client name and private key. If this error continues, please verify the given client has the proper permissions on the Chef Server.
2
+
3
+ <%= @message %>
@@ -0,0 +1 @@
1
+ I cannot read the file at '<%= @path %>' because the permissions on the file do not permit it. Please ensure the file has the correct permissions and that this Ruby process is running as a user with access to that path.
@@ -0,0 +1 @@
1
+ There were errors saving your resource: <%= @errors %>
@@ -0,0 +1 @@
1
+ '<%= @key %>' is not a valid validator. Please make sure it is spelled correctly and that the constant is properly defined. If you are using a custom validator, please ensure the validator extends ChefAPI::Validator::Base and is a subclass of ChefAPI::Validator.
@@ -0,0 +1 @@
1
+ The required URL parameter '<%= @param %>' was not present. Please specify the parameter as an option, like Resource.new(id, <%= @param %>: 'value').
@@ -0,0 +1 @@
1
+ The given path '<%= @path %>' is not a directory. Please make sure you have passed the path to a directory on disk.
@@ -0,0 +1 @@
1
+ The <%= @type %> '<%= @id %>' already exists on the Chef Server. Each <%= @type %> must have a unique identifier and the Chef Server indicated this <%= @type %> already exists. If you are trying to update the <%= @type %>, consider using the 'update' method instead.
@@ -0,0 +1 @@
1
+ There is no <%= @type %> with an id of '<%= @id %>' on the Chef Server. If you are updating the <%= @type %>, please make sure the <%= @type %> exists and has the correct Chef identifier (primary key).
@@ -0,0 +1 @@
1
+ The <%= @type %> '<%= @id %>' is not mutable. It may be locked by the remote Chef Server, or the Chef Server may not permit modifying the resource.
@@ -0,0 +1 @@
1
+ '<%= @attribute %>' is not a valid attribute!
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
+ - Tim Smith
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-12-03 00:00:00.000000000 Z
12
+ date: 2019-10-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: logify
@@ -38,15 +39,17 @@ dependencies:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
- description: A tiny Chef API client with minimal dependencies
42
+ description: A tiny Chef Infra API client with minimal dependencies
42
43
  email:
43
44
  - sethvargo@gmail.com
45
+ - tsmith84@gmail.com
44
46
  executables: []
45
47
  extensions: []
46
48
  extra_rdoc_files: []
47
49
  files:
48
50
  - LICENSE
49
51
  - lib/chef-api.rb
52
+ - lib/chef-api/aclable.rb
50
53
  - lib/chef-api/authentication.rb
51
54
  - lib/chef-api/boolean.rb
52
55
  - lib/chef-api/configurable.rb
@@ -64,6 +67,7 @@ files:
64
67
  - lib/chef-api/resources/data_bag.rb
65
68
  - lib/chef-api/resources/data_bag_item.rb
66
69
  - lib/chef-api/resources/environment.rb
70
+ - lib/chef-api/resources/group.rb
67
71
  - lib/chef-api/resources/node.rb
68
72
  - lib/chef-api/resources/organization.rb
69
73
  - lib/chef-api/resources/partial_search.rb
@@ -78,7 +82,28 @@ files:
78
82
  - lib/chef-api/validators/required.rb
79
83
  - lib/chef-api/validators/type.rb
80
84
  - lib/chef-api/version.rb
81
- homepage: https://github.com/sethvargo/chef-api
85
+ - templates/errors/abstract_method.erb
86
+ - templates/errors/cannot_regenerate_key.erb
87
+ - templates/errors/chef_api_error.erb
88
+ - templates/errors/file_not_found.erb
89
+ - templates/errors/http_bad_request.erb
90
+ - templates/errors/http_forbidden_request.erb
91
+ - templates/errors/http_gateway_timeout.erb
92
+ - templates/errors/http_method_not_allowed.erb
93
+ - templates/errors/http_not_acceptable.erb
94
+ - templates/errors/http_not_found.erb
95
+ - templates/errors/http_server_unavailable.erb
96
+ - templates/errors/http_unauthorized_request.erb
97
+ - templates/errors/insufficient_file_permissions.erb
98
+ - templates/errors/invalid_resource.erb
99
+ - templates/errors/invalid_validator.erb
100
+ - templates/errors/missing_url_parameter.erb
101
+ - templates/errors/not_a_directory.erb
102
+ - templates/errors/resource_already_exists.erb
103
+ - templates/errors/resource_not_found.erb
104
+ - templates/errors/resource_not_mutable.erb
105
+ - templates/errors/unknown_attribute.erb
106
+ homepage: https://github.com/chef/chef-api
82
107
  licenses:
83
108
  - Apache-2.0
84
109
  metadata: {}
@@ -90,16 +115,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
115
  requirements:
91
116
  - - ">="
92
117
  - !ruby/object:Gem::Version
93
- version: '2.2'
118
+ version: '2.3'
94
119
  required_rubygems_version: !ruby/object:Gem::Requirement
95
120
  requirements:
96
121
  - - ">="
97
122
  - !ruby/object:Gem::Version
98
123
  version: '0'
99
124
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.7.8
125
+ rubygems_version: 3.0.3
102
126
  signing_key:
103
127
  specification_version: 4
104
- summary: A Chef API client in Ruby
128
+ summary: A Chef Infra API client in Ruby
105
129
  test_files: []