summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2021-04-26 14:31:31 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2021-04-26 14:31:31 -0700
commit6f0098fa930ee49ebc57b3d600c00bbb7586b436 (patch)
treea7cad448067dc58f4b140ed048171d78b872414a
parentb6820f343a9b1874e8e1f623493e99823bbd5723 (diff)
downloadchef-lcg/unified-mode-warn.tar.gz
Add warning for resources not running in unified_modelcg/unified-mode-warn
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/deprecated.rb4
-rw-r--r--lib/chef/resource/lwrp_base.rb4
-rw-r--r--spec/data/lwrp/resources/bar.rb2
-rw-r--r--spec/data/lwrp/resources/buck_passer.rb1
-rw-r--r--spec/data/lwrp/resources/buck_passer_2.rb1
-rw-r--r--spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb1
-rw-r--r--spec/data/lwrp/resources/foo.rb2
-rw-r--r--spec/data/lwrp/resources/inline_compiler.rb1
-rw-r--r--spec/data/lwrp/resources/monkey_name_printer.rb1
-rw-r--r--spec/data/lwrp/resources/paint_drying_watcher.rb1
-rw-r--r--spec/data/lwrp/resources/thumb_twiddler.rb1
-rw-r--r--spec/data/lwrp/resources_with_default_attributes/nodeattr.rb2
-rw-r--r--spec/data/lwrp_const_scoping/resources/conflict.rb1
-rw-r--r--spec/data/lwrp_override/resources/foo.rb1
-rw-r--r--spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb1
-rw-r--r--spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb1
-rw-r--r--spec/data/run_context/cookbooks/dependency1/resources/resource.rb1
-rw-r--r--spec/data/run_context/cookbooks/dependency2/resources/resource.rb1
-rw-r--r--spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb1
-rw-r--r--spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb2
-rw-r--r--spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb1
-rw-r--r--spec/data/run_context/cookbooks/test/resources/resource.rb2
-rw-r--r--spec/integration/recipes/accumulator_spec.rb12
-rw-r--r--spec/integration/recipes/lwrp_inline_resources_spec.rb4
-rw-r--r--spec/integration/recipes/lwrp_spec.rb2
-rw-r--r--spec/integration/recipes/notifies_spec.rb14
-rw-r--r--spec/integration/recipes/notifying_block_spec.rb1
-rw-r--r--spec/integration/recipes/use_partial_spec.rb3
-rw-r--r--spec/unit/lwrp_spec.rb2
29 files changed, 70 insertions, 1 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 992876c17d..c48566e7e4 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -249,6 +249,10 @@ class Chef
target 32
end
+ class UnifiedMode < Base
+ target 33
+ end
+
class Generic < Base
def url
"https://docs.chef.io/chef_deprecations_client/"
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index 2cf891d530..8fa23865b3 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -53,6 +53,10 @@ class Chef
resource_class.run_context = run_context
resource_class.class_from_file(filename)
+ unless resource_class.unified_mode
+ Chef.deprecated :unified_mode, "The #{resource_name} resource in the #{cookbook_name} cookbook should declare `unified_mode true`"
+ end
+
# Make a useful string for the class (rather than <Class:312894723894>)
resource_class.instance_eval do
define_singleton_method(:to_s) do
diff --git a/spec/data/lwrp/resources/bar.rb b/spec/data/lwrp/resources/bar.rb
index 2ff35efd08..d36575917d 100644
--- a/spec/data/lwrp/resources/bar.rb
+++ b/spec/data/lwrp/resources/bar.rb
@@ -1,2 +1,4 @@
+unified_mode true
+
provides :lwrp_bar # This makes sure that we cover the case of lwrps using provides
actions :pass_buck, :prepare_eyes, :watch_paint_dry
diff --git a/spec/data/lwrp/resources/buck_passer.rb b/spec/data/lwrp/resources/buck_passer.rb
index 7335c0aae2..6f542dc423 100644
--- a/spec/data/lwrp/resources/buck_passer.rb
+++ b/spec/data/lwrp/resources/buck_passer.rb
@@ -1,3 +1,4 @@
+unified_mode true
provides :buck_passer
diff --git a/spec/data/lwrp/resources/buck_passer_2.rb b/spec/data/lwrp/resources/buck_passer_2.rb
index c7a1a279f3..c0ab7d7885 100644
--- a/spec/data/lwrp/resources/buck_passer_2.rb
+++ b/spec/data/lwrp/resources/buck_passer_2.rb
@@ -1,3 +1,4 @@
+unified_mode true
default_action :pass_buck
actions :pass_buck
diff --git a/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb b/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb
index 3a8ae2c19f..faece8b582 100644
--- a/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb
+++ b/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb
@@ -1,3 +1,4 @@
+unified_mode true
default_action :twiddle_thumbs
actions :twiddle_thumbs
diff --git a/spec/data/lwrp/resources/foo.rb b/spec/data/lwrp/resources/foo.rb
index 0ee83f0cd0..d4d2155122 100644
--- a/spec/data/lwrp/resources/foo.rb
+++ b/spec/data/lwrp/resources/foo.rb
@@ -1,3 +1,5 @@
+unified_mode true
+
actions :prepare_thumbs, :twiddle_thumbs
default_action :pass_buck
diff --git a/spec/data/lwrp/resources/inline_compiler.rb b/spec/data/lwrp/resources/inline_compiler.rb
index fe446ddf84..0e63e4ce43 100644
--- a/spec/data/lwrp/resources/inline_compiler.rb
+++ b/spec/data/lwrp/resources/inline_compiler.rb
@@ -1,3 +1,4 @@
+unified_mode true
default_action :test
actions :test, :no_updates
diff --git a/spec/data/lwrp/resources/monkey_name_printer.rb b/spec/data/lwrp/resources/monkey_name_printer.rb
index d70e2f34e3..60c3203dca 100644
--- a/spec/data/lwrp/resources/monkey_name_printer.rb
+++ b/spec/data/lwrp/resources/monkey_name_printer.rb
@@ -1,3 +1,4 @@
+unified_mode true
property :monkey
diff --git a/spec/data/lwrp/resources/paint_drying_watcher.rb b/spec/data/lwrp/resources/paint_drying_watcher.rb
index 519b7f83fd..1bff7c5b50 100644
--- a/spec/data/lwrp/resources/paint_drying_watcher.rb
+++ b/spec/data/lwrp/resources/paint_drying_watcher.rb
@@ -1,3 +1,4 @@
+unified_mode true
default_action :prepare_eyes
actions :prepare_eyes, :watch_paint_dry
diff --git a/spec/data/lwrp/resources/thumb_twiddler.rb b/spec/data/lwrp/resources/thumb_twiddler.rb
index 2b5d2d803e..f4ba71cebc 100644
--- a/spec/data/lwrp/resources/thumb_twiddler.rb
+++ b/spec/data/lwrp/resources/thumb_twiddler.rb
@@ -1,3 +1,4 @@
+unified_mode true
default_action :prepare_thumbs
actions :prepare_thumbs, :twiddle_thumbs
diff --git a/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb b/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb
index dece7c4eab..ef6b694cb2 100644
--- a/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb
+++ b/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb
@@ -1 +1,3 @@
+unified_mode true
+
attribute :penguin, :kind_of => String, :default => node[:penguin_name]
diff --git a/spec/data/lwrp_const_scoping/resources/conflict.rb b/spec/data/lwrp_const_scoping/resources/conflict.rb
index e69de29bb2..059460afc0 100644
--- a/spec/data/lwrp_const_scoping/resources/conflict.rb
+++ b/spec/data/lwrp_const_scoping/resources/conflict.rb
@@ -0,0 +1 @@
+unified_mode true
diff --git a/spec/data/lwrp_override/resources/foo.rb b/spec/data/lwrp_override/resources/foo.rb
index 2fc13d32fd..1d6be84e58 100644
--- a/spec/data/lwrp_override/resources/foo.rb
+++ b/spec/data/lwrp_override/resources/foo.rb
@@ -1,4 +1,5 @@
# Starting with Chef 12 reloading an LWRP shouldn't reload the file anymore
+unified_mode true
actions :never_execute
diff --git a/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb b/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb
index aee6f4adc4..eaf68e9058 100644
--- a/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb
@@ -1 +1,2 @@
+unified_mode true
LibraryLoadOrder.record('circular-dep1-resource')
diff --git a/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb b/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb
index efd4ef3e8c..63eb08d5b5 100644
--- a/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb
@@ -1 +1,2 @@
+unified_mode true
LibraryLoadOrder.record('circular-dep2-resource')
diff --git a/spec/data/run_context/cookbooks/dependency1/resources/resource.rb b/spec/data/run_context/cookbooks/dependency1/resources/resource.rb
index 3bd0f170bc..d355f7ce48 100644
--- a/spec/data/run_context/cookbooks/dependency1/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/dependency1/resources/resource.rb
@@ -1 +1,2 @@
+unified_mode true
LibraryLoadOrder.record('dependency1-resource')
diff --git a/spec/data/run_context/cookbooks/dependency2/resources/resource.rb b/spec/data/run_context/cookbooks/dependency2/resources/resource.rb
index 73a0a34e53..5ec44d4564 100644
--- a/spec/data/run_context/cookbooks/dependency2/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/dependency2/resources/resource.rb
@@ -1 +1,2 @@
+unified_mode true
LibraryLoadOrder.record('dependency2-resource')
diff --git a/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb b/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb
index 067835e1c1..fd8fa73b5a 100644
--- a/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb
@@ -1 +1,2 @@
+unified_mode true
LibraryLoadOrder.record('no-default-attr-resource')
diff --git a/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb b/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb
index 486e81d458..ffe7d099c9 100644
--- a/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb
@@ -1 +1,3 @@
+unified_mode true
+
LibraryLoadOrder.record('test-with-circular-deps-resource')
diff --git a/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb b/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb
index 54b152dd1c..203efabec5 100644
--- a/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb
@@ -1 +1,2 @@
+unified_mode true
LibraryLoadOrder.record('test-with-deps-resource')
diff --git a/spec/data/run_context/cookbooks/test/resources/resource.rb b/spec/data/run_context/cookbooks/test/resources/resource.rb
index 67759217ca..54c99d2fb8 100644
--- a/spec/data/run_context/cookbooks/test/resources/resource.rb
+++ b/spec/data/run_context/cookbooks/test/resources/resource.rb
@@ -1 +1,3 @@
+unified_mode true
+
LibraryLoadOrder.record('test-resource')
diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb
index ba81e82cdd..4edd8d6394 100644
--- a/spec/integration/recipes/accumulator_spec.rb
+++ b/spec/integration/recipes/accumulator_spec.rb
@@ -31,6 +31,8 @@ describe "Accumulators" do
before do
directory "cookbooks/x" do
file "resources/email_alias.rb", <<-EOM
+ unified_mode true
+
provides :email_alias
resource_name :email_alias
@@ -54,6 +56,8 @@ describe "Accumulators" do
EOM
file "resources/nested.rb", <<-EOM
+ unified_mode true
+
provides :nested
resource_name :nested
@@ -70,6 +74,8 @@ describe "Accumulators" do
EOM
file "resources/doubly_nested.rb", <<-EOM
+ unified_mode true
+
provides :doubly_nested
resource_name :doubly_nested
@@ -133,6 +139,8 @@ describe "Accumulators" do
before do
directory "cookbooks/x" do
file "resources/email_alias.rb", <<-EOM
+ unified_mode true
+
provides :email_alias
resource_name :email_alias
@@ -156,6 +164,8 @@ describe "Accumulators" do
EOM
file "resources/nested.rb", <<-EOM
+ unified_mode true
+
provides :nested
resource_name :nested
@@ -172,6 +182,8 @@ describe "Accumulators" do
EOM
file "resources/doubly_nested.rb", <<-EOM
+ unified_mode true
+
provides :doubly_nested
resource_name :doubly_nested
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb
index e5cfb284aa..5cfbe6ea5d 100644
--- a/spec/integration/recipes/lwrp_inline_resources_spec.rb
+++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb
@@ -118,6 +118,8 @@ describe "LWRPs with inline resources" do
directory "cookbooks/x" do
file "resources/do_nothing.rb", <<-EOM
+ unified_mode true
+
actions :create, :nothing
default_action :create
EOM
@@ -127,6 +129,8 @@ describe "LWRPs with inline resources" do
EOM
file "resources/my_machine.rb", <<-EOM
+ unified_mode true
+
actions :create, :nothing
default_action :create
EOM
diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb
index 060b08ec4a..e9299b9018 100644
--- a/spec/integration/recipes/lwrp_spec.rb
+++ b/spec/integration/recipes/lwrp_spec.rb
@@ -24,6 +24,8 @@ describe "LWRPs" do
directory "cookbooks/l-w-r-p" do
file "resources/foo.rb", <<~EOM
+ unified_mode true
+
default_action :create
EOM
file "providers/foo.rb", <<~EOM
diff --git a/spec/integration/recipes/notifies_spec.rb b/spec/integration/recipes/notifies_spec.rb
index 725849b4a4..c44e014028 100644
--- a/spec/integration/recipes/notifies_spec.rb
+++ b/spec/integration/recipes/notifies_spec.rb
@@ -63,6 +63,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/notifying_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :notifying_test
resource_name :notifying_test
@@ -105,6 +107,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/notifying_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :notifying_test
resource_name :notifying_test
@@ -152,6 +156,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/notifying_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :notifying_test
resource_name :notifying_test
@@ -237,6 +243,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/notifying_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :notifying_test
resource_name :notifying_test
@@ -278,6 +286,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/notifying_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :notifying_test
resource_name :notifying_test
@@ -319,6 +329,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/notifying_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :notifying_test
resource_name :notifying_test
@@ -357,6 +369,8 @@ describe "notifications" do
directory "cookbooks/x" do
file "resources/cloning_test.rb", <<~EOM
+ unified_mode true
+
default_action :run
provides :cloning_test
resource_name :cloning_test
diff --git a/spec/integration/recipes/notifying_block_spec.rb b/spec/integration/recipes/notifying_block_spec.rb
index 4b76bc21d4..15b56c8ce2 100644
--- a/spec/integration/recipes/notifying_block_spec.rb
+++ b/spec/integration/recipes/notifying_block_spec.rb
@@ -68,6 +68,7 @@ describe "notifying_block" do
before do
directory "cookbooks/x" do
file "resources/nb_test.rb", <<-EOM
+ unified_mode true
default_action :run
provides :nb_test
resource_name :nb_test
diff --git a/spec/integration/recipes/use_partial_spec.rb b/spec/integration/recipes/use_partial_spec.rb
index 3900c75944..f1d9a8eddc 100644
--- a/spec/integration/recipes/use_partial_spec.rb
+++ b/spec/integration/recipes/use_partial_spec.rb
@@ -37,6 +37,7 @@ describe "notifying_block" do
end
EOM
file "resources/thing.rb", <<-EOM
+ unified_mode true
provides :thing
use "shared_properties"
action_class do
@@ -80,6 +81,8 @@ describe "notifying_block" do
EOM
# this tests relative pathing, including the underscore and including the trailing .rb all work
file "resources/thing.rb", <<-EOM
+ unified_mode true
+
provides :thing
use "../partials/_shared_properties.rb"
action_class do
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index ac2c95d7e7..5767e3987b 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -576,7 +576,7 @@ describe "LWRP" do
@tmpdir = File.join(@tmpparent, "lwrp")
Dir.mkdir(@tmpdir)
resource_path = File.join(@tmpdir, "once.rb")
- IO.write(resource_path, "default_action :create")
+ IO.write(resource_path, "unified_mode true\ndefault_action :create")
@test_lwrp_class = Chef::Resource::LWRPBase.build_from_file("lwrp", resource_path, nil)
end