compat_resource 12.5.9 → 12.5.10
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 +4 -4
- data/README.md +40 -1
- data/files/lib/chef_compat/monkeypatches/chef/provider.rb +17 -0
- data/files/lib/chef_compat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa16b436f408af71be67cea805e6efe50489f91
|
4
|
+
data.tar.gz: d9d1497a1f8053979e585cd1058b7d536dc93e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f29ddaf1dfee4d494888d4afd987696ecb393bd18d371049e71ae1b398292da6708c49d41b9a35e6084b2b734d6fff44c996393755cbe0dca90c1a2563262ec5
|
7
|
+
data.tar.gz: f4747ca15c2b9ff2ca15e867f61168974657df45af2b2c7b625f90b70904e657e35d2746aeab9bf215ad776c9bbd515f67cf875d00f7e1c53e61a3b8e3a9d0a9
|
data/README.md
CHANGED
@@ -6,6 +6,45 @@
|
|
6
6
|
|
7
7
|
This cookbook brings the custom resource syntax from Chef 12.5 to earlier Chef 12.X releases.
|
8
8
|
|
9
|
+
## Converting cookbooks from the old resource model to the new
|
10
|
+
|
11
|
+
### Boilerplate
|
12
|
+
|
13
|
+
1. Depend on compat_resource
|
14
|
+
- Descend resources from ChefCompat::Resource
|
15
|
+
- Set resource_name in the class instead of the constructor
|
16
|
+
2. Convert Attributes to Properties
|
17
|
+
- Rename attribute -> property
|
18
|
+
- Move set_or_return -> property
|
19
|
+
- Take kind_of/equal_to/regexes and make them types
|
20
|
+
- Use true/false/nil instead of TrueClass/FalseClass/NilClass
|
21
|
+
- Remove default: nil (it's the default)
|
22
|
+
3. Convert Top-Level Providers to Actions
|
23
|
+
- Create any resources that don't already exist (for example in
|
24
|
+
multi-provider cases) and descend from the base resource
|
25
|
+
- Remove allowed_actions / @actions
|
26
|
+
- @action -> default_action
|
27
|
+
- Move `provides` and `action :x` to the resource
|
28
|
+
- Remove use_inline_resources and def whyrun_safe?
|
29
|
+
- Move other methods to `action_class.class_eval do`
|
30
|
+
|
31
|
+
Now you have everything in a resource, are using properties, and have gotten rid
|
32
|
+
of a bunch of boilerplate. Of course, this is just getting it *moved*. Now you
|
33
|
+
can start to really use the new features. And if you're making resources for
|
34
|
+
the first time, congrats--you probably didn't have to do very much of this :)
|
35
|
+
|
36
|
+
### Advanced Concepts
|
37
|
+
|
38
|
+
1. Resource Inheritance
|
39
|
+
2. Resources That Are Different On Each OS?
|
40
|
+
3. Coercion: Handling User Input
|
41
|
+
4. Lazy Defaults
|
42
|
+
5. Using Load Current Resource
|
43
|
+
6. Using Converge If Changed
|
44
|
+
7. Defaults Are For Creation
|
45
|
+
8. Shared types: using a type multiple places
|
46
|
+
|
47
|
+
|
9
48
|
|
10
49
|
Requirements
|
11
50
|
------------
|
@@ -49,4 +88,4 @@ Unless required by applicable law or agreed to in writing, software
|
|
49
88
|
distributed under the License is distributed on an "AS IS" BASIS,
|
50
89
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
51
90
|
See the License for the specific language governing permissions and
|
52
|
-
limitations under the License.
|
91
|
+
limitations under the License.
|
@@ -14,5 +14,22 @@ class Chef::Provider
|
|
14
14
|
include Chef::DSL::PlatformIntrospection
|
15
15
|
include Chef::DSL::DataQuery
|
16
16
|
include Chef::DSL::IncludeRecipe
|
17
|
+
|
18
|
+
module ::ChefCompat
|
19
|
+
module Monkeypatches
|
20
|
+
module InlineResources
|
21
|
+
module ClassMethods
|
22
|
+
def action(name, &block)
|
23
|
+
super(name) { send("compile_action_#{name}") }
|
24
|
+
# We put the action in its own method so that super() works.
|
25
|
+
define_method("compile_action_#{name}", &block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
module ClassMethods
|
32
|
+
prepend ChefCompat::Monkeypatches::InlineResources::ClassMethods
|
33
|
+
end
|
17
34
|
end
|
18
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compat_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.5.
|
4
|
+
version: 12.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|