Project

General

Profile

Revision 5274f6bc

Added by Daniel Lobato Garcia over 7 years ago

Fixes #7874 - Docker Containers API

Routes are namespaced, code still needs to be namespaced

View differences:

lib/foreman_docker/engine.rb
57 57
        end
58 58

  
59 59
        security_block :containers do
60
          permission :view_containers,    :containers         => [:index, :show]
61
          permission :commit_containers,  :containers         => [:commit]
62
          permission :create_containers,  :'containers/steps' => [:show, :update],
63
                                          :containers         => [:new]
64
          permission :destroy_containers, :containers         => [:destroy]
65
          permission :power_compute_resources_vms, :containers => [:power]
60
          permission :view_containers,
61
                     :containers          => [:index, :show],
62
                     :'api/v2/containers' => [:index, :show, :logs]
63
          permission :commit_containers, :containers => [:commit]
64
          permission :create_containers,
65
                     :'containers/steps'  => [:show, :update],
66
                     :containers          => [:new],
67
                     :'api/v2/containers' => [:create, :power]
68
          permission :destroy_containers,
69
                     :containers          => [:destroy],
70
                     :'api/v2/containers' => [:destroy]
71
          permission :power_compute_resources_vms,
72
                     :containers          => [:power],
73
                     :'api/v2/containers' => [:create, :power]
66 74
        end
67 75

  
68 76
        security_block :registries do
......
77 85
                                       :auto_complete_image_tag,
78 86
                                       :search_repository]
79 87
        end
88

  
89
        # apipie API documentation
90
        # Only available in 1.8, otherwise it has to be in the initializer below
91
        if SETTINGS[:version].to_s.include?('develop') ||
92
           Gem::Version.new(SETTINGS[:version]) >= Gem::Version.new('1.8')
93
          apipie_documented_controllers [
94
            "#{ForemanDocker::Engine.root}/app/controllers/api/v2/*.rb"]
95
        end
96
      end
97
    end
98

  
99
    initializer "foreman_docker.apipie" do
100
      # this condition is here for compatibility reason to work with Foreman 1.4.x
101
      # Also need to handle the reverse of the 1.8 method above
102
      unless SETTINGS[:version].to_s.include?('develop') ||
103
             Gem::Version.new(SETTINGS[:version]) >= Gem::Version.new('1.8')
104
        if Apipie.configuration.api_controllers_matcher.is_a?(Array)
105
          Apipie.configuration.api_controllers_matcher <<
106
            "#{ForemanDocker::Engine.root}/app/controllers/api/v2/*.rb"
107
        end
80 108
      end
81 109
    end
82 110

  

Also available in: Unified diff