From 5c5d37fe5594170e59bd000a3fca7bc232b4c937 Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Wed, 2 Aug 2017 01:23:18 -0400 Subject: [PATCH] Style and lint fixes for the Ocata release - Style and lint fixes to support newer chefdk - Rewrote metadata.rb for readability - Removed ancient Gemfile Change-Id: I63e6680cec8b66e2ece2d2627c0b413f5d401317 --- .rubocop_todo.yml | 7 ++++++- Gemfile | 14 -------------- metadata.rb | 18 ++++++++++-------- recipes/apache2-server.rb | 10 +++++----- recipes/horizon.rb | 4 ++-- recipes/neutron-lbaas-dashboard.rb | 2 +- spec/apache2-server-redhat_spec.rb | 4 ++-- spec/apache2-server_spec.rb | 23 ++++++++++++----------- spec/horizon-redhat_spec.rb | 2 +- spec/horizon_spec.rb | 7 ++++--- spec/neutron-lbaas-dashboard_spec.rb | 2 +- 11 files changed, 44 insertions(+), 49 deletions(-) delete mode 100644 Gemfile diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3776810..16235cf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,16 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-02-23 16:58:27 +0100 using RuboCop version 0.39.0. +# on 2017-08-02 01:25:35 -0400 using RuboCop version 0.47.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 26 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 468 + # Offense count: 2 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: nested, compact diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 31c90b5..0000000 --- a/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -## THIS GEMFILE IS DEPRECATED AND WILL BE REMOVED AFTER THE NEXT RELEASE -## THERE WON'T BE ANY UPDATES TO THIS FILE DURING THIS RELEASE CYCLE -## WE SWITCHED TO CHEFDK AS THE BUNDLE FOR THE NEEDED GEMS - -source 'https://rubygems.org' - -gem 'chef', '~> 11.18.6' -gem 'json', '<= 1.7.7' # chef 11 dependency -gem 'berkshelf', '~> 3.2.1' -gem 'hashie', '~> 2.0' -gem 'chefspec', '~> 4.0.0' -gem 'rspec', '~> 3.0.0' -gem 'foodcritic', '~> 4.0' -gem 'rubocop', '~> 0.29.1' diff --git a/metadata.rb b/metadata.rb index 792a6b0..aa37693 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,18 +1,20 @@ -name 'openstack-dashboard' -maintainer 'openstack-chef' +name 'openstack-dashboard' +maintainer 'openstack-chef' maintainer_email 'openstack-dev@lists.openstack.org' -issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url) -source_url 'https://github.com/openstack/cookbook-openstack-dashboard' if respond_to?(:source_url) -license 'Apache 2.0' -description 'Installs/Configures the OpenStack Dashboard (Horizon)' +license 'Apache 2.0' +description 'Installs/Configures the OpenStack Dashboard (Horizon)' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '15.0.0' +version '15.0.0' %w(ubuntu redhat centos).each do |os| supports os end -depends 'apache2', '~> 3.2' depends 'openstack-common', '>= 15.0.0' depends 'openstack-identity', '>= 15.0.0' +depends 'apache2', '~> 3.2' depends 'poise-python', '~> 1.5.1' + +issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url) +source_url 'https://github.com/openstack/cookbook-openstack-dashboard' if respond_to?(:source_url) +chef_version '>= 12.5' if respond_to?(:chef_version) diff --git a/recipes/apache2-server.rb b/recipes/apache2-server.rb index 10d4c69..5983daa 100644 --- a/recipes/apache2-server.rb +++ b/recipes/apache2-server.rb @@ -90,7 +90,7 @@ ssl_chain_file = if node['openstack']['dashboard']['ssl']['chain'] if node['openstack']['dashboard']['use_ssl'] && node['openstack']['dashboard']['ssl']['use_data_bag'] unless ssl_cert_file == ssl_key_file - cert_mode = 00644 + cert_mode = 0o0644 cert_owner = 'root' cert_group = 'root' @@ -104,7 +104,7 @@ if node['openstack']['dashboard']['use_ssl'] && end if ssl_chain_file - cert_mode = 00644 + cert_mode = 0o0644 cert_owner = 'root' cert_group = 'root' @@ -117,7 +117,7 @@ if node['openstack']['dashboard']['use_ssl'] && end end - key_mode = 00640 + key_mode = 0o0640 key_owner = 'root' key_group = node['openstack']['dashboard']['key_group'] @@ -134,7 +134,7 @@ end file node['openstack']['dashboard']['secret_key_path'] do owner node['openstack']['dashboard']['horizon_user'] group node['openstack']['dashboard']['horizon_group'] - mode 00600 + mode 0o0600 # the only time the file should be created is if we have secret_key_content # set, otherwise let apache create it when someone first accesses the # dashboard @@ -156,7 +156,7 @@ template node['openstack']['dashboard']['apache']['sites-path'] do source 'dash-site.erb' owner 'root' group 'root' - mode 00644 + mode 0o0644 variables( ssl_cert_file: ssl_cert_file.to_s, diff --git a/recipes/horizon.rb b/recipes/horizon.rb index b7384f0..fe4990a 100644 --- a/recipes/horizon.rb +++ b/recipes/horizon.rb @@ -72,7 +72,7 @@ template node['openstack']['dashboard']['local_settings_path'] do source 'local_settings.py.erb' owner 'root' group node['openstack']['dashboard']['horizon_group'] - mode 00640 + mode 0o0640 sensitive true variables( @@ -102,7 +102,7 @@ end directory "#{node['openstack']['dashboard']['dash_path']}/local" do owner 'root' group node['openstack']['dashboard']['horizon_group'] - mode 02770 + mode 0o2770 action :create end diff --git a/recipes/neutron-lbaas-dashboard.rb b/recipes/neutron-lbaas-dashboard.rb index 6028144..05bbb88 100644 --- a/recipes/neutron-lbaas-dashboard.rb +++ b/recipes/neutron-lbaas-dashboard.rb @@ -34,6 +34,6 @@ end remote_file "#{django_path}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py" do source 'https://raw.githubusercontent.com/openstack/neutron-lbaas-dashboard/stable/ocata/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py' owner 'root' - mode 00644 + mode 0o0644 notifies :run, 'execute[openstack-dashboard collectstatic]' end diff --git a/spec/apache2-server-redhat_spec.rb b/spec/apache2-server-redhat_spec.rb index a87e8e6..0da137f 100644 --- a/spec/apache2-server-redhat_spec.rb +++ b/spec/apache2-server-redhat_spec.rb @@ -26,12 +26,12 @@ describe 'openstack-dashboard::apache2-server' do expect(chef_run).to create_file('/etc/pki/tls/certs/horizon.pem').with( user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) expect(chef_run).to create_file('/etc/pki/tls/private/horizon.key').with( user: 'root', group: 'root', - mode: 0640 + mode: 0o640 ) expect(pem).to notify('execute[restore-selinux-context]').to(:run) expect(key).to notify('execute[restore-selinux-context]').to(:run) diff --git a/spec/apache2-server_spec.rb b/spec/apache2-server_spec.rb index 4f5743f..cd88129 100644 --- a/spec/apache2-server_spec.rb +++ b/spec/apache2-server_spec.rb @@ -101,13 +101,13 @@ describe 'openstack-dashboard::apache2-server' do content: 'horizon_pem_value', user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) expect(chef_run).to create_file('/etc/ssl/private/horizon.key').with( content: 'horizon_key_value', user: 'root', group: 'ssl-cert', - mode: 0640 + mode: 0o640 ) expect(pem).to notify('execute[restore-selinux-context]').to(:run) expect(key).to notify('execute[restore-selinux-context]').to(:run) @@ -124,7 +124,7 @@ describe 'openstack-dashboard::apache2-server' do content: 'horizon_chain_pem_value', user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) expect(chain).to notify('execute[restore-selinux-context]').to(:run) end @@ -145,7 +145,7 @@ describe 'openstack-dashboard::apache2-server' do content: 'horizon_pem_value', user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) end @@ -154,7 +154,7 @@ describe 'openstack-dashboard::apache2-server' do content: 'horizon_pem_value', user: 'root', group: 'ssl-cert', - mode: 0640 + mode: 0o640 ) expect(key).to notify('execute[restore-selinux-context]').to(:run) end @@ -190,13 +190,13 @@ describe 'openstack-dashboard::apache2-server' do content: 'any_pem_value', user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) expect(chef_run).to create_file('/etc/anypath/any.key').with( content: 'any_key_value', user: 'root', group: 'ssl-cert', - mode: 0640 + mode: 0o640 ) expect(key).to notify('execute[restore-selinux-context]').to(:run) expect(pem).to notify('execute[restore-selinux-context]').to(:run) @@ -214,7 +214,7 @@ describe 'openstack-dashboard::apache2-server' do content: 'any_chain_pem_value', user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) expect(chain).to notify('execute[restore-selinux-context]').to(:run) end @@ -248,7 +248,7 @@ describe 'openstack-dashboard::apache2-server' do expect(chef_run).to create_template(file.name).with( user: 'root', group: 'root', - mode: 0644 + mode: 0o644 ) end @@ -429,7 +429,8 @@ describe 'openstack-dashboard::apache2-server' do node.set['openstack']['dashboard']['horizon_group'] = 'horizon_group_value' node.set['openstack']['dashboard']['dash_path'] = 'dash_path_value' expect(chef_run).to render_file(file.name).with_content( - /^\s*WSGIDaemonProcess dashboard user=horizon_user_value group=horizon_group_value processes=3 threads=10 python-path=dash_path_value$/) + /^\s*WSGIDaemonProcess dashboard user=horizon_user_value group=horizon_group_value processes=3 threads=10 python-path=dash_path_value$/ + ) end it 'has the default DocRoot' do @@ -509,7 +510,7 @@ describe 'openstack-dashboard::apache2-server' do end it 'has correct mode' do - expect(file.mode).to eq(00600) + expect(file.mode).to eq(0o0600) end it 'does not notify apache2 restart' do diff --git a/spec/horizon-redhat_spec.rb b/spec/horizon-redhat_spec.rb index d244f5e..7e6bf6e 100644 --- a/spec/horizon-redhat_spec.rb +++ b/spec/horizon-redhat_spec.rb @@ -24,7 +24,7 @@ describe 'openstack-dashboard::horizon' do expect(chef_run).to create_template(file.name).with( user: 'root', group: 'apache', - mode: 0640 + mode: 0o640 ) end diff --git a/spec/horizon_spec.rb b/spec/horizon_spec.rb index c902a24..207939d 100644 --- a/spec/horizon_spec.rb +++ b/spec/horizon_spec.rb @@ -31,7 +31,7 @@ describe 'openstack-dashboard::horizon' do sensitive: true, user: 'root', group: 'horizon', - mode: 0640 + mode: 0o640 ) end @@ -425,7 +425,8 @@ describe 'openstack-dashboard::horizon' do it "sets the logger level for #{component}" do node.set['openstack']['dashboard']['log_level'][component] = "#{component}_log_level_value" expect(chef_run).to render_file(file.name).with_content( - /^\s*'#{component}': {\s*'handlers': \['console'\],\s*'level': '#{component}_log_level_value',$/) + /^\s*'#{component}': {\s*'handlers': \['console'\],\s*'level': '#{component}_log_level_value',$/ + ) end end @@ -536,7 +537,7 @@ describe 'openstack-dashboard::horizon' do it 'has group write mode on path' do path = chef_run.directory("#{chef_run.node['openstack']['dashboard']['dash_path']}/local") - expect(path.mode).to eq(02770) + expect(path.mode).to eq(0o2770) expect(path.group).to eq(chef_run.node['openstack']['dashboard']['horizon_group']) end end diff --git a/spec/neutron-lbaas-dashboard_spec.rb b/spec/neutron-lbaas-dashboard_spec.rb index 9522b40..a2139e7 100644 --- a/spec/neutron-lbaas-dashboard_spec.rb +++ b/spec/neutron-lbaas-dashboard_spec.rb @@ -28,7 +28,7 @@ describe 'openstack-dashboard::neutron-lbaas-dashboard' do expect(chef_run).to create_remote_file( "#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py" ).with( - mode: 00644, + mode: 0o0644, owner: 'root', source: 'https://raw.githubusercontent.com/openstack/neutron-lbaas-dashboard/stable/ocata/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py' )