cheffish 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/README.md CHANGED
@@ -1,120 +1,120 @@
1
- # Cheffish
2
-
3
- [![Status](https://travis-ci.org/chef/cheffish.svg?branch=master)](https://travis-ci.org/chef/cheffish)
4
- [![Gem Version](https://badge.fury.io/rb/cheffish.svg)](http://badge.fury.io/rb/cheffish)
5
-
6
- This library provides a variety of convergent resources for interacting with the Chef Server; along the way, it happens to provide some very useful and sophisticated ways of running Chef resources as recipes in RSpec examples.
7
-
8
- **This document may have errors, but it should have enough pointers to get you oriented.**
9
-
10
- There are essentially 3 collections here:
11
-
12
- ## Resource/Provider Pairs for Manipulating Chef Servers
13
-
14
- You'd use these in recipes/cookbooks. They are documented on the [main Chef docs site](https://docs.chef.io).
15
-
16
- - [chef_acl](https://docs.chef.io/resource_chef_acl.html)
17
- - [chef_client](https://docs.chef.io/resource_chef_client.html)
18
- - [chef_container](https://docs.chef.io/resource_chef_container.html)
19
- - [chef_data_bag](https://docs.chef.io/resource_chef_data_bag.html)
20
- - [chef_data_bag_item](https://docs.chef.io/resource_chef_data_bag_item.html)
21
- - [chef_environment](https://docs.chef.io/resource_chef_environment.html)
22
- - [chef_group](https://docs.chef.io/resource_chef_group.html)
23
- - [chef_mirror](https://docs.chef.io/resource_chef_mirror.html)
24
- - [chef_node](https://docs.chef.io/resource_chef_node.html)
25
- - [chef_organization](https://docs.chef.io/resource_chef_organization.html)
26
- - [chef_resolved_cookbooks](https://docs.chef.io/resource_chef_resolved_cookbooks.html)
27
- - [chef_role](https://docs.chef.io/resource_chef_role.html)
28
- - [chef_user](https://docs.chef.io/resource_chef_user.html)
29
- - [private_key](https://docs.chef.io/resource_private_key.html)
30
- - [public_key](https://docs.chef.io/resource_public_key.html)
31
-
32
- ## Base/Helper Classes
33
-
34
- To support the resource/provider pairs.
35
-
36
-
37
- ## RSpec Support
38
-
39
- Most of these RSpec...things were developed for testing the resource/provider pairs above; *however*, you can also `require cheffish/rspec/chef_run_support` for any RSpec `expect`s you'd like, as we do for `chef-provisioning` and its drivers (especially `chef-provisioning-aws`).
40
-
41
- The awesomeness here is that instead of instantiating a `run_context` and a `node` and a `resource` as Ruby objects, you can test your resources in an actual recipe:
42
-
43
- ```ruby
44
- when_the_chef_12_server "exists", organization: 'some-org', server_scope: :context, port: 8900..9000 do
45
- file "/tmp/something_important.json" do
46
- content "A resource in its native environment."
47
- end
48
- end
49
- ```
50
-
51
- An enclosing context that spins up `chef-zero` (local mode) Chef servers as dictated by `server_scope`. `Chef::Config` will be set up with the appropriate server URLs (see the `with_*` operators below).
52
-
53
- `server_scope`:
54
- - `:context`
55
- - `:example` *[default?]*
56
- - ?
57
-
58
- `port`:
59
- - port number (8900 is the default)
60
- - port range (server will continue trying up this range until it finds a free port)
61
-
62
- ```ruby
63
- expect_recipe {
64
- # unquoted recipe DSL here.
65
- }.to be_truthy # or write your own matchers.
66
- ```
67
-
68
- Converges the recipe using `expect()` (parentheses), which tests for a value and **cannot** be used with `raise_error`.
69
-
70
- ```ruby
71
- expect_converge {
72
- # unquoted recipe DSL here.
73
- }.to raise_error(ArgumentException)
74
- ```
75
-
76
- Converges the recipe using `expect{ }` (curly brackets), which wraps the block in a `begin..rescue..end` to detect when the block raises an exception; hence, this is **only** for `raise_error`.
77
-
78
- The blocks for the following appear to be mostly optional: what they actually do is set the `Chef::Config` variable in the name to the given value, and if you provide a block, the change is scoped to that block. Probably this would be clearer if it were aliased to (and preferring) `using` rather than `with`.
79
-
80
- - with_chef_server(server_url, options = {}, &block)
81
- - with_chef_local_server(options, &block)
82
- - with_chef_environment(name, &block)
83
- - with_chef_data_bag_item_encryption(encryption_options, &block)
84
- - with_chef_data_bag(name)
85
- - Takes a block, though this is not noted in the method signature.
86
-
87
-
88
-
89
- get_private_key(name)
90
-
91
-
92
- ### RSpec matchers
93
-
94
- These are used with `expect_recipe` or `expect_converge`:
95
-
96
- ```ruby
97
- expect_recipe {
98
- file "/tmp/a_file.json" do
99
- content "Very important content."
100
- end
101
- }.to be_idempotent.and emit_no_warnings_or_errors
102
- ```
103
-
104
- `be_idempotent`
105
-
106
- - Runs the provided recipe *again* (`expect_(recipe|converge)` ran it the first time) and asks the Chef run if it updated anything (using `updated?`, which appears to be defined on `Chef::Resource` instead of `Chef::Client`, so there's some clarification to be done there); the matcher is satisfied if the answer is "no."
107
-
108
-
109
- `emit_no_warnings_or_errors`
110
-
111
- - Greps the Chef client run's log output for WARN/ERROR lines; matcher is satisfied if there aren't any.
112
-
113
- `have_updated`
114
-
115
- - Sifts the recipe's event stream(!) to determine if any resources were updated; matcher is satisfied is the answer is "yes."
116
- - This is *not* the opposite of `be_idempotent`.
117
-
118
- `partially_match`
119
-
120
- - TBD
1
+ # Cheffish
2
+
3
+ [![Status](https://travis-ci.org/chef/cheffish.svg?branch=master)](https://travis-ci.org/chef/cheffish)
4
+ [![Gem Version](https://badge.fury.io/rb/cheffish.svg)](http://badge.fury.io/rb/cheffish)
5
+
6
+ This library provides a variety of convergent resources for interacting with the Chef Server; along the way, it happens to provide some very useful and sophisticated ways of running Chef resources as recipes in RSpec examples.
7
+
8
+ **This document may have errors, but it should have enough pointers to get you oriented.**
9
+
10
+ There are essentially 3 collections here:
11
+
12
+ ## Resource/Provider Pairs for Manipulating Chef Servers
13
+
14
+ You'd use these in recipes/cookbooks. They are documented on the [main Chef docs site](https://docs.chef.io).
15
+
16
+ - [chef_acl](https://docs.chef.io/resource_chef_acl.html)
17
+ - [chef_client](https://docs.chef.io/resource_chef_client.html)
18
+ - [chef_container](https://docs.chef.io/resource_chef_container.html)
19
+ - [chef_data_bag](https://docs.chef.io/resource_chef_data_bag.html)
20
+ - [chef_data_bag_item](https://docs.chef.io/resource_chef_data_bag_item.html)
21
+ - [chef_environment](https://docs.chef.io/resource_chef_environment.html)
22
+ - [chef_group](https://docs.chef.io/resource_chef_group.html)
23
+ - [chef_mirror](https://docs.chef.io/resource_chef_mirror.html)
24
+ - [chef_node](https://docs.chef.io/resource_chef_node.html)
25
+ - [chef_organization](https://docs.chef.io/resource_chef_organization.html)
26
+ - [chef_resolved_cookbooks](https://docs.chef.io/resource_chef_resolved_cookbooks.html)
27
+ - [chef_role](https://docs.chef.io/resource_chef_role.html)
28
+ - [chef_user](https://docs.chef.io/resource_chef_user.html)
29
+ - [private_key](https://docs.chef.io/resource_private_key.html)
30
+ - [public_key](https://docs.chef.io/resource_public_key.html)
31
+
32
+ ## Base/Helper Classes
33
+
34
+ To support the resource/provider pairs.
35
+
36
+
37
+ ## RSpec Support
38
+
39
+ Most of these RSpec...things were developed for testing the resource/provider pairs above; *however*, you can also `require cheffish/rspec/chef_run_support` for any RSpec `expect`s you'd like, as we do for `chef-provisioning` and its drivers (especially `chef-provisioning-aws`).
40
+
41
+ The awesomeness here is that instead of instantiating a `run_context` and a `node` and a `resource` as Ruby objects, you can test your resources in an actual recipe:
42
+
43
+ ```ruby
44
+ when_the_chef_12_server "exists", organization: 'some-org', server_scope: :context, port: 8900..9000 do
45
+ file "/tmp/something_important.json" do
46
+ content "A resource in its native environment."
47
+ end
48
+ end
49
+ ```
50
+
51
+ An enclosing context that spins up `chef-zero` (local mode) Chef servers as dictated by `server_scope`. `Chef::Config` will be set up with the appropriate server URLs (see the `with_*` operators below).
52
+
53
+ `server_scope`:
54
+ - `:context`
55
+ - `:example` *[default?]*
56
+ - ?
57
+
58
+ `port`:
59
+ - port number (8900 is the default)
60
+ - port range (server will continue trying up this range until it finds a free port)
61
+
62
+ ```ruby
63
+ expect_recipe {
64
+ # unquoted recipe DSL here.
65
+ }.to be_truthy # or write your own matchers.
66
+ ```
67
+
68
+ Converges the recipe using `expect()` (parentheses), which tests for a value and **cannot** be used with `raise_error`.
69
+
70
+ ```ruby
71
+ expect_converge {
72
+ # unquoted recipe DSL here.
73
+ }.to raise_error(ArgumentException)
74
+ ```
75
+
76
+ Converges the recipe using `expect{ }` (curly brackets), which wraps the block in a `begin..rescue..end` to detect when the block raises an exception; hence, this is **only** for `raise_error`.
77
+
78
+ The blocks for the following appear to be mostly optional: what they actually do is set the `Chef::Config` variable in the name to the given value, and if you provide a block, the change is scoped to that block. Probably this would be clearer if it were aliased to (and preferring) `using` rather than `with`.
79
+
80
+ - with_chef_server(server_url, options = {}, &block)
81
+ - with_chef_local_server(options, &block)
82
+ - with_chef_environment(name, &block)
83
+ - with_chef_data_bag_item_encryption(encryption_options, &block)
84
+ - with_chef_data_bag(name)
85
+ - Takes a block, though this is not noted in the method signature.
86
+
87
+
88
+
89
+ get_private_key(name)
90
+
91
+
92
+ ### RSpec matchers
93
+
94
+ These are used with `expect_recipe` or `expect_converge`:
95
+
96
+ ```ruby
97
+ expect_recipe {
98
+ file "/tmp/a_file.json" do
99
+ content "Very important content."
100
+ end
101
+ }.to be_idempotent.and emit_no_warnings_or_errors
102
+ ```
103
+
104
+ `be_idempotent`
105
+
106
+ - Runs the provided recipe *again* (`expect_(recipe|converge)` ran it the first time) and asks the Chef run if it updated anything (using `updated?`, which appears to be defined on `Chef::Resource` instead of `Chef::Client`, so there's some clarification to be done there); the matcher is satisfied if the answer is "no."
107
+
108
+
109
+ `emit_no_warnings_or_errors`
110
+
111
+ - Greps the Chef client run's log output for WARN/ERROR lines; matcher is satisfied if there aren't any.
112
+
113
+ `have_updated`
114
+
115
+ - Sifts the recipe's event stream(!) to determine if any resources were updated; matcher is satisfied is the answer is "yes."
116
+ - This is *not* the opposite of `be_idempotent`.
117
+
118
+ `partially_match`
119
+
120
+ - TBD
data/Rakefile CHANGED
@@ -1,23 +1,23 @@
1
- require 'bundler'
2
- require 'rubygems'
3
- require 'rubygems/package_task'
4
- require 'rdoc/task'
5
- require 'rspec/core/rake_task'
6
-
7
- Bundler::GemHelper.install_tasks
8
-
9
- task :default => :spec
10
-
11
- desc "Run specs"
12
- RSpec::Core::RakeTask.new(:spec) do |spec|
13
- spec.pattern = 'spec/**/*_spec.rb'
14
- end
15
-
16
- gem_spec = eval(File.read("cheffish.gemspec"))
17
-
18
- RDoc::Task.new do |rdoc|
19
- rdoc.rdoc_dir = 'rdoc'
20
- rdoc.title = "cheffish #{gem_spec.version}"
21
- rdoc.rdoc_files.include('README*')
22
- rdoc.rdoc_files.include('lib/**/*.rb')
23
- end
1
+ require 'bundler'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ task :default => :spec
10
+
11
+ desc "Run specs"
12
+ RSpec::Core::RakeTask.new(:spec) do |spec|
13
+ spec.pattern = 'spec/**/*_spec.rb'
14
+ end
15
+
16
+ gem_spec = eval(File.read("cheffish.gemspec"))
17
+
18
+ RDoc::Task.new do |rdoc|
19
+ rdoc.rdoc_dir = 'rdoc'
20
+ rdoc.title = "cheffish #{gem_spec.version}"
21
+ rdoc.rdoc_files.include('README*')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end