diff options
author | Tim Smith <tsmith@chef.io> | 2020-03-31 13:48:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 13:48:38 -0700 |
commit | 5313c69f330e52362ba8a8e8e6313936b0d09521 (patch) | |
tree | 5b54a744e7beeab0434e2de124b8b3986f4adf6a | |
parent | 26424efc37c2f0528ffacc607027ffb75b3b054b (diff) | |
parent | 1e23ae8f3f2b7d5228f2920b4e3aca20b4f0d158 (diff) | |
download | chef-5313c69f330e52362ba8a8e8e6313936b0d09521.tar.gz |
Merge pull request #9553 from chef/fix_cloud
Fix cloud? helper to only report true on cloud instances
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/cloud.rb | 3 | ||||
-rw-r--r-- | chef-utils/spec/unit/dsl/cloud_spec.rb | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/chef-utils/lib/chef-utils/dsl/cloud.rb b/chef-utils/lib/chef-utils/dsl/cloud.rb index 734c7412aa..4b55fcdc29 100644 --- a/chef-utils/lib/chef-utils/dsl/cloud.rb +++ b/chef-utils/lib/chef-utils/dsl/cloud.rb @@ -30,7 +30,8 @@ module ChefUtils # @return [Boolean] # def cloud?(node = __getnode) - node.key?("cloud") + # cloud is always present, but nil if not on a cloud + !node["cloud"].nil? end # Return true if the current current node is in EC2. diff --git a/chef-utils/spec/unit/dsl/cloud_spec.rb b/chef-utils/spec/unit/dsl/cloud_spec.rb index ebf24c7818..8fc6c18528 100644 --- a/chef-utils/spec/unit/dsl/cloud_spec.rb +++ b/chef-utils/spec/unit/dsl/cloud_spec.rb @@ -79,4 +79,10 @@ RSpec.describe ChefUtils::DSL::Cloud do context "on softlayer" do cloud_reports_true_for(:cloud?, :softlayer?, node: { "softlayer" => {}, "cloud" => {} }) end + + context "on virtualbox" do + it "does not return true for cloud?" do + expect(described_class.cloud?({ "virtualbox" => {}, "cloud" => nil })).to be false + end + end end |