Skip to content

Commit

Permalink
Move StorageProvider creation from seed to rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
elohanlon committed Oct 28, 2024
1 parent 3644132 commit 94b55e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 0 additions & 3 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@
name: 'CRC32C', empty_binary_value: Digest::CRC32c.new.digest
)

StorageProvider.find_or_create_by!(storage_type: StorageProvider.storage_types[:aws], container_name: 'cul-dlstor-digital-preservation')
StorageProvider.find_or_create_by!(storage_type: StorageProvider.storage_types[:gcp], container_name: 'cul-dlstor-digital-preservation')
StorageProvider.find_or_create_by!(storage_type: StorageProvider.storage_types[:cul], container_name: 'netapp')
21 changes: 21 additions & 0 deletions lib/tasks/setup.rake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ namespace :atc do
end
end

desc 'Set up StorageProviders'
task storage_providers: :environment do
storage_provider_container_name = ENV['storage_provider_container_name']
if storage_provider_container_name.nil?
puts 'Missing storage_provider_container_name (Example: storage_provider_container_name=some-bucket-name)'
next
end

[
{ storage_type: StorageProvider.storage_types[:aws], container_name: storage_provider_container_name },
{ storage_type: StorageProvider.storage_types[:gcp], container_name: storage_provider_container_name },
].each do |storage_provider_args|
if StorageProvider.exists?(**storage_provider_args)
puts "#{Rainbow("StorageProvider already exists (skipping): #{storage_provider_args.inspect}").blue.bright}\n"
else
StorageProvider.create!(**storage_provider_args)
puts Rainbow("Created StorageProvider: #{storage_provider_args.inspect}").green
end
end
end

desc 'Set up test config files'
task test_storage_providers: :environment do
[
Expand Down

0 comments on commit 94b55e7

Please sign in to comment.