Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preprovision initializer for app platforms #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
v4.12.0 (XXXX 2024)
- Add preprovision initializer for app platforms
- Update Dradis links in README
- Fix the TypeError around the plugins template caching

Expand Down
25 changes: 24 additions & 1 deletion lib/dradis/plugins/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,34 @@ class Engine < ::Rails::Engine

config.dradis = ActiveSupport::OrderedOptions.new

initializer "dradis-plugins.set_configs" do |app|
initializer 'dradis-plugins.set_configs' do |app|
options = app.config.dradis
options.base_export_controller_class_name ||= 'AuthenticatedController'
options.thor_helper_module ||= Dradis::Plugins::ThorHelper
end

# In App Platforms, assets:precompile is run before the DB is provisioned causing a
# ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1",
# port 5432 failed: Connection refused
#
# We run into this problem because dradis-plugins uses a :enabled/disabled DB
# setting for each integration to decide whether to load them or not.
#
# See:
# https://devcenter.heroku.com/articles/rails-asset-pipeline
#
initializer 'dradis-plugins.preprovision-database' do
Rails.application.reloader.to_prepare do
# This is set by the App Platforms
if ENV['DATABASE_URL']
# DB isn't ready yet
if !(ActiveRecord::Base.connection rescue false)
# Empty the list of integrations.
Dradis::Plugins::class_variable_set('@@enabled_list', [])
end
end
end
end
end
end
end