From f1b7e20f527eb9f6738a44d7b75e0974b0c9a0de Mon Sep 17 00:00:00 2001
From: Colleen Murphy <colleen@gazlene.net>
Date: Mon, 20 Jul 2015 17:43:16 -0700
Subject: [PATCH] Add Gemfile and puppet 4 checks

In anticipation of puppet 4, start trying to deal with puppet 4 things
that can be helpfully predicted by puppet lint plugins. This patch also
corrects lint errors caught by the puppet-lint-absolute_classname-check
and puppet-lint-empty_string-check gems as well as arrow alignment
which wasn't being caught under the system version of puppet-lint.

Change-Id: I5552777ba63d07039f9b2bed9c4100a44e6a0255
---
 .gitignore        |  2 ++
 Gemfile           | 30 ++++++++++++++++++++++++++++++
 manifests/bot.pp  | 14 +++++++-------
 manifests/init.pp | 12 ++++++------
 4 files changed, 45 insertions(+), 13 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 Gemfile

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dade81e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+Gemfile.lock
+.bundled_gems/
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..96912da
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,30 @@
+source 'https://rubygems.org'
+
+group :development, :test do
+  gem 'puppetlabs_spec_helper', :require => false
+
+  gem 'metadata-json-lint'
+  # This is nice and all, but let's not worry about it until we've actually
+  # got puppet 4.x sorted
+  # gem 'puppet-lint-param-docs'
+  gem 'puppet-lint-absolute_classname-check'
+  gem 'puppet-lint-absolute_template_path'
+  gem 'puppet-lint-trailing_newline-check'
+
+  # Puppet 4.x related lint checks
+  gem 'puppet-lint-unquoted_string-check'
+  gem 'puppet-lint-empty_string-check'
+  gem 'puppet-lint-leading_zero-check'
+  gem 'puppet-lint-variable_contains_upcase'
+  gem 'puppet-lint-spaceship_operator_without_tag-check'
+  gem 'puppet-lint-undef_in_function-check'
+
+  if puppetversion = ENV['PUPPET_GEM_VERSION']
+    gem 'puppet', puppetversion, :require => false
+  else
+    gem 'puppet', '~> 3.0', :require => false
+  end
+
+end
+
+# vim:ft=ruby
diff --git a/manifests/bot.pp b/manifests/bot.pp
index 79a6a6c..6f3070a 100644
--- a/manifests/bot.pp
+++ b/manifests/bot.pp
@@ -18,14 +18,14 @@
 #
 class elastic_recheck::bot (
   $gerrit_host,
-  $gerrit_ssh_host_key = '',
+  $gerrit_ssh_host_key = undef,
   $recheck_gerrit_user = 'elasticrecheck',
-  $recheck_ssh_private_key = '',
-  $recheck_ssh_public_key = '',
+  $recheck_ssh_private_key = undef,
+  $recheck_ssh_public_key = undef,
   $recheck_bot_passwd,
   $recheck_bot_nick,
 ) {
-  include elastic_recheck
+  include ::elastic_recheck
 
   file { '/etc/elastic-recheck/elastic-recheck.conf':
     ensure  => present,
@@ -52,7 +52,7 @@ class elastic_recheck::bot (
     require => Class['elastic_recheck'],
   }
 
-  if $recheck_ssh_private_key != '' {
+  if $recheck_ssh_private_key != undef {
     file { '/home/recheck/.ssh/id_rsa':
       owner   => 'recheck',
       group   => 'recheck',
@@ -63,7 +63,7 @@ class elastic_recheck::bot (
     }
   }
 
-  if $recheck_ssh_public_key != '' {
+  if $recheck_ssh_public_key != undef {
     file { '/home/recheck/.ssh/id_rsa.pub':
       owner   => 'recheck',
       group   => 'recheck',
@@ -74,7 +74,7 @@ class elastic_recheck::bot (
     }
   }
 
-  if $gerrit_ssh_host_key != '' {
+  if $gerrit_ssh_host_key != undef {
     file { '/home/recheck/.ssh/known_hosts':
       owner   => 'recheck',
       group   => 'recheck',
diff --git a/manifests/init.pp b/manifests/init.pp
index 4cdc47b..328d28f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -46,7 +46,7 @@ class elastic_recheck (
     source   => 'https://git.openstack.org/openstack-infra/elastic-recheck',
   }
 
-  include pip
+  include ::pip
   exec { 'install_elastic-recheck' :
     command     => 'pip install /opt/elastic-recheck',
     path        => '/usr/local/bin:/usr/bin:/bin/',
@@ -56,11 +56,11 @@ class elastic_recheck (
   }
 
   file { '/usr/local/bin/er_safe_run.sh':
-    ensure  => present,
-    source  => 'puppet:///modules/elastic_recheck/er_safe_run.sh',
-    mode    => '0755',
-    owner   => 'root',
-    group   => 'root',
+    ensure => present,
+    source => 'puppet:///modules/elastic_recheck/er_safe_run.sh',
+    mode   => '0755',
+    owner  => 'root',
+    group  => 'root',
   }
 
   file { '/var/run/elastic-recheck':