From 253d1fb088cc65140f1348d2e0fa310afad75436 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Tue, 23 Oct 2018 11:34:05 +0100 Subject: [PATCH] Fix nil checks in google_project_logging_audit_config resource Signed-off-by: Alex Pop --- libraries/google_project_logging_audit_config.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/google_project_logging_audit_config.rb b/libraries/google_project_logging_audit_config.rb index 224fbc9e1..22d7fac7a 100644 --- a/libraries/google_project_logging_audit_config.rb +++ b/libraries/google_project_logging_audit_config.rb @@ -21,12 +21,12 @@ def initialize(opts = {}) @audit_logging_configs = @gcp.gcp_project_client.get_project_iam_policy(@project) @default_types = [] @default_exempted_members = {} - if defined?(@audit_logging_configs.audit_configs) + if defined?(@audit_logging_configs.audit_configs) && !@audit_logging_configs.audit_configs.nil? @audit_logging_configs.audit_configs.each do |service_config| next if service_config.service != 'allServices' service_config.audit_log_configs.each do |config| @default_types+=[config.log_type] - @default_exempted_members[config.log_type]=config.exempted_members if defined?(config.exempted_members) + @default_exempted_members[config.log_type]=config.exempted_members if defined?(config.exempted_members) && !config.exempted_members.nil? end end end @@ -34,8 +34,7 @@ def initialize(opts = {}) end def exists? - return false if !defined? @audit_logging_configs.audit_configs - !@audit_logging_configs.audit_configs.nil? + defined?(@audit_logging_configs.audit_configs) && !@audit_logging_configs.audit_configs.nil? end attr_reader :default_types