Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fog_options to config #431

Merged
merged 2 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Nothing
- Add `fog_options` configuration option.

### Changed

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ AssetSync.configure do |config|
#
# Change canned ACL of uploaded object. Default is unset. Will override fog_public if set.
# Choose from: private | public-read | public-read-write | aws-exec-read |
# authenticated-read | bucket-owner-read | bucket-owner-full-control
# config.aws_acl = nil
# authenticated-read | bucket-owner-read | bucket-owner-full-control
# config.aws_acl = nil
#
# Change host option in fog (only if you need to)
# config.fog_host = 's3.amazonaws.com'
Expand All @@ -256,6 +256,10 @@ AssetSync.configure do |config|
# Use http instead of https.
# config.fog_scheme = 'http'
#
# Extra fog options.
sunny marked this conversation as resolved.
Show resolved Hide resolved
# Overrides any existing value (even those set by AssetSync)
# config.fog_options = {}
#
# Automatically replace files with their equivalent gzip compressed version
# config.gzip_compression = true
#
Expand Down Expand Up @@ -322,7 +326,7 @@ defaults: &defaults
#
# Change canned ACL of uploaded object. Default is unset. Will override fog_public if set.
# Choose from: private | public-read | public-read-write | aws-exec-read |
# authenticated-read | bucket-owner-read | bucket-owner-full-control
# authenticated-read | bucket-owner-read | bucket-owner-full-control
# aws_acl: null
#
# Change host option in fog (only if you need to)
Expand Down Expand Up @@ -436,6 +440,7 @@ The blocks are run when local files are being scanned and uploaded

* **fog\_region**: the region your storage bucket is in e.g. *eu-west-1* (AWS), *ord* (Rackspace), *japanwest* (Azure Blob)
* **fog\_path\_style**: To use buckets with dot in names, check https://github.com/fog/fog/issues/2381#issuecomment-28088524
* **fog\_options**: For extra fog options. Overrides any existing value (even those set by AssetSync)

#### AWS

Expand Down
2 changes: 2 additions & 0 deletions lib/asset_sync/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Invalid < StandardError; end
attr_accessor :fog_directory # e.g. 'the-bucket-name'
attr_accessor :fog_region # e.g. 'eu-west-1'
attr_reader :fog_public # e.g. true, false, "default"
attr_accessor :fog_options # e.g. { enable_signature_v4_streaming: true }

# Amazon AWS
attr_accessor :aws_access_key_id
Expand Down Expand Up @@ -338,6 +339,7 @@ def fog_options
raise ArgumentError, "AssetSync Unknown provider: #{fog_provider} only AWS, Rackspace and Google are supported currently."
end

options.merge!(@fog_options) if @fog_options
options
end

Expand Down
22 changes: 22 additions & 0 deletions spec/unit/asset_sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,28 @@
end
end

describe 'with fog_options' do
before(:each) do
AssetSync.config = AssetSync::Config.new
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.fog_region = 'eu-west-1'
config.fog_path_style = 'true'
config.fog_options = { enable_signature_v4_streaming: true }
end
end

it "assigns fog_options" do
AssetSync.config.fog_options = { enable_signature_v4_streaming: true }
expect(AssetSync.config.fog_options).to include(
provider: 'AWS',
region: 'eu-west-1',
path_style: 'true',
enable_signature_v4_streaming: true,
)
end
end

describe 'with invalid yml' do
before(:each) do
set_rails_root('with_invalid_yml')
Expand Down