chef-rewind 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.kitchen.yml +26 -0
  4. data/.travis.yml +11 -0
  5. data/Berksfile +4 -0
  6. data/Gemfile +5 -34
  7. data/README.md +6 -2
  8. data/Rakefile +10 -0
  9. data/chef-rewind.gemspec +1 -1
  10. data/gemfiles/chef-11.gemfile +7 -0
  11. data/gemfiles/chef-12.gemfile +7 -0
  12. data/lib/chef/rewind.rb +45 -15
  13. data/spec/data/cookbooks/rewind/Berksfile +3 -0
  14. data/spec/data/cookbooks/rewind/README.md +1 -0
  15. data/spec/data/cookbooks/rewind/files/default/test/default_test.rb +21 -0
  16. data/spec/data/cookbooks/rewind/metadata.rb +7 -0
  17. data/spec/data/cookbooks/rewind/recipes/base.rb +11 -0
  18. data/spec/data/cookbooks/rewind/recipes/default.rb +12 -0
  19. data/spec/rewind_recipe_spec.rb +10 -11
  20. data/spec/rewind_resource_spec.rb +2 -2
  21. data/spec/spec_helper.rb +0 -44
  22. data/spec/unwind_recipe_spec.rb +34 -5
  23. metadata +23 -89
  24. data/spec/data/cookbooks/angrybash/recipes/default.rb +0 -8
  25. data/spec/data/cookbooks/apache2/files/default/apache2_module_conf_generate.pl +0 -2
  26. data/spec/data/cookbooks/apache2/recipes/default.rb +0 -3
  27. data/spec/data/cookbooks/borken/recipes/default.rb +0 -2
  28. data/spec/data/cookbooks/borken/templates/default/borken.erb +0 -2
  29. data/spec/data/cookbooks/chefignore +0 -6
  30. data/spec/data/cookbooks/java/files/default/java.response +0 -2
  31. data/spec/data/cookbooks/openldap/attributes/default.rb +0 -16
  32. data/spec/data/cookbooks/openldap/attributes/smokey.rb +0 -1
  33. data/spec/data/cookbooks/openldap/definitions/client.rb +0 -5
  34. data/spec/data/cookbooks/openldap/definitions/server.rb +0 -5
  35. data/spec/data/cookbooks/openldap/files/default/.dotfile +0 -1
  36. data/spec/data/cookbooks/openldap/files/default/.ssh/id_rsa +0 -1
  37. data/spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir +0 -1
  38. data/spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file1.txt +0 -3
  39. data/spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file2.txt +0 -3
  40. data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile +0 -1
  41. data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file1.txt +0 -3
  42. data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file2.txt +0 -3
  43. data/spec/data/cookbooks/openldap/files/default/remotedir/subdir_with_no_file_just_a_subsubdir/the_subsubdir/some_file.txt +0 -3
  44. data/spec/data/cookbooks/openldap/recipes/default.rb +0 -3
  45. data/spec/data/cookbooks/openldap/recipes/gigantor.rb +0 -3
  46. data/spec/data/cookbooks/openldap/recipes/one.rb +0 -15
  47. data/spec/data/cookbooks/openldap/templates/default/openldap_stuff.conf.erb +0 -1
  48. data/spec/data/cookbooks/openldap/templates/default/openldap_variable_stuff.conf.erb +0 -1
  49. data/spec/data/cookbooks/openldap/templates/default/test.erb +0 -1
  50. data/spec/support/lib/chef/provider/easy.rb +0 -35
  51. data/spec/support/lib/chef/provider/snakeoil.rb +0 -40
  52. data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -43
  53. data/spec/support/matchers/leak.rb +0 -96
  54. data/spec/support/mock/constant.rb +0 -52
  55. data/spec/support/mock/platform.rb +0 -18
  56. data/spec/support/platform_helpers.rb +0 -31
  57. data/spec/support/platforms/prof/gc.rb +0 -54
  58. data/spec/support/platforms/prof/win32.rb +0 -46
  59. data/spec/support/shared/functional/directory_resource.rb +0 -85
  60. data/spec/support/shared/functional/file_resource.rb +0 -173
  61. data/spec/support/shared/functional/knife.rb +0 -37
  62. data/spec/support/shared/functional/securable_resource.rb +0 -394
  63. data/spec/support/shared/unit/api_error_inspector.rb +0 -192
  64. data/spec/support/shared/unit/platform_introspector.rb +0 -162
@@ -29,10 +29,21 @@ describe Chef::Recipe do
29
29
  @recipe.unwind "zen_master[foobar]"
30
30
 
31
31
  resources = @run_context.resource_collection.all_resources
32
- resources.length.should == 0
32
+ expect(resources.empty?).to be_truthy
33
33
  end
34
34
 
35
- it "should define resource completely when unwind is called" do
35
+ it 'should only remove the correct resource' do
36
+ @recipe.zen_master "foobar"
37
+ @recipe.cat "blanket"
38
+ @recipe.zen_master "bar"
39
+
40
+ @recipe.unwind "cat[blanket]"
41
+
42
+ resources = @run_context.resource_collection.all_resources
43
+ expect(resources.length).to eq 2
44
+ end
45
+
46
+ it "should delete resource completely when unwind is called" do
36
47
  @recipe.zen_master "foo" do
37
48
  action :nothing
38
49
  peace false
@@ -52,13 +63,31 @@ describe Chef::Recipe do
52
63
  notifies :blowup, "cat[blanket]"
53
64
  end
54
65
 
55
- lambda { @runner.converge }.should raise_error(Chef::Provider::Cat::CatError)
66
+ expect { @runner.converge }.to raise_error(Chef::Provider::Cat::CatError)
56
67
  end
57
68
 
58
69
  it "should throw an error when unwinding a nonexistent resource" do
59
- lambda do
70
+ expect {
60
71
  @recipe.unwind "zen_master[foobar]"
61
- end.should raise_error(Chef::Exceptions::ResourceNotFound)
72
+ }.to raise_error(Chef::Exceptions::ResourceNotFound)
73
+ end
74
+
75
+ it "should correctly unwind a resource that was defined more than once" do
76
+ @recipe.zen_master "foo" do
77
+ peace true
78
+ end
79
+ @recipe.cat "blanket"
80
+ @recipe.zen_master "foo" do
81
+ peace false
82
+ end
83
+ @recipe.zen_master "bar"
84
+
85
+ @recipe.unwind "zen_master[foo]"
86
+
87
+ %w(zen_master[bar] cat[blanket]).each do |name|
88
+ resource = @run_context.resource_collection.lookup(name)
89
+ expect(resource.to_s).to eq(name)
90
+ end
62
91
  end
63
92
  end
64
93
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-rewind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Berry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-04 00:00:00.000000000 Z
11
+ date: 2014-12-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Monkey patches Chef to allow rewinding and unwinding of existing resources
14
14
  email:
@@ -17,63 +17,33 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
20
+ - ".gitignore"
21
+ - ".kitchen.yml"
22
+ - ".travis.yml"
23
+ - Berksfile
21
24
  - CHANGELOG
22
25
  - Gemfile
23
26
  - LICENSE
24
27
  - README.md
25
28
  - Rakefile
26
29
  - chef-rewind.gemspec
30
+ - gemfiles/chef-11.gemfile
31
+ - gemfiles/chef-12.gemfile
27
32
  - lib/chef/rewind.rb
28
- - spec/data/cookbooks/angrybash/recipes/default.rb
29
- - spec/data/cookbooks/apache2/files/default/apache2_module_conf_generate.pl
30
- - spec/data/cookbooks/apache2/recipes/default.rb
31
- - spec/data/cookbooks/borken/recipes/default.rb
32
- - spec/data/cookbooks/borken/templates/default/borken.erb
33
- - spec/data/cookbooks/chefignore
34
- - spec/data/cookbooks/java/files/default/java.response
35
- - spec/data/cookbooks/openldap/attributes/default.rb
36
- - spec/data/cookbooks/openldap/attributes/smokey.rb
37
- - spec/data/cookbooks/openldap/definitions/client.rb
38
- - spec/data/cookbooks/openldap/definitions/server.rb
39
- - spec/data/cookbooks/openldap/files/default/.dotfile
40
- - spec/data/cookbooks/openldap/files/default/.ssh/id_rsa
41
- - spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir
42
- - spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file1.txt
43
- - spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file2.txt
44
- - spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile
45
- - spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file1.txt
46
- - spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file2.txt
47
- - spec/data/cookbooks/openldap/files/default/remotedir/subdir_with_no_file_just_a_subsubdir/the_subsubdir/some_file.txt
48
- - spec/data/cookbooks/openldap/recipes/default.rb
49
- - spec/data/cookbooks/openldap/recipes/gigantor.rb
50
- - spec/data/cookbooks/openldap/recipes/one.rb
51
- - spec/data/cookbooks/openldap/templates/default/openldap_stuff.conf.erb
52
- - spec/data/cookbooks/openldap/templates/default/openldap_variable_stuff.conf.erb
53
- - spec/data/cookbooks/openldap/templates/default/test.erb
33
+ - spec/data/cookbooks/rewind/Berksfile
34
+ - spec/data/cookbooks/rewind/README.md
35
+ - spec/data/cookbooks/rewind/files/default/test/default_test.rb
36
+ - spec/data/cookbooks/rewind/metadata.rb
37
+ - spec/data/cookbooks/rewind/recipes/base.rb
38
+ - spec/data/cookbooks/rewind/recipes/default.rb
54
39
  - spec/rewind_recipe_spec.rb
55
40
  - spec/rewind_resource_spec.rb
56
41
  - spec/spec_helper.rb
57
42
  - spec/support/chef_helpers.rb
58
43
  - spec/support/lib/chef/provider/cat.rb
59
- - spec/support/lib/chef/provider/easy.rb
60
- - spec/support/lib/chef/provider/snakeoil.rb
61
44
  - spec/support/lib/chef/provider/zen_master.rb
62
45
  - spec/support/lib/chef/resource/cat.rb
63
- - spec/support/lib/chef/resource/one_two_three_four.rb
64
46
  - spec/support/lib/chef/resource/zen_master.rb
65
- - spec/support/matchers/leak.rb
66
- - spec/support/mock/constant.rb
67
- - spec/support/mock/platform.rb
68
- - spec/support/platform_helpers.rb
69
- - spec/support/platforms/prof/gc.rb
70
- - spec/support/platforms/prof/win32.rb
71
- - spec/support/shared/functional/directory_resource.rb
72
- - spec/support/shared/functional/file_resource.rb
73
- - spec/support/shared/functional/knife.rb
74
- - spec/support/shared/functional/securable_resource.rb
75
- - spec/support/shared/unit/api_error_inspector.rb
76
- - spec/support/shared/unit/platform_introspector.rb
77
47
  - spec/unwind_recipe_spec.rb
78
48
  homepage: ''
79
49
  licenses: []
@@ -84,69 +54,33 @@ require_paths:
84
54
  - lib
85
55
  required_ruby_version: !ruby/object:Gem::Requirement
86
56
  requirements:
87
- - - '>='
57
+ - - ">="
88
58
  - !ruby/object:Gem::Version
89
59
  version: '0'
90
60
  required_rubygems_version: !ruby/object:Gem::Requirement
91
61
  requirements:
92
- - - '>='
62
+ - - ">="
93
63
  - !ruby/object:Gem::Version
94
64
  version: '0'
95
65
  requirements: []
96
66
  rubyforge_project:
97
- rubygems_version: 2.0.14
67
+ rubygems_version: 2.2.2
98
68
  signing_key:
99
69
  specification_version: 4
100
70
  summary: Monkey patches Chef to allow rewinding and unwinding of existing resources
101
71
  test_files:
102
- - spec/data/cookbooks/angrybash/recipes/default.rb
103
- - spec/data/cookbooks/apache2/files/default/apache2_module_conf_generate.pl
104
- - spec/data/cookbooks/apache2/recipes/default.rb
105
- - spec/data/cookbooks/borken/recipes/default.rb
106
- - spec/data/cookbooks/borken/templates/default/borken.erb
107
- - spec/data/cookbooks/chefignore
108
- - spec/data/cookbooks/java/files/default/java.response
109
- - spec/data/cookbooks/openldap/attributes/default.rb
110
- - spec/data/cookbooks/openldap/attributes/smokey.rb
111
- - spec/data/cookbooks/openldap/definitions/client.rb
112
- - spec/data/cookbooks/openldap/definitions/server.rb
113
- - spec/data/cookbooks/openldap/files/default/.dotfile
114
- - spec/data/cookbooks/openldap/files/default/.ssh/id_rsa
115
- - spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir
116
- - spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file1.txt
117
- - spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file2.txt
118
- - spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile
119
- - spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file1.txt
120
- - spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file2.txt
121
- - spec/data/cookbooks/openldap/files/default/remotedir/subdir_with_no_file_just_a_subsubdir/the_subsubdir/some_file.txt
122
- - spec/data/cookbooks/openldap/recipes/default.rb
123
- - spec/data/cookbooks/openldap/recipes/gigantor.rb
124
- - spec/data/cookbooks/openldap/recipes/one.rb
125
- - spec/data/cookbooks/openldap/templates/default/openldap_stuff.conf.erb
126
- - spec/data/cookbooks/openldap/templates/default/openldap_variable_stuff.conf.erb
127
- - spec/data/cookbooks/openldap/templates/default/test.erb
72
+ - spec/data/cookbooks/rewind/Berksfile
73
+ - spec/data/cookbooks/rewind/README.md
74
+ - spec/data/cookbooks/rewind/files/default/test/default_test.rb
75
+ - spec/data/cookbooks/rewind/metadata.rb
76
+ - spec/data/cookbooks/rewind/recipes/base.rb
77
+ - spec/data/cookbooks/rewind/recipes/default.rb
128
78
  - spec/rewind_recipe_spec.rb
129
79
  - spec/rewind_resource_spec.rb
130
80
  - spec/spec_helper.rb
131
81
  - spec/support/chef_helpers.rb
132
82
  - spec/support/lib/chef/provider/cat.rb
133
- - spec/support/lib/chef/provider/easy.rb
134
- - spec/support/lib/chef/provider/snakeoil.rb
135
83
  - spec/support/lib/chef/provider/zen_master.rb
136
84
  - spec/support/lib/chef/resource/cat.rb
137
- - spec/support/lib/chef/resource/one_two_three_four.rb
138
85
  - spec/support/lib/chef/resource/zen_master.rb
139
- - spec/support/matchers/leak.rb
140
- - spec/support/mock/constant.rb
141
- - spec/support/mock/platform.rb
142
- - spec/support/platform_helpers.rb
143
- - spec/support/platforms/prof/gc.rb
144
- - spec/support/platforms/prof/win32.rb
145
- - spec/support/shared/functional/directory_resource.rb
146
- - spec/support/shared/functional/file_resource.rb
147
- - spec/support/shared/functional/knife.rb
148
- - spec/support/shared/functional/securable_resource.rb
149
- - spec/support/shared/unit/api_error_inspector.rb
150
- - spec/support/shared/unit/platform_introspector.rb
151
86
  - spec/unwind_recipe_spec.rb
152
- has_rdoc:
@@ -1,8 +0,0 @@
1
- bash "go off the rails" do
2
- code <<-END
3
- for i in localhost 127.0.0.1 #{Socket.gethostname()}
4
- do
5
- echo "grant all on *.* to root@'$i' identified by 'a_password'; flush privileges;" | mysql -u root -h 127.0.0.1
6
- done
7
- END
8
- end
@@ -1,2 +0,0 @@
1
- # apache2_module_conf_generate.pl
2
- # this is just here for show.
@@ -1,3 +0,0 @@
1
- #
2
- # Nothing ot see here
3
- #
@@ -1,2 +0,0 @@
1
- a cat walked on the keyboard one day...
2
- (*&(*&(*&(*&(*^%$%^%#^^&(*)(*{}}}}}}}}+++++===))))))
@@ -1,2 +0,0 @@
1
- a cat walked on the keyboard one day...
2
- <%= (*&)(*^^^^*******++_+_--- }}}}]]]end)%>
@@ -1,6 +0,0 @@
1
- #
2
- # The ignore file allows you to skip files in cookbooks with the same name that appear
3
- # later in the search path.
4
- #
5
-
6
- recipes/ignoreme.rb
@@ -1,2 +0,0 @@
1
- # Hi, I'm pretending to be the preseed file for installing the Sun JDK on debian
2
- # or Ubuntu
@@ -1,16 +0,0 @@
1
- chef_env ||= nil
2
- case chef_env
3
- when "prod"
4
- default[:ldap_server] = "ops1prod"
5
- default[:ldap_basedn] = "dc=hjksolutions,dc=com"
6
- default[:ldap_replication_password] = "yes"
7
- when "corp"
8
- default[:ldap_server] = "ops1prod"
9
- default[:ldap_basedn] = "dc=hjksolutions,dc=com"
10
- default[:ldap_replication_password] = "yougotit"
11
- else
12
-
13
- default[:ldap_server] = "ops1prod"
14
- default[:ldap_basedn] = "dc=hjksolutions,dc=com"
15
- default[:ldap_replication_password] = "forsure"
16
- end
@@ -1 +0,0 @@
1
- default[:smokey] = "robinson"
@@ -1,5 +0,0 @@
1
- define :openldap_client, :mothra => "a big monster" do
2
- cat "#{params[:name]}" do
3
- pretty_kitty true
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- define :openldap_server, :mothra => "a big monster" do
2
- cat "#{params[:name]}" do
3
- pretty_kitty true
4
- end
5
- end
@@ -1 +0,0 @@
1
- I am here to test .dotfiles work in file directories.
@@ -1,3 +0,0 @@
1
- # remote directory
2
- # file specificity: default
3
- # relpath: remotedir/remote_dir_file1.txt
@@ -1,3 +0,0 @@
1
- # remote directory
2
- # file specificity: default
3
- # relpath: remotedir/remote_dir_file2.txt
@@ -1 +0,0 @@
1
- this is a file with a name beginning with a . dot
@@ -1,3 +0,0 @@
1
- # remote directory
2
- # file specificity: default
3
- # relpath: remotedir/remotesubdir/remote_dir_file1.txt
@@ -1,3 +0,0 @@
1
- # remote directory
2
- # file specificity: default
3
- # relpath: remotedir/remotesubdir/remote_dir_file2.txt
@@ -1,3 +0,0 @@
1
- # remote directory
2
- # file specificity: default
3
- # relpath: remotedir/subdir_with_no_file_just_a_subsubdir/the_subsubdir/some_file.txt
@@ -1,3 +0,0 @@
1
- cat "blanket" do
2
- pretty_kitty true
3
- end
@@ -1,3 +0,0 @@
1
- cat "blanket" do
2
- pretty_kitty false
3
- end
@@ -1,15 +0,0 @@
1
- ##
2
- # Nodes should have a unique name
3
- ##
4
- name "test.example.com-default"
5
-
6
- ##
7
- # Nodes can set arbitrary arguments
8
- ##
9
- sunshine "in"
10
- something "else"
11
-
12
- ##
13
- # Nodes should have recipes
14
- ##
15
- recipes "operations-master", "operations-monitoring"
@@ -1 +0,0 @@
1
- slappiness is <%= node[:slappiness] -%>
@@ -1 +0,0 @@
1
- We could be diving for pearls!
@@ -1,35 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- class Chef
20
- class Provider
21
- class Easy < Chef::Provider
22
- def load_current_resource
23
- true
24
- end
25
-
26
- def action_sell
27
- true
28
- end
29
-
30
- def action_buy
31
- true
32
- end
33
- end
34
- end
35
- end
@@ -1,40 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- class Chef
20
- class Provider
21
- class SnakeOil < Chef::Provider
22
- def load_current_resource
23
- true
24
- end
25
-
26
- def action_purr
27
- @new_resource.updated_by_last_action(true)
28
- true
29
- end
30
-
31
- def action_sell
32
- true
33
- end
34
-
35
- def action_buy
36
- true
37
- end
38
- end
39
- end
40
- end