chef-rewind 0.0.7 → 0.0.8
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.
- checksums.yaml +7 -0
- data/CHANGELOG +21 -18
- data/chef-rewind.gemspec +1 -1
- data/lib/chef/rewind.rb +6 -0
- data/spec/support/lib/chef/provider/cat.rb +21 -0
- data/spec/support/lib/chef/provider/zen_master.rb +13 -0
- data/spec/support/lib/chef/resource/cat.rb +2 -4
- data/spec/support/lib/chef/resource/zen_master.rb +6 -0
- data/spec/unwind_recipe_spec.rb +30 -3
- metadata +11 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cefbbaa69a7831ac60f9c606e878059e7f2608dc
|
4
|
+
data.tar.gz: 2a4f1030ac29fac1a99648ba1adb0b6cb29ec53e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5054f2756825cb8eb289b35d93b1759699dfb801797eba165de52ce56e6955ce2394d26b9c5094c00e24090af6f15698d3c15cb56242ac65a40a6f022650cf7
|
7
|
+
data.tar.gz: 4e60f6920312e2e226fbfd52c8860b06504cf82155f207ad762bdbb2cca8ba70db5432f6e1e698fb964707edb287b60e751ca51f2d77cd22adc5fd1153793097
|
data/CHANGELOG
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
Merge pull request #13 from yipit-cookbooks/bugfix-unwind
|
2
|
+
bump version for release
|
3
|
+
Merge pull request #12 from yipit-cookbooks/unwind
|
4
|
+
bump version for 0.0.6 release
|
5
|
+
Merge pull request #7 from pdf/rubygems_deprecation
|
6
|
+
Merge pull request #8 from pdf/chef_11_compat
|
7
|
+
Merge pull request #9 from pdf/rewind_recipe_name
|
8
|
+
Merge pull request #4 from aabes/master
|
9
|
+
now with rspec tests using chef's spec_helper
|
10
|
+
rename to chef-rewind
|
11
|
+
use set_and_return for Chef::Resource.cookbook_name
|
12
|
+
update readme
|
13
|
+
revert earlier commit that sets cookbook_name
|
14
|
+
update readme
|
15
|
+
set cookbook_name to current cookbook at time of editing
|
16
|
+
Merge pull request #1 from nathenharvey/patch-1
|
17
|
+
don't create nonexistent resources
|
18
|
+
add note that need `chef_gem` to install it
|
19
|
+
update readme
|
20
|
+
set version #
|
21
|
+
initial commit
|
data/chef-rewind.gemspec
CHANGED
data/lib/chef/rewind.rb
CHANGED
@@ -72,7 +72,13 @@ class Chef
|
|
72
72
|
|
73
73
|
# assumes `resource_id` is the same as `Chef::Resource#to_s`
|
74
74
|
@resources.delete_if {|r| r.to_s == resource_id }
|
75
|
+
resource_index_value = @resources_by_name[resource_id]
|
76
|
+
@resources_by_name.each do |k, v|
|
77
|
+
@resources_by_name[k] = v - 1 if v > resource_index_value
|
78
|
+
end
|
79
|
+
|
75
80
|
@resources_by_name.delete resource_id
|
81
|
+
|
76
82
|
end
|
77
83
|
end
|
78
84
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Chef
|
2
|
+
class Provider
|
3
|
+
class Cat < Chef::Provider
|
4
|
+
class CatError < RuntimeError
|
5
|
+
end
|
6
|
+
|
7
|
+
def load_current_resource
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def action_sell
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def action_blowup
|
16
|
+
raise CatError, "CAT BLOWUP"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -19,13 +19,11 @@
|
|
19
19
|
class Chef
|
20
20
|
class Resource
|
21
21
|
class Cat < Chef::Resource
|
22
|
-
|
23
|
-
attr_accessor :action
|
24
|
-
|
25
22
|
def initialize(name, run_context=nil)
|
26
23
|
@resource_name = :cat
|
27
24
|
super
|
28
|
-
@action =
|
25
|
+
@action = :nothing
|
26
|
+
@allowed_actions = [:nothing, :sell, :blowup]
|
29
27
|
end
|
30
28
|
|
31
29
|
def pretty_kitty(arg=nil)
|
@@ -27,12 +27,18 @@ class Chef
|
|
27
27
|
def initialize(name, run_context=nil)
|
28
28
|
@resource_name = :zen_master
|
29
29
|
super
|
30
|
+
@action = :nothing
|
31
|
+
@allowed_actions = [:change, :nothing]
|
30
32
|
end
|
31
33
|
|
32
34
|
def peace(tf)
|
33
35
|
@peace = tf
|
34
36
|
end
|
35
37
|
|
38
|
+
def updated_by_last_action?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
36
42
|
def something(arg=nil)
|
37
43
|
set_if_args(@something, arg) do
|
38
44
|
case arg
|
data/spec/unwind_recipe_spec.rb
CHANGED
@@ -2,17 +2,21 @@ require 'spec_helper'
|
|
2
2
|
require 'chef/rewind'
|
3
3
|
|
4
4
|
describe Chef::Recipe do
|
5
|
-
|
5
|
+
|
6
6
|
before(:each) do
|
7
7
|
@cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
|
8
8
|
cl = Chef::CookbookLoader.new(@cookbook_repo)
|
9
9
|
cl.load_cookbooks
|
10
10
|
@cookbook_collection = Chef::CookbookCollection.new(cl)
|
11
11
|
@node = Chef::Node.new
|
12
|
+
@node.name "latte"
|
13
|
+
@node.automatic[:platform] = "mac_os_x"
|
14
|
+
@node.automatic[:platform_version] = "10.5.1"
|
12
15
|
@node.normal[:tags] = Array.new
|
13
16
|
@events = Chef::EventDispatch::Dispatcher.new
|
14
17
|
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
|
15
18
|
@recipe = Chef::Recipe.new("hjk", "test", @run_context)
|
19
|
+
@runner = Chef::Runner.new(@run_context)
|
16
20
|
end
|
17
21
|
|
18
22
|
|
@@ -21,15 +25,38 @@ describe Chef::Recipe do
|
|
21
25
|
@recipe.zen_master "foobar" do
|
22
26
|
peace false
|
23
27
|
end
|
24
|
-
|
28
|
+
|
25
29
|
@recipe.unwind "zen_master[foobar]"
|
26
30
|
|
27
31
|
resources = @run_context.resource_collection.all_resources
|
28
32
|
resources.length.should == 0
|
29
33
|
end
|
30
34
|
|
35
|
+
it "should define resource completely when unwind is called" do
|
36
|
+
@recipe.zen_master "foo" do
|
37
|
+
action :nothing
|
38
|
+
peace false
|
39
|
+
end
|
40
|
+
@recipe.cat "blanket" do
|
41
|
+
end
|
42
|
+
@recipe.zen_master "bar" do
|
43
|
+
action :nothing
|
44
|
+
peace false
|
45
|
+
end
|
46
|
+
|
47
|
+
@recipe.unwind "zen_master[foo]"
|
48
|
+
|
49
|
+
@recipe.zen_master "foobar" do
|
50
|
+
peace true
|
51
|
+
action :change
|
52
|
+
notifies :blowup, "cat[blanket]"
|
53
|
+
end
|
54
|
+
|
55
|
+
lambda { @runner.converge }.should raise_error(Chef::Provider::Cat::CatError)
|
56
|
+
end
|
57
|
+
|
31
58
|
it "should throw an error when unwinding a nonexistent resource" do
|
32
|
-
lambda do
|
59
|
+
lambda do
|
33
60
|
@recipe.unwind "zen_master[foobar]"
|
34
61
|
end.should raise_error(Chef::Exceptions::ResourceNotFound)
|
35
62
|
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-rewind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bryan Berry
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Monkey patches Chef to allow rewinding and unwinding of existing resources
|
15
14
|
email:
|
@@ -56,8 +55,10 @@ files:
|
|
56
55
|
- spec/rewind_resource_spec.rb
|
57
56
|
- spec/spec_helper.rb
|
58
57
|
- spec/support/chef_helpers.rb
|
58
|
+
- spec/support/lib/chef/provider/cat.rb
|
59
59
|
- spec/support/lib/chef/provider/easy.rb
|
60
60
|
- spec/support/lib/chef/provider/snakeoil.rb
|
61
|
+
- spec/support/lib/chef/provider/zen_master.rb
|
61
62
|
- spec/support/lib/chef/resource/cat.rb
|
62
63
|
- spec/support/lib/chef/resource/one_two_three_four.rb
|
63
64
|
- spec/support/lib/chef/resource/zen_master.rb
|
@@ -76,27 +77,26 @@ files:
|
|
76
77
|
- spec/unwind_recipe_spec.rb
|
77
78
|
homepage: ''
|
78
79
|
licenses: []
|
80
|
+
metadata: {}
|
79
81
|
post_install_message:
|
80
82
|
rdoc_options: []
|
81
83
|
require_paths:
|
82
84
|
- lib
|
83
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
86
|
requirements:
|
86
|
-
- -
|
87
|
+
- - '>='
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - '>='
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version:
|
97
|
+
rubygems_version: 2.0.14
|
98
98
|
signing_key:
|
99
|
-
specification_version:
|
99
|
+
specification_version: 4
|
100
100
|
summary: Monkey patches Chef to allow rewinding and unwinding of existing resources
|
101
101
|
test_files:
|
102
102
|
- spec/data/cookbooks/angrybash/recipes/default.rb
|
@@ -129,8 +129,10 @@ test_files:
|
|
129
129
|
- spec/rewind_resource_spec.rb
|
130
130
|
- spec/spec_helper.rb
|
131
131
|
- spec/support/chef_helpers.rb
|
132
|
+
- spec/support/lib/chef/provider/cat.rb
|
132
133
|
- spec/support/lib/chef/provider/easy.rb
|
133
134
|
- spec/support/lib/chef/provider/snakeoil.rb
|
135
|
+
- spec/support/lib/chef/provider/zen_master.rb
|
134
136
|
- spec/support/lib/chef/resource/cat.rb
|
135
137
|
- spec/support/lib/chef/resource/one_two_three_four.rb
|
136
138
|
- spec/support/lib/chef/resource/zen_master.rb
|