diff options
author | Tim Smith <tsmith@chef.io> | 2019-05-29 15:17:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 15:17:10 -0700 |
commit | 86de6b1e51e8c59f24b72bcdfe69eb68437b3fc8 (patch) | |
tree | 0d0c019a8c66923874ef3f26b351e66d4ba248a6 | |
parent | 7b1069567a8e3490ae6e0e21252880d62429c130 (diff) | |
parent | 3517c40842a81af75b8af2260c576159f9167c9b (diff) | |
download | chef-86de6b1e51e8c59f24b72bcdfe69eb68437b3fc8.tar.gz |
Merge pull request #8609 from chef/backport_8
Move the data_query, powershell and registry_helper DSLs up to universal
-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 | 6 |
3 files changed, 29 insertions, 11 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 9da812cec0..06cafd37d9 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,12 +20,9 @@ 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/audit" -require "chef/dsl/powershell" require "chef/dsl/core" require "chef/mixin/lazy_module_include" @@ -51,12 +48,9 @@ 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::Audit - 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 ffeb6583f4..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,6 +48,9 @@ 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 |