Skip to content

Commit

Permalink
Fix nil checks in google_project_logging_audit_config resource
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pop <[email protected]>
  • Loading branch information
alexpop committed Oct 23, 2018
1 parent 1892fa2 commit a4c76fd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libraries/google_project_logging_audit_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@ 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
end
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
Expand Down

0 comments on commit a4c76fd

Please sign in to comment.