diff options
author | Tim Smith <tsmith@chef.io> | 2019-05-06 09:51:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-06 09:51:08 -0700 |
commit | f7f2ef56bafad859771f14203c50434273e9b812 (patch) | |
tree | dd3d0a0d44b01cf0c0f0af6652e726ca98e9d9c7 | |
parent | ef089cf93b33df48e2b1aac93ad550b682aa0b1d (diff) | |
parent | a14ab197d97d3745b3ec3927423b8d2be63f3893 (diff) | |
download | chef-f7f2ef56bafad859771f14203c50434273e9b812.tar.gz |
Merge pull request #8457 from chef/lcg/chef-15-dsl-changes
Move more DSL helpers into universal so they're available everywhere
-rw-r--r-- | lib/chef/dsl/data_query.rb | 26 | ||||
-rw-r--r-- | lib/chef/dsl/recipe.rb | 8 | ||||
-rw-r--r-- | lib/chef/dsl/universal.rb | 13 |
3 files changed, 29 insertions, 18 deletions
diff --git a/lib/chef/dsl/data_query.rb b/lib/chef/dsl/data_query.rb index 8ec466ea35..a447ff1f38 100644 --- a/lib/chef/dsl/data_query.rb +++ b/lib/chef/dsl/data_query.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2018, Chef Software Inc. +# Copyright:: Copyright 2008-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,9 +25,9 @@ require "chef/encrypted_data_bag_item/check_encrypted" class Chef module DSL - # ==Chef::DSL::DataQuery - # Provides DSL for querying data from the chef-server via search or data - # bag. + # Provides DSL helper methods for querying the search interface, data bag + # interface or node interface. + # module DataQuery include Chef::EncryptedDataBagItem::CheckEncrypted @@ -80,6 +80,24 @@ class Chef raise end + # + # Note that this is mixed into the Universal DSL so access to the node needs to be done + # through the run_context and not accessing the node method directly, since the node method + # is not as universal as the run_context. + # + + # True if all the tags are set on the node. + # + # @param [Array<String>] tags to check against + # @return boolean + # + def tagged?(*tags) + tags.each do |tag| + return false unless run_context.node.tags.include?(tag) + end + true + end + end end end diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb index 4d68a36a81..a8ca8713b6 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-2018, Chef Software Inc. +# Copyright:: Copyright 2008-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,11 +20,8 @@ require "chef/exceptions" require "chef/dsl/resources" require "chef/dsl/definitions" -require "chef/dsl/data_query" require "chef/dsl/include_recipe" -require "chef/dsl/registry_helper" require "chef/dsl/reboot_pending" -require "chef/dsl/powershell" require "chef/dsl/core" require "chef/mixin/lazy_module_include" @@ -50,11 +47,8 @@ class Chef # module Recipe include Chef::DSL::Core - include Chef::DSL::DataQuery include Chef::DSL::IncludeRecipe - include Chef::DSL::RegistryHelper include Chef::DSL::RebootPending - include Chef::DSL::Powershell include Chef::DSL::Resources include Chef::DSL::Definitions extend Chef::Mixin::LazyModuleInclude diff --git a/lib/chef/dsl/universal.rb b/lib/chef/dsl/universal.rb index cb7e8591e8..eb90acfa2c 100644 --- a/lib/chef/dsl/universal.rb +++ b/lib/chef/dsl/universal.rb @@ -18,6 +18,9 @@ # require "chef/dsl/platform_introspection" +require "chef/dsl/data_query" +require "chef/dsl/registry_helper" +require "chef/dsl/powershell" require "chef/mixin/powershell_exec" require "chef/mixin/powershell_out" require "chef/mixin/shell_out" @@ -45,17 +48,13 @@ class Chef # module Universal include Chef::DSL::PlatformIntrospection + include Chef::DSL::DataQuery + include Chef::DSL::RegistryHelper + include Chef::DSL::Powershell include Chef::Mixin::PowershellExec include Chef::Mixin::PowershellOut include Chef::Mixin::ShellOut extend Chef::Mixin::LazyModuleInclude - - def tagged?(*tags) - tags.each do |tag| - return false unless run_context.node.tags.include?(tag) - end - true - end end end end |