Sha256: da06bcbbfafcda389d6843c17a538508f75b2007c20cf0d41de234c6ec580a2b

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

module ForemanGoogle
  class Engine < ::Rails::Engine
    isolate_namespace ForemanGoogle
    engine_name 'foreman_google'

    # Add any db migrations
    initializer 'foreman_google.load_app_instance_data' do |app|
      ForemanGoogle::Engine.paths['db/migrate'].existent.each do |path|
        app.config.paths['db/migrate'] << path
      end
    end

    initializer 'foreman_google.register_plugin', before: :finisher_hook do |_app|
      Foreman::Plugin.register :foreman_google do
        requires_foreman '>= 3.7.0'
        register_global_js_file 'global'
        register_gettext

        in_to_prepare do
          compute_resource(ForemanGoogle::GCE)
        end
      end
    end

    # Include concerns in this config.to_prepare block
    config.to_prepare do
      require 'google/cloud/compute/v1'

      ::Host::Managed.include ForemanGoogle::HostManagedExtensions
      ::Api::V2::ComputeResourcesController.include ForemanGoogle::Api::V2::ComputeResourcesExtensions
      ::Api::V2::ComputeResourcesController.include ForemanGoogle::Api::V2::ApipieExtensions
      ::Api::V2::ComputeResourcesController.include Foreman::Controller::Parameters::ComputeResourceExtension
      ::ComputeResourcesController.include Foreman::Controller::Parameters::ComputeResourceExtension
      Google::Cloud::Compute::V1::AttachedDisk.include GoogleExtensions::AttachedDisk
    rescue StandardError => e
      Rails.logger.warn "ForemanGoogle: skipping engine hook (#{e})"
    end

    rake_tasks do
      Rake::Task['db:seed'].enhance do
        ForemanGoogle::Engine.load_seed
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_google-2.0.1 lib/foreman_google/engine.rb
foreman_google-2.0.0 lib/foreman_google/engine.rb