Skip to content

Commit

Permalink
Merge pull request Purple-Devs#112 from PCPS/rails61
Browse files Browse the repository at this point in the history
make s3 check rails 6.1 compatible
  • Loading branch information
jmarchello authored Apr 6, 2023
2 parents 5a19a91 + 32751bc commit 53ae042
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/health_check/s3_health_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def check
end
permissions.each do |permision|
begin
send(permision, bucket_name)
rescue Exception => e
raise "bucket:#{bucket_name}, permission:#{permision} - #{e.message}"
end
send(permision, bucket_name)
rescue Exception => e
raise "bucket:#{bucket_name}, permission:#{permision} - #{e.message}"
end
end
end
''
Expand Down Expand Up @@ -46,14 +46,25 @@ def R(bucket)
end

def W(bucket)
app_name = if Rails::VERSION::MAJOR >= 6
::Rails.application.class.module_parent_name
else
::Rails.application.class.parent_name
end

aws_s3_client.put_object(bucket: bucket,
key: "healthcheck_#{::Rails.application.class.parent_name}",
key: "healthcheck_#{app_name}",
body: Time.new.to_s)
end

def D(bucket)
app_name = if Rails::VERSION::MAJOR >= 6
::Rails.application.class.module_parent_name
else
::Rails.application.class.parent_name
end
aws_s3_client.delete_object(bucket: bucket,
key: "healthcheck_#{::Rails.application.class.parent_name}")
key: "healthcheck_#{app_name}")
end
end
end
Expand Down

0 comments on commit 53ae042

Please sign in to comment.