Revision dc3be9a0
Added by David Davis over 8 years ago
.rubocop.yml | ||
---|---|---|
1 |
inherit_from: |
|
2 |
- .rubocop_todo.yml |
|
3 |
|
|
4 |
AllCops: |
|
5 |
RunRailsCops: true # always run the rails cops |
|
6 |
|
|
7 | 1 |
# Don't enforce documentation |
8 | 2 |
Style/Documentation: |
9 | 3 |
Enabled: false |
... | ... | |
17 | 11 |
EnforcedStyle: filter |
18 | 12 |
|
19 | 13 |
Style/LineLength: |
20 |
Max: 132 # Half of a 1920x1080 screen
|
|
14 |
Max: 100
|
|
21 | 15 |
|
22 | 16 |
Style/MethodLength: |
23 | 17 |
Max: 20 |
18 |
|
|
19 |
StringLiterals: |
|
20 |
Enabled: false |
Rakefile | ||
---|---|---|
5 | 5 |
rescue LoadError |
6 | 6 |
Rails.logger.error 'You must `gem install bundler` and `bundle install` to run rake tasks' |
7 | 7 |
end |
8 |
|
|
9 |
begin |
|
10 |
require 'rubocop/rake_task' |
|
11 |
RuboCop::RakeTask.new |
|
12 |
rescue => _ |
|
13 |
puts "Rubocop not loaded." |
|
14 |
end |
|
15 |
|
|
16 |
task :default do |
|
17 |
Rake::Task['rubocop'].execute |
|
18 |
end |
app/controllers/containers_controller.rb | ||
---|---|---|
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
def destroy |
19 |
if params[:compute_resource_id].present? |
|
20 |
destroy_as_compute_resource_vm |
|
21 |
end |
|
19 |
return unless params[:compute_resource_id].present? |
|
20 |
destroy_as_compute_resource_vm |
|
22 | 21 |
end |
23 | 22 |
|
24 | 23 |
private |
25 | 24 |
|
26 | 25 |
def destroy_as_compute_resource_vm |
27 |
@container_resource = ComputeResource.authorized(:destroy_compute_resources_vms).find(params[:compute_resource_id]) |
|
26 |
@container_resource = ComputeResource.authorized(:destroy_compute_resources_vms) |
|
27 |
.find(params[:compute_resource_id]) |
|
28 | 28 |
if @container_resource.destroy_vm(params[:id]) |
29 |
process_success({ :success_redirect => containers_path,
|
|
30 |
:success_msg => _('Container is being deleted.') })
|
|
29 |
process_success(:success_redirect => containers_path, |
|
30 |
:success_msg => _('Container is being deleted.'))
|
|
31 | 31 |
else |
32 |
process_error({ :redirect => containers_path })
|
|
32 |
process_error(:redirect => containers_path)
|
|
33 | 33 |
end |
34 | 34 |
end |
35 | 35 |
|
app/models/concerns/fog_extensions/fogdocker/server.rb | ||
---|---|---|
36 | 36 |
end |
37 | 37 |
|
38 | 38 |
def vm_description |
39 |
_('%{cores} Cores and %{memory} memory') % { :cores => cpus, :memory => number_to_human_size(memory.to_i) } |
|
39 |
_('%{cores} Cores and %{memory} memory') % |
|
40 |
{ :cores => cpus, :memory => number_to_human_size(memory.to_i) } |
|
40 | 41 |
end |
41 | 42 |
end |
42 | 43 |
end |
app/models/foreman_docker/docker.rb | ||
---|---|---|
52 | 52 |
end |
53 | 53 |
|
54 | 54 |
def vm_instance_defaults |
55 |
ActiveSupport::HashWithIndifferentAccess.new('name' => "foreman_#{Time.now.to_i}", 'cmd' => ['/bin/bash']) |
|
55 |
ActiveSupport::HashWithIndifferentAccess.new('name' => "foreman_#{Time.now.to_i}", |
|
56 |
'cmd' => ['/bin/bash']) |
|
56 | 57 |
end |
57 | 58 |
|
58 | 59 |
def test_connection(options = {}) |
foreman_docker.gemspec | ||
---|---|---|
23 | 23 |
s.add_dependency 'fog' |
24 | 24 |
s.add_dependency 'docker-api', '~> 1.8.0' |
25 | 25 |
s.add_dependency 'wicked' |
26 |
s.add_development_dependency 'rubocop' |
|
26 |
s.add_development_dependency 'rubocop', '~> 0.26.1'
|
|
27 | 27 |
end |
lib/foreman_docker/engine.rb | ||
---|---|---|
24 | 24 |
requires_foreman '> 1.4' |
25 | 25 |
compute_resource ForemanDocker::Docker |
26 | 26 |
|
27 |
sub_menu :top_menu, :containers_menu, :caption => N_('Containers'), :after => :monitor_menu do |
|
27 |
sub_menu :top_menu, :containers_menu, :caption => N_('Containers'), |
|
28 |
:after => :monitor_menu do |
|
28 | 29 |
menu :top_menu, :containers, :caption => N_('All containers'), |
29 |
:url_hash => { :controller => :containers, :action => :index } |
|
30 |
:url_hash => { :controller => :containers, |
|
31 |
:action => :index } |
|
30 | 32 |
menu :top_menu, :new_container, :caption => N_('New container'), |
31 |
:url_hash => { :controller => :containers, :action => :new } |
|
33 |
:url_hash => { :controller => :containers, |
|
34 |
:action => :new } |
|
32 | 35 |
end |
33 | 36 |
|
34 | 37 |
security_block :containers do |
35 |
permission :view_containers, { :containers => [:index] }
|
|
36 |
permission :create_containers, { :'containers/steps' => [:show, :update],
|
|
37 |
:containers => [:new] }
|
|
38 |
permission :destroy_containers, { :containers => [:destroy] }
|
|
38 |
permission :view_containers, :containers => [:index]
|
|
39 |
permission :create_containers, :'containers/steps' => [:show, :update], |
|
40 |
:containers => [:new]
|
|
41 |
permission :destroy_containers, :containers => [:destroy]
|
|
39 | 42 |
end |
40 | 43 |
end |
41 | 44 |
|
... | ... | |
46 | 49 |
end |
47 | 50 |
end |
48 | 51 |
|
49 |
|
|
50 | 52 |
# extend fog docker server and image models. |
51 | 53 |
require 'fog/fogdocker/models/compute/server' |
52 | 54 |
require 'fog/fogdocker/models/compute/image' |
lib/foreman_docker/tasks/test.rake | ||
---|---|---|
5 | 5 |
test_task = Rake::TestTask.new('docker_test_task') do |t| |
6 | 6 |
t.libs << ["test", "#{ForemanDocker::Engine.root}/test"] |
7 | 7 |
t.test_files = [ |
8 |
"#{ForemanDocker::Engine.root}/test/**/*_test.rb",
|
|
8 |
"#{ForemanDocker::Engine.root}/test/**/*_test.rb" |
|
9 | 9 |
] |
10 | 10 |
t.verbose = true |
11 | 11 |
end |
Also available in: Unified diff
Fixes #7977 - Enabling rubocop for foreman-docker