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? if logo.blank?
ActionController::Base.helpers.image_url("marianne.svg") ActionController::Base.helpers.image_url("marianne.svg")
else else
if Flipflop.remote_storage? if Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(logo.filename).url RemoteDownloader.new(logo.filename).url
else else
LocalDownloader.new(logo.path, 'logo').url LocalDownloader.new(logo.path, 'logo').url

View file

@ -52,7 +52,7 @@ class Commentaire < ApplicationRecord
if piece_jointe.virus_scanner.safe? if piece_jointe.virus_scanner.safe?
Rails.application.routes.url_helpers.url_for(piece_jointe) Rails.application.routes.url_helpers.url_for(piece_jointe)
end end
elsif Flipflop.remote_storage? elsif Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(file.path).url RemoteDownloader.new(file.path).url
elsif file&.url elsif file&.url
# FIXME: this is horrible but used only in dev and will be removed after migration # 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 end
# Choose what kind of storage to use for this uploader: # Choose what kind of storage to use for this uploader:
if Flipflop.remote_storage? if Rails.application.secrets.fog[:enabled]
storage :fog storage :fog
else else
storage :file storage :file
@ -13,7 +13,7 @@ class AttestationTemplateLogoUploader < BaseUploader
# Override the directory where uploaded files will be stored. # Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted: # This is a sensible default for uploaders that are meant to be mounted:
def store_dir def store_dir
if !Flipflop.remote_storage? if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end end
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -147,14 +147,6 @@ RSpec.configure do |config|
Typhoeus::Expectation.clear Typhoeus::Expectation.clear
ActionMailer::Base.deliveries.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| RSpec::Matchers.define :have_same_attributes_as do |expected, options|