summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-02-27 15:55:17 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2020-02-27 15:55:17 -0800
commit19473cf4773455aef58362334a7636bbc0fd0975 (patch)
tree61d7a5723ac22b55d3dcc95bcb3ee086937473b4
parent36a727691ea93d1f5fe8cf267fae5dd92516a9f0 (diff)
downloadchef-19473cf4773455aef58362334a7636bbc0fd0975.tar.gz
Remove the "Core" DSL for Chef-16
This lets us avoid using declare_resource in old style core resources. As everything gets converted over to custom resources this is going away anyway. We haven't seen any issues from using the recipe DSL in custom resources in core. Clearly this is potentially breaking since any references to Chef::DSL::Core need to be changed to Chef::DSL::Recipe (although I'm not sure who would have done that other than maybe us somewhere, I had a note in there that nobody should probably touch the Core DSL). This greatly simplifies the major DSLs down to two: Recipe DSL - things that only make sense in a context where there is a resource_collection Universal DSL - things that apply everywhere Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/dsl/core.rb52
-rw-r--r--lib/chef/dsl/recipe.rb21
-rw-r--r--lib/chef/dsl/universal.rb10
-rw-r--r--lib/chef/provider.rb5
-rw-r--r--lib/chef/resource/action_class.rb4
5 files changed, 13 insertions, 79 deletions
diff --git a/lib/chef/dsl/core.rb b/lib/chef/dsl/core.rb
deleted file mode 100644
index f564dd0418..0000000000
--- a/lib/chef/dsl/core.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-#--
-# Author:: Adam Jacob (<adam@chef.io>)
-# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2008-2019, Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require_relative "declare_resource"
-require_relative "universal"
-require_relative "../mixin/notifying_block"
-require_relative "../mixin/lazy_module_include"
-
-class Chef
- module DSL
- # Part of a family of DSL mixins.
- #
- # Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
- # - this does not target core chef resources and providers.
- # - this is restricted to recipe/resource/provider context where a resource collection exists.
- # - cookbook authors should typically include modules into here.
- #
- # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
- # - this adds cores providers on top of the Recipe DSL.
- # - this is restricted to recipe/resource/provider context where a resource collection exists.
- # - core chef authors should typically include modules into here.
- #
- # Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
- # - this adds resources and attributes files.
- # - do not add helpers which manipulate the resource collection.
- # - this is for general-purpose stuff that is useful nearly everywhere.
- # - it also pollutes the namespace of nearly every context, watch out.
- #
- module Core
- include Chef::DSL::Universal
- include Chef::DSL::DeclareResource
- include Chef::Mixin::NotifyingBlock
- extend Chef::Mixin::LazyModuleInclude
- end
- end
-end
diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb
index 1d02d9c03e..647ae4feb9 100644
--- a/lib/chef/dsl/recipe.rb
+++ b/lib/chef/dsl/recipe.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2008-2019, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,23 +22,19 @@ require_relative "resources"
require_relative "definitions"
require_relative "include_recipe"
require_relative "reboot_pending"
-require_relative "core"
+require_relative "universal"
+require_relative "declare_resource"
+require_relative "../mixin/notifying_block"
require_relative "../mixin/lazy_module_include"
class Chef
module DSL
# Part of a family of DSL mixins.
#
- # Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
- # - this does not target core chef resources and providers.
+ # Chef::DSL::Recipe mixes into Recipes and Providers.
# - this is restricted to recipe/resource/provider context where a resource collection exists.
# - cookbook authors should typically include modules into here.
#
- # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
- # - this adds cores providers on top of the Recipe DSL.
- # - this is restricted to recipe/resource/provider context where a resource collection exists.
- # - core chef authors should typically include modules into here.
- #
# Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
# - this adds resources and attributes files.
# - do not add helpers which manipulate the resource collection.
@@ -46,7 +42,9 @@ class Chef
# - it also pollutes the namespace of nearly every context, watch out.
#
module Recipe
- include Chef::DSL::Core
+ include Chef::DSL::Universal
+ include Chef::DSL::DeclareResource
+ include Chef::Mixin::NotifyingBlock
include Chef::DSL::IncludeRecipe
include Chef::DSL::RebootPending
include Chef::DSL::Resources
@@ -69,6 +67,3 @@ class Chef
end
end
end
-
-# Avoid circular references for things that are only used in instance methods
-require_relative "../resource"
diff --git a/lib/chef/dsl/universal.rb b/lib/chef/dsl/universal.rb
index c9afa38f98..fe276de5a6 100644
--- a/lib/chef/dsl/universal.rb
+++ b/lib/chef/dsl/universal.rb
@@ -1,7 +1,7 @@
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2008-2019, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,16 +30,10 @@ class Chef
module DSL
# Part of a family of DSL mixins.
#
- # Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
- # - this does not target core chef resources and providers.
+ # Chef::DSL::Recipe mixes into Recipes and Providers.
# - this is restricted to recipe/resource/provider context where a resource collection exists.
# - cookbook authors should typically include modules into here.
#
- # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
- # - this adds cores providers on top of the Recipe DSL.
- # - this is restricted to recipe/resource/provider context where a resource collection exists.
- # - core chef authors should typically include modules into here.
- #
# Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
# - this adds resources and attributes files.
# - do not add helpers which manipulate the resource collection.
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 3fa097ce38..06e0341089 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -23,7 +23,7 @@ require_relative "mixin/enforce_ownership_and_permissions"
require_relative "mixin/why_run"
require_relative "mixin/shell_out"
require_relative "mixin/provides"
-require_relative "dsl/core"
+require_relative "dsl/recipe"
require_relative "platform/service_helpers"
require_relative "node_map"
require "forwardable" unless defined?(Forwardable)
@@ -44,8 +44,7 @@ class Chef
extend Chef::Mixin::Provides
extend Forwardable
- # includes the "core" DSL and not the "recipe" DSL by design
- include Chef::DSL::Core
+ include Chef::DSL::Recipe
# the class only gets the Universal DSL (no resource_collection at class parsing time)
extend Chef::DSL::Universal
diff --git a/lib/chef/resource/action_class.rb b/lib/chef/resource/action_class.rb
index 5e9e26b02d..7aafceaca7 100644
--- a/lib/chef/resource/action_class.rb
+++ b/lib/chef/resource/action_class.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io)
-# Copyright:: Copyright 2015-2019, Chef Software Inc.
+# Copyright:: Copyright 2015-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,6 @@ require_relative "../dsl/recipe"
class Chef
class Resource
class ActionClass < Chef::Provider
- include Chef::DSL::Recipe
-
def to_s
"#{new_resource || "<no resource>"} action #{action ? action.inspect : "<no action>"}"
end