diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-05-16 18:41:36 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-05-16 18:41:36 -0700 |
commit | ec712ea75bbfe1a829c0148b45cfd130aa22f715 (patch) | |
tree | dab79bb8a13de9e0bdb9ea62b7015c3560634035 /lib/chef/dsl | |
parent | 97f2ea97a4a4fd86d667a21cdfed790c820afe61 (diff) | |
download | chef-ec712ea75bbfe1a829c0148b45cfd130aa22f715.tar.gz |
create 'universal' DSL
this is for DSL methods that get mixed in everywhere.
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r-- | lib/chef/dsl/core.rb | 29 | ||||
-rw-r--r-- | lib/chef/dsl/recipe.rb | 23 | ||||
-rw-r--r-- | lib/chef/dsl/universal.rb | 49 |
3 files changed, 81 insertions, 20 deletions
diff --git a/lib/chef/dsl/core.rb b/lib/chef/dsl/core.rb index c2dbea7628..64439943ba 100644 --- a/lib/chef/dsl/core.rb +++ b/lib/chef/dsl/core.rb @@ -18,27 +18,34 @@ # require "chef/dsl/declare_resource" +require "chef/dsl/universal" require "chef/mixin/notifying_block" -require "chef/mixin/powershell_out" -require "chef/mixin/shell_out" +require "chef/mixin/lazy_module_include" class Chef module DSL - # This is the "Core DSL" with various bits of Sugar that are mixed into core providers as well - # as user LWRPs. This module deliberately does not mixin the Resources or Defintions DSL bits - # so that cookbooks are not injeting random things into the namespace of core providers. + # Part of a family of DSL mixins. # - # - If you are writing cookbooks: you have come to the wrong place, please inject things into - # Chef::DSL::Recipe instead. + # 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. # - # - If you are writing core chef: you have come to the right place, please drop your DSL modules - # into here. + # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers + # - this adds cores providers on top of the Recipe DSL. + # - 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 - include Chef::Mixin::PowershellOut - include Chef::Mixin::ShellOut + extend Chef::Mixin::LazyModuleInclude end end end diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb index c8b1aed74d..eb828f4e95 100644 --- a/lib/chef/dsl/recipe.rb +++ b/lib/chef/dsl/recipe.rb @@ -21,7 +21,6 @@ require "chef/exceptions" require "chef/dsl/resources" require "chef/dsl/definitions" require "chef/dsl/data_query" -require "chef/dsl/platform_introspection" require "chef/dsl/include_recipe" require "chef/dsl/registry_helper" require "chef/dsl/reboot_pending" @@ -33,20 +32,26 @@ require "chef/mixin/lazy_module_include" class Chef module DSL - # This is the "Recipe DSL" which is all the sugar, plus all the resources and definitions - # which are mixed into user LWRPs/Resources/Providers. + # Part of a family of DSL mixins. # - # - If you are writing cookbooks: you have come to the right place, please inject things - # into here if you want to make them available to all recipe and non-core provider code. + # 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. # - # - If you are writing core chef: you have likely come to the wrong place, please consider - # dropping your DSL modules into Chef::DSL::Core instead so that we can use them in core - # providers (unless they are *only* intended for recipe code). + # Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers + # - this adds cores providers on top of the Recipe DSL. + # - 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 Recipe include Chef::DSL::Core include Chef::DSL::DataQuery - include Chef::DSL::PlatformIntrospection include Chef::DSL::IncludeRecipe include Chef::DSL::RegistryHelper include Chef::DSL::RebootPending diff --git a/lib/chef/dsl/universal.rb b/lib/chef/dsl/universal.rb new file mode 100644 index 0000000000..8b4449c3cb --- /dev/null +++ b/lib/chef/dsl/universal.rb @@ -0,0 +1,49 @@ +#-- +# Author:: Adam Jacob (<adam@chef.io>) +# Author:: Christopher Walters (<cw@chef.io>) +# Copyright:: Copyright 2008-2016, 2009-2015 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 "chef/dsl/platform_instrospection" +require "chef/mixin/powershell_out" +require "chef/mixin/shell_out" + +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. + # - 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 Universal + include Chef::DSL::PlatformIntrospection + include Chef::Mixin::PowershellOut + include Chef::Mixin::ShellOut + end + end +end |