Browse Source

Coding style fixes

fhrbek 11 years ago
parent
commit
10cb81468e

+ 23 - 0
.project

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>postgresql</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
+		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+	</natures>
+</projectDescription>

+ 1 - 1
Modulefile

@@ -5,7 +5,7 @@ author 'Inkling/Puppet Labs'
 description 'PostgreSQL defined resource types'
 summary 'PostgreSQL defined resource types'
 license 'Apache'
-project_page 'https://github.com/puppetlabs/puppet-postgresql/issues'
+project_page 'https://github.com/puppetlabs/puppet-postgresql'
 
 dependency 'puppetlabs/stdlib', '>=3.2.0 <4.0.0'
 dependency 'puppetlabs/firewall', '>= 0.0.4'

+ 4 - 4
manifests/config/beforeservice.pp

@@ -73,15 +73,15 @@ class postgresql::config::beforeservice(
   # managing their own settings in a second conf file.
   file_line { 'postgresql.conf#include':
     path        => $postgresql_conf_path,
-    line        => "include 'postgresql_puppet_extras.conf'",
+    line        => 'include \'postgresql_puppet_extras.conf\'',
     notify      => Service['postgresqld'],
   }
 
   # Since we're adding an "include" for this extras config file, we need
   # to make sure it exists.
-  exec { "touch `dirname $postgresql_conf_path`/postgresql_puppet_extras.conf" :
-    path   => "/usr/bin:/bin",
-    unless => "[ -f `dirname $postgresql_conf_path`/postgresql_puppet_extras.conf ]"
+  exec { "touch `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf" :
+    path   => '/usr/bin:/bin',
+    unless => "[ -f `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf ]"
   }
 
   # TODO: is this a reasonable place for this firewall stuff?

+ 7 - 7
manifests/database.pp

@@ -34,10 +34,10 @@ define postgresql::database(
       undef   => '',
       default => "--locale=${locale}",
     }
-    $public_revoke_privilege = "CONNECT"
+    $public_revoke_privilege = 'CONNECT'
   } else {
-    $locale_option = ""
-    $public_revoke_privilege = "ALL"
+    $locale_option = ''
+    $public_revoke_privilege = 'ALL'
   }
 
   $createdb_command_tmp = "${postgresql::params::createdb_path} --template=template0 --encoding '${charset}' ${locale_option} '${dbname}'"
@@ -49,9 +49,9 @@ define postgresql::database(
     $createdb_command = "${createdb_command_tmp} --tablespace='${tablespace}'"
   }
 
-  postgresql_psql { "Check for existence of db '$dbname'":
-    command => "SELECT 1",
-    unless  => "SELECT datname FROM pg_database WHERE datname='$dbname'",
+  postgresql_psql { "Check for existence of db '${dbname}'":
+    command => 'SELECT 1',
+    unless  => "SELECT datname FROM pg_database WHERE datname='${dbname}'",
     cwd     => $postgresql::params::datadir,
     require => Class['postgresql::server']
   } ~>
@@ -65,7 +65,7 @@ define postgresql::database(
 
   # This will prevent users from connecting to the database unless they've been
   #  granted privileges.
-  postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE $dbname FROM public":
+  postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE ${dbname} FROM public":
     db          => 'postgres',
     refreshonly => true,
     cwd         => $postgresql::params::datadir,

+ 2 - 2
manifests/database_grant.pp

@@ -50,10 +50,10 @@ define postgresql::database_grant(
     default => $privilege,
   }
 
-  postgresql_psql {"GRANT $privilege ON database $db TO $role":
+  postgresql_psql {"GRANT ${privilege} ON database ${db} TO ${role}":
     db           => $psql_db,
     psql_user    => $psql_user,
-    unless       => "SELECT 1 WHERE has_database_privilege('$role', '$db', '$unless_privilege')",
+    unless       => "SELECT 1 WHERE has_database_privilege('${role}', '${db}', '${unless_privilege}')",
     cwd          => $postgresql::params::datadir,
   }
 }

+ 44 - 34
manifests/init.pp

@@ -1,37 +1,46 @@
-# Class: postgresql
-#
-#   This is a base class that can be used to modify catalog-wide settings relating
-#   to the various types in class contained in the postgresql module.
-#
-#   If you don't declare this class in your catalog, sensible defaults will
-#   be used.  However, if you choose to declare it, it needs to appear *before*
-#   any other types or classes from the postgresql module.
-#
-#   For examples, see the files in the `tests` directory; in particular,
-#    `/server-yum-postgresql-org.pp`.
-#
-# Parameters:
-#   [*version*] - The postgresql version to install.  If not specified, the
-#                 module will use whatever version is the default for your
-#                 OS distro.
-#   [*manage_package_repo*] - This determines whether or not the module should
-#                 attempt to manage the postgres package repository for your
-#                 distro.  Defaults to `false`, but if set to `true`, it can
-#                 be used to set up the official postgres yum/apt package
-#                 repositories for you.
-#   [*package_source*] - This setting is only used if `manage_package_repo` is
-#                 set to `true`.  It determines which package repository should
-#                 be used to install the postgres packages.  Currently supported
-#                 values include `yum.postgresql.org`.
-#   [*locale*] -  This setting defines the default locale for initdb and createdb
-#                 commands. This default to 'undef' which is effectively 'C'.
-#   [*charset*] - Sets the default charset to be used for initdb and createdb.
-#                 Defaults to 'UTF8'.
-# Actions:
-#
-# Requires:
-#
-# Sample Usage:
+# == Class: postgresql
+#
+# This is a base class that can be used to modify catalog-wide settings relating
+# to the various types in class contained in the postgresql module.
+#
+# If you don't declare this class in your catalog, sensible defaults will
+# be used.  However, if you choose to declare it, it needs to appear *before*
+# any other types or classes from the postgresql module.
+#
+# For examples, see the files in the `tests` directory; in particular,
+# `/server-yum-postgresql-org.pp`.
+#
+#
+# [*version*]
+#    The postgresql version to install.  If not specified, the
+#    module will use whatever version is the default for your
+#    OS distro.
+# [*manage_package_repo*]
+#    This determines whether or not the module should
+#    attempt to manage the postgres package repository for your
+#    distro.  Defaults to `false`, but if set to `true`, it can
+#    be used to set up the official postgres yum/apt package
+#    repositories for you.
+# [*package_source*]
+#    This setting is only used if `manage_package_repo` is
+#    set to `true`.  It determines which package repository should
+#    be used to install the postgres packages.  Currently supported
+#    values include `yum.postgresql.org`.
+#
+# [*locale*]
+#    This setting defines the default locale for initdb and createdb
+#    commands. This default to 'undef' which is effectively 'C'.
+# [*charset*]
+#    Sets the default charset to be used for initdb and createdb.
+#    Defaults to 'UTF8'.
+#
+# === Examples:
+#
+#   class { 'postgresql':
+#     version               => '9.2',
+#     manage_package_repo   => true,
+#   }
+#
 #
 class postgresql (
   $version             = $::postgres_default_version,
@@ -41,6 +50,7 @@ class postgresql (
   $charset             = 'UTF8'
 ) {
   class { 'postgresql::params':
+
     version             => $version,
     manage_package_repo => $manage_package_repo,
     package_source      => $package_source,

+ 3 - 3
manifests/package_source/yum_postgresql_org.pp

@@ -6,10 +6,10 @@ class postgresql::package_source::yum_postgresql_org(
   $package_version     = "${version_parts[0]}${version_parts[1]}"
 
   file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}":
-      source => "puppet:///modules/postgresql/RPM-GPG-KEY-PGDG"
+      source => 'puppet:///modules/postgresql/RPM-GPG-KEY-PGDG'
   } ->
 
-  yumrepo { "yum.postgresql.org":
+  yumrepo { 'yum.postgresql.org':
       descr    => "PostgreSQL ${version} \$releasever - \$basearch",
       baseurl  => "http://yum.postgresql.org/${version}/redhat/rhel-\$releasever-\$basearch",
       enabled  => 1,
@@ -17,6 +17,6 @@ class postgresql::package_source::yum_postgresql_org(
       gpgkey   => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}",
   }
 
-  Yumrepo["yum.postgresql.org"] -> Package<|tag == 'postgresql'|>
+  Yumrepo['yum.postgresql.org'] -> Package<|tag == 'postgresql'|>
 
 }

+ 3 - 3
manifests/params.pp

@@ -52,7 +52,7 @@ class postgresql::params(
 
            case $rh_pkg_source {
              'yum.postgresql.org': {
-                class { "postgresql::package_source::yum_postgresql_org":
+                class { 'postgresql::package_source::yum_postgresql_org':
                   version => $version
                 }
              }
@@ -64,7 +64,7 @@ class postgresql::params(
         }
 
         'Debian': {
-          class { "postgresql::package_source::apt_postgresql_org": }
+          class { 'postgresql::package_source::apt_postgresql_org': }
         }
 
         default: {
@@ -81,7 +81,7 @@ class postgresql::params(
   # that pluginsync might not be enabled.  Ideally this would be handled directly
   # in puppet.
   if ($::postgres_default_version == undef) {
-    fail "No value for postgres_default_version facter fact; it's possible that you don't have pluginsync enabled."
+    fail 'No value for postgres_default_version facter fact; it\'s possible that you don\'t have pluginsync enabled.'
   }
 
   case $::operatingsystem {

+ 3 - 3
manifests/psql.pp

@@ -38,10 +38,10 @@ define postgresql::psql(
   $quoted_command = regsubst($command, '"', '\\"', 'G')
   $quoted_unless  = regsubst($unless,  '"', '\\"', 'G')
 
-  $final_cmd = "/bin/echo \"$quoted_command\" | $psql |egrep -v -q '^$'"
+  $final_cmd = "/bin/echo \"${quoted_command}\" | ${psql} |egrep -v -q '^$'"
 
-  notify { "deprecation warning: $final_cmd":
-    message => "postgresql::psql is deprecated ; please use postgresql_psql instead.",
+  notify { "deprecation warning: ${final_cmd}":
+    message => 'postgresql::psql is deprecated ; please use postgresql_psql instead.',
   } ->
 
   exec { $final_cmd:

+ 2 - 2
manifests/role.pp

@@ -33,10 +33,10 @@ define postgresql::role(
   $superuser_sql  = $superuser  ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
 
   # TODO: FIXME: Will not correct the superuser / createdb / createrole / login status of a role that already exists
-  postgresql_psql {"CREATE ROLE ${username} ENCRYPTED PASSWORD '${password_hash}' $login_sql $createrole_sql $createdb_sql $superuser_sql":
+  postgresql_psql {"CREATE ROLE ${username} ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql}":
     db           => $db,
     psql_user    => 'postgres',
-    unless       => "SELECT rolname FROM pg_roles WHERE rolname='$username'",
+    unless       => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",
     cwd          => $postgresql::params::datadir,
   }
 }

+ 3 - 3
manifests/tablespace.pp

@@ -38,17 +38,17 @@ define postgresql::tablespace(
 
   $create_tablespace_command = "CREATE TABLESPACE ${spcname} ${owner_section} LOCATION '${location}'"
 
-  file { "${location}":
+  file { $location:
     ensure => directory,
     owner  => 'postgres',
     group  => 'postgres',
-    mode => 700,
+    mode   => '0700',
   }
 
   postgresql_psql { "Create tablespace '${spcname}'":
     command => $create_tablespace_command,
     unless  => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'",
     cwd     => $postgresql::params::datadir,
-    require => [Class['postgresql::server'], File["${location}"]],
+    require => [Class['postgresql::server'], File[$location]],
   }
 }

+ 1 - 1
spec/system/base.pp

@@ -28,7 +28,7 @@ user {'puppet':
 file {'/etc/sudoers.d/puppet_postgresql_tests':
   ensure  => file,
   content => 'vagrant ALL=(ALL) ALL',
-  mode    => 0440,
+  mode    => '0440',
   owner   => root,
   group   => root,
 }

+ 1 - 1
spec/system/test_module/manifests/system_default/test_grant_create.pp

@@ -35,7 +35,7 @@ class postgresql_tests::system_default::test_grant_create($user, $password, $db)
     require => Class['postgresql::server'],
   }
 
-  postgresql::database_grant { "grant create test":
+  postgresql::database_grant { 'grant create test':
     privilege   => 'CREATE',
     db          => $db,
     role        => $user,

+ 2 - 2
spec/system/test_module/manifests/system_default/test_tablespace.pp

@@ -27,7 +27,7 @@ class postgresql_tests::system_default::test_tablespace {
     ensure => 'directory',
     owner  => 'postgres',
     group  => 'postgres',
-    mode   => 700,
+    mode   => '0700',
     require => File['/tmp'],
   }
 
@@ -61,5 +61,5 @@ class postgresql_tests::system_default::test_tablespace {
     tablespace => 'tablespace2',
     require => Postgresql::Tablespace['tablespace2'],
   }
-  
+
 }

+ 2 - 2
tests/official-postgresql-repos.pp

@@ -12,8 +12,8 @@
 # still need to use the 'postgresql' class to specify the postgres version
 # number, though, in order for the other classes to be able to find the
 # correct paths to the postgres dirs.
-class { "postgresql":
+class { 'postgresql':
     version               => '9.2',
     manage_package_repo   => true,
 }->
-class { "postgresql::server": }
+class { 'postgresql::server': }

+ 1 - 1
tests/postgresql_pgconf_extras.pp

@@ -8,7 +8,7 @@ class { 'postgresql::server':
     },
 }
 
-include "postgresql::params"
+include 'postgresql::params'
 
 $pg_conf_include_file = "${postgresql::params::confdir}/postgresql_puppet_extras.conf"
 

+ 4 - 4
tests/postgresql_tablespace.pp

@@ -12,10 +12,10 @@ file { '/tmp':
   ensure => 'directory',
 }
 file { '/tmp/pg_tablespaces':
-  ensure => 'directory',
-  owner  => 'postgres',
-  group  => 'postgres',
-  mode   => 700,
+  ensure  => 'directory',
+  owner   => 'postgres',
+  group   => 'postgres',
+  mode    => '0700',
   require => File['/tmp'],
 }