Permalink
Browse files

Ensures compliances with style guide

  • Loading branch information...
1 parent f591e1c commit dba78e7404a42ca49684446dcde1d3d0ce83b030 Garrett Honeycutt committed Oct 4, 2012
@@ -4,7 +4,7 @@
module Puppet::Parser::Functions
newfunction(:write_erl_config, :type => :rvalue, :doc => <<-DOC) do |*args|
- Output an erlang configuration from the given hash.
+ Output an erlang configuration from the given hash.
DOC
raise(Puppet::ParseError, "write_erl_config(): Wrong number of arguments " +
@@ -5,11 +5,11 @@
require 'digest'
Puppet::Type.type(:httpfile).provide(:ruby) do
-
+
desc "Download the file with Ruby"
-
+
has_feature :hash
-
+
def hash
return @hash if @hash
if resource.parameter(:hash).was_uri then
@@ -24,16 +24,16 @@ def hash
# create the file by downloading it
#
- # pre-condition:
- # exists? has been called and returned false
+ # pre-condition:
+ # exists? has been called and returned false
def create
# clean badly hashing files
if File.exists? resource[:path] then
FileUtils.rm resource[:path]
info 'cleaned out existing file, since it hashed badly or was outdated'
end
-
+
digester = Digest::SHA2.new
uri = resource[:source]
@@ -49,37 +49,37 @@ def create
end
end
end
-
+
info 'download complete, verifying file integrity'
unless hash == digester.hexdigest
raise Puppet::Error, "Data at URI[#{uri.to_s}]/#{digester.hexdigest}]\
- didn\'t match expected Httpfile[#{hash}], please retry or correct the hash."
+ didn\'t match expected Httpfile[#{hash}], please retry or correct the hash."
end
-
+
end
- # remove the file if it exists, no matter its hash
+ # remove the file if it exists, no matter its hash
def destroy
FileUtils.rm resource[:path] if File.exists? resource[:path]
end
-
+
# it exists if it exists and it hashes properly
def exists?
return false unless File.exists? resource[:path]
-
+
digester = Digest::SHA2.new
-
+
File.open resource[:path] do |file|
buffer = ''
while not file.eof
file.read 512, buffer
digester.update buffer
end
end
-
+
digester.hexdigest == hash
end
-
+
end
@@ -2,23 +2,23 @@
Puppet::Type.newtype(:httpfile) do
include Puppet::Util::MethodHelper
-
+
@doc = 'Download and verify files through HTTP'
-
+
feature :hash, 'The ability to hash the downloaded file', :methods => [:hash]
-
+
ensurable do
newvalue :present do
provider.create unless provider.exists?
nil # autogen event if returning nil
end
-
+
newvalue :absent do
provider.destroy
nil
end
end
-
+
newparam :source do
desc 'Where to download the file from'
@@ -30,21 +30,21 @@
fail Puppet::Error, "The value '#{v}' doesn't parse. #{e.to_s}"
end
end
-
+
munge { |v| URI.parse(v) }
end
-
+
newparam :hash, :required_features => %w{hash} do
-
+
attr_writer :is_uri
-
+
desc 'What is the hash of the file or where from to download the hash?'
-
+
validate do |v|
v || fail(Puppet::Error, 'empty or undefined hash property')
end
-
+
munge do |v|
v = v.strip
if is_uri v then
@@ -57,27 +57,27 @@
def is_uri v
return @is_uri unless @is_uri.nil?
return @is_uri = true if v.is_a? URI
-
+
begin
URI.parse v
@is_uri = true
rescue URI::InvalidURIError => e
@is_uri = false
info "#{v} wasn't uri: #{e}"
end
-
+
@is_uri
end
-
+
def was_uri ; @is_uri ; end
end
-
+
newparam :path do
-
+
desc "Where to place the downloaded file"
-
+
isnamevar
-
+
validate do |value|
unless Puppet::Util.absolute_path?(value)
fail Puppet::Error, "File paths must be fully qualified, not '#{value}'"
@@ -87,6 +87,6 @@ def was_uri ; @is_uri ; end
munge do |value|
::File.expand_path(value)
end
-
+
end
-end
+end
View
@@ -36,25 +36,25 @@
$appcfg = merge({
kernel => {
inet_dist_listen_min => 6000,
- inet_dist_listen_max => 7999
+ inet_dist_listen_max => 7999,
},
- riak_api => {
+ riak_api => {
pb_ip => $::ipaddress,
- bp_port => 8087
+ bp_port => 8087,
},
riak_core => {
- ring_state_dir => "${$riak::params::data_dir}/ring",
+ ring_state_dir => "${$riak::params::data_dir}/ring",
ring_creation_size => 64,
http => {
- "__string_${$::ipaddress}" => 8098
+ "__string_${$::ipaddress}" => 8098,
},
- handoff_port => 8099,
- dtrace_support => false,
- platform_bin_dir => $riak::params::bin_dir,
- platform_data_dir => $riak::params::data_dir,
- platform_etc_dir => $riak::params::etc_dir,
- platform_lib_dir => $riak::params::lib_dir,
- platform_log_dir => $riak::params::log_dir
+ handoff_port => 8099,
+ dtrace_support => false,
+ platform_bin_dir => $riak::params::bin_dir,
+ platform_data_dir => $riak::params::data_dir,
+ platform_etc_dir => $riak::params::etc_dir,
+ platform_lib_dir => $riak::params::lib_dir,
+ platform_log_dir => $riak::params::log_dir,
},
riak_kv => {
storage_backend => '__atom_riak_kv_bitcask_backend',
@@ -69,83 +69,81 @@
http_url_encoding => 'on',
vnode_vclocks => true,
legacy_keylisting => false,
- listkeys_backpressure => true
+ listkeys_backpressure => true,
},
riak_search => {
- enabled => false
+ enabled => false,
},
merge_index => {
data_root => "${$riak::params::data_dir}/merge_index",
buffer_rollover_size => 1048576,
- max_compact_segments => 20
+ max_compact_segments => 20,
},
bitcask => {
- data_root => "${$riak::params::data_dir}/bitcask"
+ data_root => "${$riak::params::data_dir}/bitcask",
},
leveldb => {
- data_root => "${$riak::params::data_dir}/leveldb"
+ data_root => "${$riak::params::data_dir}/leveldb",
},
lager => {
handlers => {
lager_file_backend => [
- ['__tuple', $riak::params::error_log, '__atom_error',
- 10485760, '$D0', 5],
- ['__tuple', $riak::params::info_log, '__atom_info',
- 10485760, '$D0', 5]
+ ['__tuple', $riak::params::error_log, '__atom_error', 10485760, '$D0', 5],
+ ['__tuple', $riak::params::info_log, '__atom_info', 10485760, '$D0', 5],
],
crash_log => $riak::params::crash_log,
crash_log_msg_side => 65536,
crash_log_size => 10485760,
crash_log_date => '$D0',
crash_log_count => 5,
- error_logger_redirect => true
+ error_logger_redirect => true,
}
},
riak_sysmon => {
- process_limit => 20,
- post_limit => 2,
- gc_ms_limit => 100,
+ process_limit => 20,
+ post_limit => 2,
+ gc_ms_limit => 100,
heap_word_limit => 40111000,
- busy_port => true,
- busy_dist_port => true
+ busy_port => true,
+ busy_dist_port => true,
},
sasl => {
sasl_error_logger => false,
- utc_log => true
+ utc_log => true,
},
riak_control => {
- enabled => false,
- auth => 'userlist',
- userlist => ['__tuple', 'user', 'pass'],
- admin => true
+ enabled => false,
+ auth => 'userlist',
+ userlist => ['__tuple', 'user', 'pass'],
+ admin => true,
},
}, $cfg)
$manage_file = $absent ? {
true => 'absent',
- default => 'present'
+ default => 'present',
}
$manage_template = $template ? {
'' => write_erl_config($appcfg),
- default => template($template)
+ default => template($template),
}
$manage_source = $source ? {
'' => undef,
- default => $source
+ default => $source,
}
anchor { 'riak::appconfig::start': } ->
file { [
$appcfg[riak_core][platform_log_dir],
$appcfg[riak_core][platform_lib_dir],
- $appcfg[riak_core][platform_data_dir]
+ $appcfg[riak_core][platform_data_dir],
]:
ensure => directory,
mode => '0755',
- owner => 'riak'
+ owner => 'riak',
}
file { "${$appcfg[riak_core][platform_etc_dir]}/app.config":
@@ -155,16 +153,16 @@
require => [
File["${$appcfg[riak_core][platform_log_dir]}"],
File["${$appcfg[riak_core][platform_lib_dir]}"],
- File["${$appcfg[riak_core][platform_data_dir]}"]
- ]
+ File["${$appcfg[riak_core][platform_data_dir]}"],
+ ],
}
anchor { 'riak::appconfig::end':
require => [
File["${$appcfg[riak_core][platform_etc_dir]}/app.config"],
File["${$appcfg[riak_core][platform_log_dir]}"],
File["${$appcfg[riak_core][platform_lib_dir]}"],
- File["${$appcfg[riak_core][platform_data_dir]}"]
- ]
+ File["${$appcfg[riak_core][platform_data_dir]}"],
+ ],
}
}
Oops, something went wrong.

0 comments on commit dba78e7

Please sign in to comment.