cheffish 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +120 -120
  4. data/Rakefile +23 -23
  5. data/lib/chef/provider/chef_acl.rb +439 -439
  6. data/lib/chef/provider/chef_client.rb +53 -53
  7. data/lib/chef/provider/chef_container.rb +55 -55
  8. data/lib/chef/provider/chef_data_bag.rb +55 -55
  9. data/lib/chef/provider/chef_data_bag_item.rb +278 -278
  10. data/lib/chef/provider/chef_environment.rb +83 -83
  11. data/lib/chef/provider/chef_group.rb +83 -83
  12. data/lib/chef/provider/chef_mirror.rb +169 -169
  13. data/lib/chef/provider/chef_node.rb +87 -87
  14. data/lib/chef/provider/chef_organization.rb +155 -155
  15. data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
  16. data/lib/chef/provider/chef_role.rb +84 -84
  17. data/lib/chef/provider/chef_user.rb +59 -59
  18. data/lib/chef/provider/private_key.rb +225 -225
  19. data/lib/chef/provider/public_key.rb +88 -88
  20. data/lib/chef/resource/chef_acl.rb +69 -69
  21. data/lib/chef/resource/chef_client.rb +48 -48
  22. data/lib/chef/resource/chef_container.rb +22 -22
  23. data/lib/chef/resource/chef_data_bag.rb +22 -22
  24. data/lib/chef/resource/chef_data_bag_item.rb +121 -121
  25. data/lib/chef/resource/chef_environment.rb +77 -77
  26. data/lib/chef/resource/chef_group.rb +53 -53
  27. data/lib/chef/resource/chef_mirror.rb +52 -52
  28. data/lib/chef/resource/chef_node.rb +22 -22
  29. data/lib/chef/resource/chef_organization.rb +69 -69
  30. data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
  31. data/lib/chef/resource/chef_role.rb +110 -110
  32. data/lib/chef/resource/chef_user.rb +56 -56
  33. data/lib/chef/resource/private_key.rb +48 -48
  34. data/lib/chef/resource/public_key.rb +25 -25
  35. data/lib/cheffish/actor_provider_base.rb +131 -131
  36. data/lib/cheffish/basic_chef_client.rb +184 -184
  37. data/lib/cheffish/chef_provider_base.rb +246 -246
  38. data/lib/cheffish/chef_run.rb +162 -162
  39. data/lib/cheffish/chef_run_data.rb +19 -19
  40. data/lib/cheffish/chef_run_listener.rb +30 -30
  41. data/lib/cheffish/key_formatter.rb +113 -113
  42. data/lib/cheffish/merged_config.rb +94 -94
  43. data/lib/cheffish/recipe_dsl.rb +157 -157
  44. data/lib/cheffish/rspec/chef_run_support.rb +83 -83
  45. data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
  46. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
  47. data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
  48. data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
  49. data/lib/cheffish/rspec/matchers.rb +4 -4
  50. data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
  51. data/lib/cheffish/rspec/repository_support.rb +108 -108
  52. data/lib/cheffish/rspec.rb +8 -8
  53. data/lib/cheffish/server_api.rb +52 -52
  54. data/lib/cheffish/version.rb +3 -3
  55. data/lib/cheffish/with_pattern.rb +21 -21
  56. data/lib/cheffish.rb +235 -235
  57. data/spec/functional/fingerprint_spec.rb +64 -64
  58. data/spec/functional/merged_config_spec.rb +19 -19
  59. data/spec/functional/server_api_spec.rb +13 -13
  60. data/spec/integration/chef_acl_spec.rb +879 -879
  61. data/spec/integration/chef_client_spec.rb +105 -105
  62. data/spec/integration/chef_container_spec.rb +33 -33
  63. data/spec/integration/chef_group_spec.rb +309 -309
  64. data/spec/integration/chef_mirror_spec.rb +491 -491
  65. data/spec/integration/chef_node_spec.rb +786 -786
  66. data/spec/integration/chef_organization_spec.rb +226 -226
  67. data/spec/integration/chef_role_spec.rb +78 -78
  68. data/spec/integration/chef_user_spec.rb +85 -85
  69. data/spec/integration/private_key_spec.rb +399 -399
  70. data/spec/integration/recipe_dsl_spec.rb +28 -28
  71. data/spec/integration/rspec/converge_spec.rb +183 -183
  72. data/spec/support/key_support.rb +29 -29
  73. data/spec/support/spec_support.rb +15 -15
  74. data/spec/unit/get_private_key_spec.rb +131 -131
  75. data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
  76. metadata +3 -2
@@ -1,53 +1,53 @@
1
- require 'cheffish/actor_provider_base'
2
- require 'chef/resource/chef_client'
3
- require 'chef/chef_fs/data_handler/client_data_handler'
4
-
5
- class Chef
6
- class Provider
7
- class ChefClient < Cheffish::ActorProviderBase
8
- provides :chef_client
9
-
10
- def whyrun_supported?
11
- true
12
- end
13
-
14
- def actor_type
15
- 'client'
16
- end
17
-
18
- def actor_path
19
- 'clients'
20
- end
21
-
22
- action :create do
23
- create_actor
24
- end
25
-
26
- action :delete do
27
- delete_actor
28
- end
29
-
30
- #
31
- # Helpers
32
- #
33
-
34
- def resource_class
35
- Chef::Resource::ChefClient
36
- end
37
-
38
- def data_handler
39
- Chef::ChefFS::DataHandler::ClientDataHandler.new
40
- end
41
-
42
- def keys
43
- {
44
- 'name' => :name,
45
- 'admin' => :admin,
46
- 'validator' => :validator,
47
- 'public_key' => :source_key
48
- }
49
- end
50
-
51
- end
52
- end
53
- end
1
+ require 'cheffish/actor_provider_base'
2
+ require 'chef/resource/chef_client'
3
+ require 'chef/chef_fs/data_handler/client_data_handler'
4
+
5
+ class Chef
6
+ class Provider
7
+ class ChefClient < Cheffish::ActorProviderBase
8
+ provides :chef_client
9
+
10
+ def whyrun_supported?
11
+ true
12
+ end
13
+
14
+ def actor_type
15
+ 'client'
16
+ end
17
+
18
+ def actor_path
19
+ 'clients'
20
+ end
21
+
22
+ action :create do
23
+ create_actor
24
+ end
25
+
26
+ action :delete do
27
+ delete_actor
28
+ end
29
+
30
+ #
31
+ # Helpers
32
+ #
33
+
34
+ def resource_class
35
+ Chef::Resource::ChefClient
36
+ end
37
+
38
+ def data_handler
39
+ Chef::ChefFS::DataHandler::ClientDataHandler.new
40
+ end
41
+
42
+ def keys
43
+ {
44
+ 'name' => :name,
45
+ 'admin' => :admin,
46
+ 'validator' => :validator,
47
+ 'public_key' => :source_key
48
+ }
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -1,55 +1,55 @@
1
- require 'cheffish/chef_provider_base'
2
- require 'chef/resource/chef_container'
3
- require 'chef/chef_fs/data_handler/container_data_handler'
4
-
5
- class Chef
6
- class Provider
7
- class ChefContainer < Cheffish::ChefProviderBase
8
- provides :chef_container
9
-
10
- def whyrun_supported?
11
- true
12
- end
13
-
14
- action :create do
15
- if !@current_exists
16
- converge_by "create container #{new_resource.name} at #{rest.url}" do
17
- rest.post("containers", normalize_for_post(new_json))
18
- end
19
- end
20
- end
21
-
22
- action :delete do
23
- if @current_exists
24
- converge_by "delete container #{new_resource.name} at #{rest.url}" do
25
- rest.delete("containers/#{new_resource.name}")
26
- end
27
- end
28
- end
29
-
30
- def load_current_resource
31
- begin
32
- @current_exists = rest.get("containers/#{new_resource.name}")
33
- rescue Net::HTTPServerException => e
34
- if e.response.code == "404"
35
- @current_exists = false
36
- else
37
- raise
38
- end
39
- end
40
- end
41
-
42
- def new_json
43
- {}
44
- end
45
-
46
- def data_handler
47
- Chef::ChefFS::DataHandler::ContainerDataHandler.new
48
- end
49
-
50
- def keys
51
- { 'containername' => :name, 'containerpath' => :name }
52
- end
53
- end
54
- end
55
- end
1
+ require 'cheffish/chef_provider_base'
2
+ require 'chef/resource/chef_container'
3
+ require 'chef/chef_fs/data_handler/container_data_handler'
4
+
5
+ class Chef
6
+ class Provider
7
+ class ChefContainer < Cheffish::ChefProviderBase
8
+ provides :chef_container
9
+
10
+ def whyrun_supported?
11
+ true
12
+ end
13
+
14
+ action :create do
15
+ if !@current_exists
16
+ converge_by "create container #{new_resource.name} at #{rest.url}" do
17
+ rest.post("containers", normalize_for_post(new_json))
18
+ end
19
+ end
20
+ end
21
+
22
+ action :delete do
23
+ if @current_exists
24
+ converge_by "delete container #{new_resource.name} at #{rest.url}" do
25
+ rest.delete("containers/#{new_resource.name}")
26
+ end
27
+ end
28
+ end
29
+
30
+ def load_current_resource
31
+ begin
32
+ @current_exists = rest.get("containers/#{new_resource.name}")
33
+ rescue Net::HTTPServerException => e
34
+ if e.response.code == "404"
35
+ @current_exists = false
36
+ else
37
+ raise
38
+ end
39
+ end
40
+ end
41
+
42
+ def new_json
43
+ {}
44
+ end
45
+
46
+ def data_handler
47
+ Chef::ChefFS::DataHandler::ContainerDataHandler.new
48
+ end
49
+
50
+ def keys
51
+ { 'containername' => :name, 'containerpath' => :name }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,55 +1,55 @@
1
- require 'cheffish/chef_provider_base'
2
- require 'chef/resource/chef_data_bag'
3
-
4
- class Chef
5
- class Provider
6
- class ChefDataBag < Cheffish::ChefProviderBase
7
- provides :chef_data_bag
8
-
9
- def whyrun_supported?
10
- true
11
- end
12
-
13
- action :create do
14
- if !current_resource_exists?
15
- converge_by "create data bag #{new_resource.name} at #{rest.url}" do
16
- rest.post("data", { 'name' => new_resource.name })
17
- end
18
- end
19
- end
20
-
21
- action :delete do
22
- if current_resource_exists?
23
- converge_by "delete data bag #{new_resource.name} at #{rest.url}" do
24
- rest.delete("data/#{new_resource.name}")
25
- end
26
- end
27
- end
28
-
29
- def load_current_resource
30
- begin
31
- @current_resource = json_to_resource(rest.get("data/#{new_resource.name}"))
32
- rescue Net::HTTPServerException => e
33
- if e.response.code == "404"
34
- @current_resource = not_found_resource
35
- else
36
- raise
37
- end
38
- end
39
- end
40
-
41
- #
42
- # Helpers
43
- #
44
- # Gives us new_json, current_json, not_found_json, etc.
45
-
46
- def resource_class
47
- Chef::Resource::ChefDataBag
48
- end
49
-
50
- def json_to_resource(json)
51
- Chef::Resource::ChefDataBag.new(json['name'], run_context)
52
- end
53
- end
54
- end
55
- end
1
+ require 'cheffish/chef_provider_base'
2
+ require 'chef/resource/chef_data_bag'
3
+
4
+ class Chef
5
+ class Provider
6
+ class ChefDataBag < Cheffish::ChefProviderBase
7
+ provides :chef_data_bag
8
+
9
+ def whyrun_supported?
10
+ true
11
+ end
12
+
13
+ action :create do
14
+ if !current_resource_exists?
15
+ converge_by "create data bag #{new_resource.name} at #{rest.url}" do
16
+ rest.post("data", { 'name' => new_resource.name })
17
+ end
18
+ end
19
+ end
20
+
21
+ action :delete do
22
+ if current_resource_exists?
23
+ converge_by "delete data bag #{new_resource.name} at #{rest.url}" do
24
+ rest.delete("data/#{new_resource.name}")
25
+ end
26
+ end
27
+ end
28
+
29
+ def load_current_resource
30
+ begin
31
+ @current_resource = json_to_resource(rest.get("data/#{new_resource.name}"))
32
+ rescue Net::HTTPServerException => e
33
+ if e.response.code == "404"
34
+ @current_resource = not_found_resource
35
+ else
36
+ raise
37
+ end
38
+ end
39
+ end
40
+
41
+ #
42
+ # Helpers
43
+ #
44
+ # Gives us new_json, current_json, not_found_json, etc.
45
+
46
+ def resource_class
47
+ Chef::Resource::ChefDataBag
48
+ end
49
+
50
+ def json_to_resource(json)
51
+ Chef::Resource::ChefDataBag.new(json['name'], run_context)
52
+ end
53
+ end
54
+ end
55
+ end