From 51e58eebd3ba69e3f41046221baddf75aba90a11 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Fri, 25 Oct 2024 14:42:32 -0700 Subject: [PATCH] set up s3 for valkyrie files --- config/initializers/pre_wings.rb | 3 ++ config/initializers/wings.rb | 49 -------------------------------- hyrax-webapp | 2 +- ops/production-deploy.tmpl.yaml | 10 +++++++ ops/staging-deploy.tmpl.yaml | 10 +++++++ 5 files changed, 24 insertions(+), 50 deletions(-) create mode 100644 config/initializers/pre_wings.rb delete mode 100644 config/initializers/wings.rb diff --git a/config/initializers/pre_wings.rb b/config/initializers/pre_wings.rb new file mode 100644 index 0000000..820149e --- /dev/null +++ b/config/initializers/pre_wings.rb @@ -0,0 +1,3 @@ +Rails.application.config.to_prepare do + WINGS_CONCERNS = [AdminSet, Collection, ConferenceItem, Dataset, Etd, ExamPaper, GenericWork, Image, JournalArticle, Oer, PublishedWork, Thesis].freeze +end diff --git a/config/initializers/wings.rb b/config/initializers/wings.rb deleted file mode 100644 index 6d5c9dd..0000000 --- a/config/initializers/wings.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Metrics/BlockLength - -Rails.application.config.after_initialize do - # Add all concerns that are migrating from ActiveFedora here - CONCERNS = [ConferenceItem, Dataset, Etd, ExamPaper, GenericWork, Image, JournalArticle, PublishedWork, Thesis].freeze - - CONCERNS.each do |klass| - Wings::ModelRegistry.register("#{klass}Resource".constantize, klass) - # we register itself so we can pre-translate the class in Freyja instead of having to translate in each query_service - Wings::ModelRegistry.register(klass, klass) - end - - Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name| - # TODO: Can we use some kind of lookup. - klass_name = resource_klass_name.gsub(/Resource$/, '') - if CONCERNS.map(&:to_s).include?(klass_name) - "#{klass_name}Resource".constantize - elsif 'Collection' == klass_name - CollectionResource - elsif 'AdminSet' == klass_name - AdminSetResource - # Without this mapping, we'll see cases of Postgres Valkyrie adapter attempting to write to - # Fedora. Yeah! - elsif 'Hydra::AccessControl' == klass_name - Hyrax::AccessControl - elsif 'FileSet' == klass_name - Hyrax::FileSet - elsif 'Hydra::AccessControls::Embargo' == klass_name - Hyrax::Embargo - elsif 'Hydra::AccessControls::Lease' == klass_name - Hyrax::Lease - elsif 'Hydra::PCDM::File' == klass_name - Hyrax::FileMetadata - else - klass_name.constantize - end - end - - Valkyrie::MetadataAdapter.register( - Freyja::MetadataAdapter.new, - :freyja - ) - Valkyrie.config.metadata_adapter = :freyja - - Hyrax.query_service.services[0].custom_queries.register_query_handler(Hyrax::CustomQueries::FindBySlug) - Hyrax.query_service.services[1].custom_queries.register_query_handler(Wings::CustomQueries::FindBySlug) -end -# rubocop:enable Metrics/BlockLength diff --git a/hyrax-webapp b/hyrax-webapp index 6931967..3b5e762 160000 --- a/hyrax-webapp +++ b/hyrax-webapp @@ -1 +1 @@ -Subproject commit 69319674143d7d8dc2b45b8cd19be6054ddf4034 +Subproject commit 3b5e762945f6753e56448176aab6d322cfc646a4 diff --git a/ops/production-deploy.tmpl.yaml b/ops/production-deploy.tmpl.yaml index 43692b2..0121585 100644 --- a/ops/production-deploy.tmpl.yaml +++ b/ops/production-deploy.tmpl.yaml @@ -175,6 +175,16 @@ extraEnvVars: &envVars value: adventist-knapsack-production-redis-master - name: REDIS_URL value: redis://:$REDIS_PASSWORD@adventist-knapsack-production-redis-master:6379/0 + - name: REPOSITORY_S3_STORAGE + value: true + - name: REPOSITORY_S3_BUCKET + value: samvera-original-files + - name: REPOSITORY_S3_REGION + value: us-east-1 + - name: REPOSITORY_S3_ACCESS_KEY + value: $AWS_ACCESS_KEY_ID + - name: REPOSITORY_S3_SECRET_KEY + value: $AWS_SECRET_ACCESS_KEY - name: SECRET_KEY_BASE value: $SECRET_KEY_BASE - name: SENTRY_DSN diff --git a/ops/staging-deploy.tmpl.yaml b/ops/staging-deploy.tmpl.yaml index 5322516..693bff7 100644 --- a/ops/staging-deploy.tmpl.yaml +++ b/ops/staging-deploy.tmpl.yaml @@ -197,6 +197,16 @@ extraEnvVars: &envVars value: adventist-knapsack-staging-redis-master - name: REDIS_URL value: redis://:$REDIS_PASSWORD@adventist-knapsack-staging-redis-master:6379/0 + - name: REPOSITORY_S3_STORAGE + value: "true" + - name: REPOSITORY_S3_BUCKET + value: samvera-original-files-staging + - name: REPOSITORY_S3_REGION + value: us-east-1 + - name: REPOSITORY_S3_ACCESS_KEY + value: $AWS_ACCESS_KEY_ID + - name: REPOSITORY_S3_SECRET_KEY + value: $AWS_SECRET_ACCESS_KEY - name: SECRET_KEY_BASE value: $SECRET_KEY_BASE - name: SENTRY_DSN