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
This commit is contained in:
Samuel Cassiba 2017-08-02 01:23:18 -04:00
parent 943c3a6aeb
commit 5c5d37fe55
11 changed files with 44 additions and 49 deletions

View File

@ -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

14
Gemfile
View File

@ -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'

View File

@ -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)

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'
)