Project

General

Profile

Download (3.21 KB) Statistics
| Branch: | Tag: | Revision:

foreman_pipeline / lib / foreman_pipeline / engine.rb @ 720671b8

1
require 'foreman_pipeline/monkeys'
2
require 'bastion'
3
require 'katello'
4
require 'net/ssh'
5
require 'net/scp'
6

    
7
module ForemanPipeline
8
  class Engine < ::Rails::Engine
9
    isolate_namespace ForemanPipeline
10

    
11
    initializer 'foreman_pipeline.assets_dispatcher', :before => :build_middleware_stack do |app|
12
      app.middleware.use ::ActionDispatch::Static, "#{ForemanPipeline::Engine.root}/app/assets/javascripts/foreman_pipeline"
13
    end
14

    
15
    initializer 'foreman_pipeline.mount_engine', :after => :build_middleware_stack do |app|
16
      app.routes_reloader.paths << "#{ForemanPipeline::Engine.root}/config/mount_engine.rb"
17
    end
18

    
19
    initializer 'foreman_pipeline.load_app_instance_data' do |app|
20
      ForemanPipeline::Engine.paths['db/migrate'].existent.each do |path|
21
        app.config.paths['db/migrate'] << path
22
      end
23
      app.config.autoload_paths += Dir["#{config.root}/app/lib"]
24
      app.config.autoload_paths += Dir["#{config.root}/app/views/foreman"]
25
    end
26

    
27
    initializer 'foreman_pipeline.register_plugin', :before => :finisher_hook do
28
      require 'foreman_pipeline/plugin'
29
      require 'foreman_pipeline/permissions'
30
      require 'foreman_pipeline/roles'
31
    end
32

    
33
    initializer 'foreman_pipeline.assets.precompile' do |app|
34
       app.config.assets.precompile += %w(foreman_pipeline/foreman_pipeline.js
35
                                          foreman_pipeline/foreman_pipeline.css)
36
    end
37

    
38
    initializer 'foreman_pipeline.configure_assets', :group => :assets do |app|
39
      SETTINGS[:foreman_pipeline] = {
40
        :assets => {
41
          :precompile => [
42
            'foreman_pipeline/foreman_pipeline.js',
43
            'foreman_pipeline/foreman_pipeline.css'
44
          ]
45
        }
46
      }
47
    end
48

    
49
    initializer "foreman_pipeline.apipie" do
50
      Apipie.configuration.checksum_path += ['/foreman_pipeline/api/']
51
    end
52

    
53
    initializer 'foreman_pipeline.register_actions', :before => 'foreman_tasks.initialize_dynflow' do |app|
54
      ForemanTasks.dynflow.require!
55

    
56
      action_paths = %W(#{ForemanPipeline::Engine.root}/app/lib/actions)
57

    
58
      ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
59
    end
60

    
61
    config.to_prepare do
62

    
63
      ::Bastion.register_plugin({
64
        :name => 'foreman_pipeline',
65
        :javascript => 'foreman_pipeline/foreman_pipeline',
66
        :stylesheet => 'foreman_pipeline/foreman_pipeline',
67
        :pages => %w(
68
            jobs
69
            jenkins_instances
70
          )
71
        })
72

    
73
      # extensions
74
      ::Katello::Repository.send :include, ForemanPipeline::Concerns::RepositoryExtension
75
      ::Katello::ContentViewRepository.send :include, ForemanPipeline::Concerns::ContentViewRepositoryExtension
76
      ::Katello::ContentView.send :include, ForemanPipeline::Concerns::ContentViewExtension
77
      ::Katello::KTEnvironment.send :include, ForemanPipeline::Concerns::KtEnvironmentExtension
78
      ::Hostgroup.send :include, ForemanPipeline::Concerns::HostgroupExtension
79
      ::ComputeResource.send :include, ForemanPipeline::Concerns::ComputeResourceExtension
80
    end
81

    
82

    
83
    rake_tasks do
84
      load "#{ForemanPipeline::Engine.root}/lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake"
85
      load "#{ForemanPipeline::Engine.root}/lib/foreman_pipeline/tasks/foreman_pipeline_test.rake"
86
    end
87

    
88
  end
89
end