summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrajaktaPurohit <PrajaktaPurohit@users.noreply.github.com>2022-05-17 12:12:23 -0700
committerGitHub <noreply@github.com>2022-05-17 12:12:23 -0700
commit450ecb0f292804b513ff7b7b5a40096622f0d235 (patch)
tree43e255b4dedf1d52345e06a5ae9106e4ddafa77b
parent706d19b6fc4d6bdb7bfa9ee6917287ef39b0cfb7 (diff)
parentdf8d5a0d5415306877abb731771526b8030dcd7c (diff)
downloadchef-450ecb0f292804b513ff7b7b5a40096622f0d235.tar.gz
Merge pull request #12830 from chef/i5pranay93/INFWS-73-customer-bug-671
handling exception for compliance phase error during chef spec run
-rw-r--r--lib/chef/compliance/input_collection.rb2
-rw-r--r--lib/chef/compliance/profile_collection.rb3
-rw-r--r--lib/chef/compliance/waiver_collection.rb2
3 files changed, 3 insertions, 4 deletions
diff --git a/lib/chef/compliance/input_collection.rb b/lib/chef/compliance/input_collection.rb
index 034943f8d9..a3e55c5f6a 100644
--- a/lib/chef/compliance/input_collection.rb
+++ b/lib/chef/compliance/input_collection.rb
@@ -40,7 +40,7 @@ class Chef
def from_file(filename, cookbook_name)
new_input = Input.from_file(events, filename, cookbook_name)
self << new_input
- events.compliance_input_loaded(new_input)
+ events&.compliance_input_loaded(new_input)
end
# Add a input from a raw hash. This input will be enabled by default.
diff --git a/lib/chef/compliance/profile_collection.rb b/lib/chef/compliance/profile_collection.rb
index d85d04e825..2def655dd9 100644
--- a/lib/chef/compliance/profile_collection.rb
+++ b/lib/chef/compliance/profile_collection.rb
@@ -41,11 +41,10 @@ class Chef
def from_file(path, cookbook_name)
new_profile = Profile.from_file(events, path, cookbook_name)
self << new_profile
- events.compliance_profile_loaded(new_profile)
+ events&.compliance_profile_loaded(new_profile)
end
# @return [Boolean] if any of the profiles are enabled
- #
def using_profiles?
any?(&:enabled?)
end
diff --git a/lib/chef/compliance/waiver_collection.rb b/lib/chef/compliance/waiver_collection.rb
index a3d12b3a97..68dce07287 100644
--- a/lib/chef/compliance/waiver_collection.rb
+++ b/lib/chef/compliance/waiver_collection.rb
@@ -40,7 +40,7 @@ class Chef
def from_file(filename, cookbook_name)
new_waiver = Waiver.from_file(events, filename, cookbook_name)
self << new_waiver
- events.compliance_waiver_loaded(new_waiver)
+ events&.compliance_waiver_loaded(new_waiver)
end
# Add a waiver from a raw hash. This waiver will be enabled by default.