Stop using Flipflop as switch for Fog

This commit is contained in:
Paul Chavard 2019-07-31 12:25:40 +02:00
parent 6f3fde21f2
commit 25db21467d
10 changed files with 13 additions and 22 deletions

View file

@ -26,7 +26,7 @@ module ProcedureHelper
if logo.blank?
ActionController::Base.helpers.image_url("marianne.svg")
else
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(logo.filename).url
else
LocalDownloader.new(logo.path, 'logo').url

View file

@ -52,7 +52,7 @@ class Commentaire < ApplicationRecord
if piece_jointe.virus_scanner.safe?
Rails.application.routes.url_helpers.url_for(piece_jointe)
end
elsif Flipflop.remote_storage?
elsif Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(file.path).url
elsif file&.url
# FIXME: this is horrible but used only in dev and will be removed after migration

View file

@ -4,7 +4,7 @@ class AttestationTemplateLogoUploader < BaseUploader
end
# Choose what kind of storage to use for this uploader:
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
@ -13,7 +13,7 @@ class AttestationTemplateLogoUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
if !Flipflop.remote_storage?
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -4,7 +4,7 @@ class AttestationTemplateSignatureUploader < BaseUploader
end
# Choose what kind of storage to use for this uploader:
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
@ -13,7 +13,7 @@ class AttestationTemplateSignatureUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
if !Flipflop.remote_storage?
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -4,7 +4,7 @@ class AttestationUploader < BaseUploader
end
# Choose what kind of storage to use for this uploader:
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
@ -13,7 +13,7 @@ class AttestationUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
if !Flipflop.remote_storage?
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -3,7 +3,7 @@ class CommentaireFileUploader < BaseUploader
Rails.root.join("public")
end
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file

View file

@ -4,7 +4,7 @@ class ProcedureLogoUploader < BaseUploader
end
# Choose what kind of storage to use for this uploader:
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
@ -13,7 +13,7 @@ class ProcedureLogoUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
if !Flipflop.remote_storage?
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
@ -27,7 +27,7 @@ class ProcedureLogoUploader < BaseUploader
def filename
if file.present?
if original_filename.present? || model.logo_secure_token
if Flipflop.remote_storage?
if Rails.application.secrets.fog[:enabled]
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension&.downcase}"
else
filename = "logo-#{secure_token}.#{file.extension&.downcase}"

View file

@ -29,8 +29,6 @@ Flipflop.configure do
end
group :production do
feature :remote_storage,
default: ENV['FOG_ENABLED'] == 'enabled'
feature :insee_api_v3,
default: true
feature :weekly_overview,

View file

@ -34,6 +34,7 @@ defaults: &defaults
pipedrive:
key: <%= ENV['PIPEDRIVE_KEY'] %>
fog:
enabled: <%= ENV['FOG_ENABLED'] == 'enabled' %>
openstack_tenant: <%= ENV['FOG_OPENSTACK_TENANT'] %>
openstack_api_key: <%= ENV['FOG_OPENSTACK_API_KEY'] %>
openstack_username: <%= ENV['FOG_OPENSTACK_USERNAME'] %>

View file

@ -147,14 +147,6 @@ RSpec.configure do |config|
Typhoeus::Expectation.clear
ActionMailer::Base.deliveries.clear
if Flipflop.remote_storage?
VCR.use_cassette("ovh_storage_init") do
CarrierWave.configure do |config|
config.fog_credentials = { provider: 'OpenStack' }
end
end
end
}
RSpec::Matchers.define :have_same_attributes_as do |expected, options|