Initial dashboard Pike updates

- Switched default linter to cookstyle
- Renamed rake tasks to better conform with Chef conventions
- Normalized the template banner

Change-Id: I80d825722a3218b34a5dee38b60017492e3768e0
This commit is contained in:
Samuel Cassiba 2017-08-23 21:10:06 -04:00
parent 6e44af9d17
commit d7773b69b6
10 changed files with 39 additions and 61 deletions

View File

@ -1,5 +1,3 @@
inherit_from: .rubocop_todo.yml
AllCops: AllCops:
Include: Include:
- metadata.rb - metadata.rb
@ -28,3 +26,12 @@ LineLength:
WordArray: WordArray:
MinSize: 3 MinSize: 3
Style/Next:
Description: Use `next` to skip iteration instead of a condition at the end.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
Enabled: true
EnforcedStyle: always
SupportedStyles:
- skip_modifier_ifs
- always

View File

@ -1,28 +0,0 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-17 14:16:07 +0200 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
Style/ClassAndModuleChildren:
Exclude:
- 'recipes/apache2-server.rb'
- 'recipes/horizon.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'spec/horizon_spec.rb'

View File

@ -1,20 +1,20 @@
task default: ["test"] task default: ["test"]
task :test => [:lint, :style, :unit] task :test => [:syntax, :lint, :unit]
desc "Vendor the cookbooks in the Berksfile" desc "Vendor the cookbooks in the Berksfile"
task :berks_prep do task :berks_prep do
sh %{chef exec berks vendor} sh %{chef exec berks vendor}
end end
desc "Run FoodCritic (lint) tests" desc "Run FoodCritic (syntax) tests"
task :lint do task :syntax do
sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} sh %{chef exec foodcritic --exclude spec -f any .}
end end
desc "Run RuboCop (style) tests" desc "Run RuboCop (lint) tests"
task :style do task :lint do
sh %{chef exec rubocop} sh %{chef exec cookstyle}
end end
desc "Run RSpec (unit) tests" desc "Run RSpec (unit) tests"

View File

@ -22,8 +22,8 @@
# Set to some text value if you want templated config files # Set to some text value if you want templated config files
# to contain a custom banner at the top of the written file # to contain a custom banner at the top of the written file
default['openstack']['dashboard']['custom_template_banner'] = ' default['openstack']['dashboard']['custom_template_banner'] = '
# This file autogenerated by Chef # This file is automatically generated by Chef
# Do not edit, changes will be overwritten # Any changes will be overwritten
' '
# ****************** OpenStack Dashboard Endpoints ****************************** # ****************** OpenStack Dashboard Endpoints ******************************
@ -99,7 +99,7 @@ default['openstack']['dashboard']['webroot'] = '/'
default['openstack']['dashboard']['db_python_packages'] = { default['openstack']['dashboard']['db_python_packages'] = {
mysql: [], mysql: [],
postgresql: [], postgresql: [],
sqlite: [] sqlite: [],
} }
# The hash algorithm to use for authentication tokens. This must match the hash # The hash algorithm to use for authentication tokens. This must match the hash
@ -125,7 +125,7 @@ when 'rhel'
default['openstack']['dashboard']['platform'] = { default['openstack']['dashboard']['platform'] = {
'horizon_packages' => ['openstack-dashboard'], 'horizon_packages' => ['openstack-dashboard'],
'memcache_python_packages' => ['python-memcached'], 'memcache_python_packages' => ['python-memcached'],
'package_overrides' => '' 'package_overrides' => '',
} }
default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf" default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf"
when 'debian' when 'debian'
@ -143,7 +143,7 @@ when 'debian'
default['openstack']['dashboard']['login_redirect_url'] = nil default['openstack']['dashboard']['login_redirect_url'] = nil
default['openstack']['dashboard']['platform'] = { default['openstack']['dashboard']['platform'] = {
'memcache_python_packages' => ['python-memcache'], 'memcache_python_packages' => ['python-memcache'],
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'" 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'",
} }
default['openstack']['dashboard']['platform']['horizon_packages'] = ['node-less', 'openstack-dashboard'] default['openstack']['dashboard']['platform']['horizon_packages'] = ['node-less', 'openstack-dashboard']
default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf" default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf"

View File

@ -24,7 +24,7 @@
require 'uri' require 'uri'
class ::Chef::Recipe # rubocop:disable Documentation class ::Chef::Recipe
include ::Openstack include ::Openstack
end end

View File

@ -24,7 +24,7 @@
require 'uri' require 'uri'
class ::Chef::Recipe # rubocop:disable Documentation class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
include_recipe 'openstack-identity' include_recipe 'openstack-identity'

View File

@ -554,7 +554,7 @@ describe 'openstack-dashboard::apache2-server' do
action: [:run], action: [:run],
params: { params: {
enable: false, enable: false,
name: '000-default' name: '000-default',
} }
) )
end end
@ -567,7 +567,7 @@ describe 'openstack-dashboard::apache2-server' do
params: { params: {
enable: true, enable: true,
notifies: [:reload, 'service[apache2]', :immediately], notifies: [:reload, 'service[apache2]', :immediately],
name: 'openstack-dashboard' name: 'openstack-dashboard',
} }
) )
end end

View File

@ -32,7 +32,7 @@ describe 'openstack-dashboard::horizon' do
[ [
%r{^LOGIN_URL = '/auth/login/'$}, %r{^LOGIN_URL = '/auth/login/'$},
%r{^LOGOUT_URL = '/auth/logout/'$}, %r{^LOGOUT_URL = '/auth/logout/'$},
%r{^LOGIN_REDIRECT_URL = '/'$} %r{^LOGIN_REDIRECT_URL = '/'$},
].each do |line| ].each do |line|
expect(chef_run).to render_file(file.name).with_content(line) expect(chef_run).to render_file(file.name).with_content(line)
end end

View File

@ -50,12 +50,12 @@ describe 'openstack-dashboard::horizon' do
node.set['openstack']['dashboard']['misc_local_settings'] = { node.set['openstack']['dashboard']['misc_local_settings'] = {
'CUSTOM_CONFIG_A' => { 'CUSTOM_CONFIG_A' => {
'variable1' => 'value1', 'variable1' => 'value1',
'variable2' => 'value2' 'variable2' => 'value2',
}, },
'CUSTOM_CONFIG_B' => { 'CUSTOM_CONFIG_B' => {
'variable1' => 'value1', 'variable1' => 'value1',
'variable2' => 'value2' 'variable2' => 'value2',
} },
} }
end end
@ -68,7 +68,7 @@ describe 'openstack-dashboard::horizon' do
['CUSTOM_CONFIG_B = {', ['CUSTOM_CONFIG_B = {',
' \'variable1\': \'value1\',', ' \'variable1\': \'value1\',',
' \'variable2\': \'value2\',', ' \'variable2\': \'value2\',',
'}'] '}'],
].each do |content| ].each do |content|
expect(chef_run).to render_file(file.name).with_content(build_section(content)) expect(chef_run).to render_file(file.name).with_content(build_section(content))
end end
@ -237,7 +237,7 @@ describe 'openstack-dashboard::horizon' do
[ [
/^LOGIN_URL =$/, /^LOGIN_URL =$/,
/^LOGOUT_URL =$/, /^LOGOUT_URL =$/,
/^LOGIN_REDIRECT_URL =$/ /^LOGIN_REDIRECT_URL =$/,
].each do |line| ].each do |line|
expect(chef_run).to_not render_file(file.name).with_content(line) expect(chef_run).to_not render_file(file.name).with_content(line)
end end
@ -254,7 +254,7 @@ describe 'openstack-dashboard::horizon' do
node.set['openstack']['dashboard']['volume_api_version'] = 'volume_api_version_value' node.set['openstack']['dashboard']['volume_api_version'] = 'volume_api_version_value'
[ [
/^\s*"identity": identity_api_version_value,$/, /^\s*"identity": identity_api_version_value,$/,
/^\s*"volume": volume_api_version_value$/ /^\s*"volume": volume_api_version_value$/,
].each do |line| ].each do |line|
expect(chef_run).to render_file(file.name).with_content(line) expect(chef_run).to render_file(file.name).with_content(line)
end end
@ -264,7 +264,7 @@ describe 'openstack-dashboard::horizon' do
node.set['openstack']['api']['auth']['version'] = 'v3.0' node.set['openstack']['api']['auth']['version'] = 'v3.0'
[ [
/^\s*"identity": 3,$/, /^\s*"identity": 3,$/,
/^\s*"volume": 2$/ /^\s*"volume": 2$/,
].each do |line| ].each do |line|
expect(chef_run).to render_file(file.name).with_content(line) expect(chef_run).to render_file(file.name).with_content(line)
end end
@ -456,10 +456,9 @@ describe 'openstack-dashboard::horizon' do
/^\s*'PASSWORD': 'test-passes',$/, /^\s*'PASSWORD': 'test-passes',$/,
/^\s*'HOST': '#{service_type}_host',$/, /^\s*'HOST': '#{service_type}_host',$/,
/^\s*'PORT': '#{service_type}_port',$/].each do |cfg| /^\s*'PORT': '#{service_type}_port',$/].each do |cfg|
unless service_type == 'sqlite' next if service_type == 'sqlite'
it "configures the #{service_type} backend with #{cfg}" do it "configures the #{service_type} backend with #{cfg}" do
expect(chef_run).to render_file(file.name).with_content(cfg) expect(chef_run).to render_file(file.name).with_content(cfg)
end
end end
end end
end end
@ -497,7 +496,7 @@ describe 'openstack-dashboard::horizon' do
sync_db_environment = { sync_db_environment = {
'PYTHONPATH' => '/etc/openstack-dashboard:' \ 'PYTHONPATH' => '/etc/openstack-dashboard:' \
'/usr/share/openstack-dashboard:' \ '/usr/share/openstack-dashboard:' \
'$PYTHONPATH' '$PYTHONPATH',
} }
it 'does not execute when session_backend is not sql' do it 'does not execute when session_backend is not sql' do

View File

@ -8,12 +8,12 @@ LOG_LEVEL = :fatal
REDHAT_OPTS = { REDHAT_OPTS = {
platform: 'redhat', platform: 'redhat',
version: '7.1', version: '7.1',
log_level: LOG_LEVEL log_level: LOG_LEVEL,
}.freeze }.freeze
UBUNTU_OPTS = { UBUNTU_OPTS = {
platform: 'ubuntu', platform: 'ubuntu',
version: '16.04', version: '16.04',
log_level: LOG_LEVEL log_level: LOG_LEVEL,
}.freeze }.freeze
# Build a regex for a section of lines # Build a regex for a section of lines