Merge pull request #52863 from zzak/asto/deprecate-azure

Deprecate ActiveStorage::Service::AzureStorageService
This commit is contained in:
Rafael Mendonça França 2024-09-11 12:59:00 -03:00 committed by GitHub
commit 9356db3d4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 0 deletions

View File

@ -1,3 +1,7 @@
* Deprecate `ActiveStorage::Service::AzureStorageService`.
*zzak*
* Improve `ActiveStorage::Filename#sanitized` method to handle special characters more effectively.
Replace the characters `"*?<>` with `-` if they exist in the Filename to match the Filename convention of Win OS.

View File

@ -15,6 +15,13 @@ module ActiveStorage
attr_reader :client, :container, :signer
def initialize(storage_account_name:, storage_access_key:, container:, public: false, **options)
ActiveStorage.deprecator.warn <<~MSG.squish
`ActiveStorage::Service::AzureStorageService` is deprecated and will be
removed in Rails 8.1.
Please try the `azure-blob` gem instead.
This gem is not maintained by the Rails team, so please test your applications before deploying to production.
MSG
@client = Azure::Storage::Blob::BlobService.create(storage_account_name: storage_account_name, storage_access_key: storage_access_key, **options)
@signer = Azure::Storage::Common::Core::Auth::SharedAccessSignature.new(storage_account_name, storage_access_key)
@container = container

View File

@ -20,4 +20,22 @@ class ActiveStorage::Service::ConfiguratorTest < ActiveSupport::TestCase
ActiveStorage::Service::Configurator.build(:bigfoot, {})
end
end
test "azure service is deprecated" do
msg = <<~MSG.squish
`ActiveStorage::Service::AzureStorageService` is deprecated and will be
removed in Rails 8.1.
Please try the `azure-blob` gem instead.
This gem is not maintained by the Rails team, so please test your applications before deploying to production.
MSG
assert_deprecated(msg, ActiveStorage.deprecator) do
ActiveStorage::Service::Configurator.build(:azure, azure: {
service: "AzureStorage",
storage_account_name: "test_account",
storage_access_key: Base64.encode64("test_access_key").strip,
container: "container"
})
end
end
end