Skip to content

Commit

Permalink
Extract AWS_S3_BUCKET_NAME env var into app config
Browse files Browse the repository at this point in the history
So it's easier to stub.

Unfortunately I've had to disable a Rubocop rule around one line. This
violation is due to the digit `3` in the variable name. It looks as if
the constraints for this rule have been relaxed [1] in Rubocop v0.44.0,
but we're currently using v0.43.0 and upgrading means first upgrading
the constraints on the Rubocop version in the specification for the
`govuk-lint` gem and then upgrading that gem in this project. I'm
going to do that separately and I'll make a note to remove this
disabling of the rule when I do that.

[1]: rubocop/rubocop@833aad6
  • Loading branch information
floehopper committed Jul 25, 2017
1 parent fd0a75b commit 13ba282
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/initializers/aws.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AssetManager::Application.config.aws_s3_bucket_name = ENV['AWS_S3_BUCKET_NAME']

Aws.config.update(
logger: Rails.logger
)
5 changes: 4 additions & 1 deletion lib/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

module Services
def self.cloud_storage
@cloud_storage ||= S3Storage.build(ENV['AWS_S3_BUCKET_NAME'])
# rubocop:disable Style/VariableNumber
aws_s3_bucket_name = AssetManager::Application.config.aws_s3_bucket_name
# rubocop:enable Style/VariableNumber
@cloud_storage ||= S3Storage.build(aws_s3_bucket_name)
end
end

0 comments on commit 13ba282

Please sign in to comment.