Skip to content

Commit

Permalink
Quality enhancements for Code Review
Browse files Browse the repository at this point in the history
Rewrite of deploy provider with support of determining deployment
digest. Now deploy provider checks if it should deploy an artifact based
on their SHA1 digest.

Also, adding some quality enhancements to pass Code Review
without errors, that's Code Climate and CodeCov.

Should fix issues: #70, #71
  • Loading branch information
cardil committed Sep 23, 2018
1 parent 31b21bf commit 1c2d57f
Show file tree
Hide file tree
Showing 89 changed files with 5,569 additions and 3,078 deletions.
343 changes: 45 additions & 298 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/deploy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$artifact = 'servlet3-webapp'
$group = 'org/glassfish/jersey/examples'
$file = "${artifact}-${version}.war"
$deployment = "${artifact}.war"
$fullpath = "${sourcedir}/${file}"

exec { "wget https://repo1.maven.org/maven2/${group}/${artifact}/${version}/${file}":
Expand All @@ -17,7 +18,7 @@
require => Package['wget'],
}

jboss::deploy { $file:
jboss::deploy { $deployment:
ensure => 'present',
path => $fullpath,
subscribe => Exec['wget'],
Expand Down
8 changes: 8 additions & 0 deletions examples/modified/clientry.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include jboss

jboss::clientry { '/subsystem=messaging/hornetq-server=default':
ensure => 'present',
properties => {
'security-enabled' => true,
}
}
36 changes: 36 additions & 0 deletions examples/modified/datasource.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class { 'jboss':
enableconsole => true,
}

jboss::user { 'admin':
password => 'seCret1!',
}

jboss::datasource { 'test-datasource':
ensure => 'present',
xa => true,
username => 'test-username-changed',
password => 'test-password-1',
jdbcscheme => 'h2:mem',
dbname => 'testing2',
host => '',
port => '',
driver => {
'name' => 'h2',
'driver-xa-datasource-class-name' => 'org.h2.jdbcx.JdbcDataSource'
}
}

jboss::datasource { 'test-xa-datasource':
ensure => 'present',
xa => false,
username => 'test-username-changed',
password => 'test-password-changed',
jdbcscheme => 'h2:mem',
dbname => 'testing-xa-2;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE',
host => '',
port => '',
driver => {
'name' => 'h2'
}
}
26 changes: 26 additions & 0 deletions examples/modified/deploy.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include jboss

ensure_packages(['wget'])

$sourcedir = '/usr/src'
$version = '2.23'
$artifact = 'servlet3-webapp'
$group = 'org/glassfish/jersey/examples'
$file = "${artifact}-${version}.war"
$deployment = "${artifact}.war"
$fullpath = "${sourcedir}/${file}"

exec { "wget https://repo1.maven.org/maven2/${group}/${artifact}/${version}/${file}":
alias => 'wget',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
cwd => $sourcedir,
creates => $fullpath,
require => Package['wget'],
}

jboss::deploy { $deployment:
ensure => 'present',
path => $fullpath,
subscribe => Exec['wget'],
# servergroup => 'foobar-group', # on domain mode
}
11 changes: 11 additions & 0 deletions examples/modified/jmsqueue.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include jboss

jboss::jmsqueue { 'app-mails':
ensure => 'present',
durable => true,
entries => [
'queue/app-mails',
'java:jboss/exported/jms/queue/app-mails',
'queue/x-app-mails',
],
}
33 changes: 33 additions & 0 deletions examples/modified/resourceadapter.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include jboss

ensure_packages(['wget'])

$sourcedir = '/usr/src'
$version = '2.1.0'
$artifact = 'genericconnector-rar'
$group = 'ch/maxant'
$file = "${artifact}-${version}.rar"
$fullpath = "${sourcedir}/${file}"

exec { "wget https://repo1.maven.org/maven2/${group}/${artifact}/${version}/${file}":
alias => 'wget',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
cwd => $sourcedir,
creates => $fullpath,
require => Package['wget'],
}

jboss::resourceadapter { 'genericconnector.rar':
archive => 'genericconnector.rar',
transactionsupport => 'XATransaction',
classname => 'ch.maxant.generic_jca_adapter.ManagedTransactionAssistanceFactory',
jndiname => 'java:/jboss/jca-generic-x',
}

jboss::deploy { 'genericconnector.rar':
path => $fullpath,
require => [
JBoss::Resourceadapter['genericconnector.rar'],
Exec['wget'],
],
}
14 changes: 14 additions & 0 deletions examples/modified/securitydomain.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include jboss

jboss::securitydomain { 'db-auth-default':
ensure => 'present',
code => 'Database',
codeflag => 'required',
moduleoptions => {
'dsJndiName' => 'java:jboss/datasources/x-default-db',
'principalsQuery' => 'select \'password\' from user u where u.login = ?',
'hashUserPassword' => true,
'hashStorePassword' => false,
'rolesQuery' => 'select r.name, \'roles\' from users',
},
}
6 changes: 6 additions & 0 deletions examples/modified/user.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include jboss

jboss::user { 'admin':
ensure => 'present',
password => 't0p-5seCret1!',
}
102 changes: 1 addition & 101 deletions lib/puppet/type/jboss_confignode.rb
Original file line number Diff line number Diff line change
@@ -1,105 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), '../../puppet_x/coi/jboss'))

Puppet::Type.newtype(:jboss_confignode) do

@doc = "Generic configuration entry for JBoss Application Sever"

newproperty(:ensure) do
desc "Whether a configuration node should be in one of `present`, `absent`, `running`, `stopped`, `disabled` or `enabled` state."

newvalues :stopped, :running, :present, :absent, :enabled, :disabled

aliasvalue(:true, :present)
aliasvalue(:false, :absent)

end
newparam(:name) do
desc "The name of resource"
end

newparam(:path) do
desc "The JBoss configuration path to be ensured"
end

newproperty(:properties) do
desc "Additional properties for node"

munge do |value|
if %w{absent undef}.include?(value)
value.to_sym
else
matcher = PuppetX::Coi::Jboss::BuildinsUtils::HashlikeMatcher.new(value)
unless matcher.hashlike?
{}
else
value
end
end
end

def change_to_s(current, desire)
absentlike = PuppetX::Coi::Jboss::Constants::ABSENTLIKE_WITH_S
changes = []
keys = []
keys.concat(desire.keys) unless absentlike.include?(desire)
keys.concat(current.keys) unless absentlike.include?(current)
keys.uniq.sort.each do |key|
desired_value = if absentlike.include?(desire) then desire else desire[key] end
current_value = if absentlike.include?(current) then current else current[key] end
if absentlike.include?(desired_value) and not absentlike.include?(current_value) then
message = "property '#{key}' was #{current_value.inspect} and has been removed"
elsif absentlike.include?(current_value) and not absentlike.include?(desired_value)
message = "property '#{key}' has been set to #{desired_value.inspect}"
else
message = "property '#{key}' has changed from #{current_value.inspect} to #{desired_value.inspect}"
end
changes << message unless current_value == desired_value
end
changes.join ', '
end
end

newparam(:profile) do
desc "The JBoss profile name"
defaultto "full"
end

newparam(:runasdomain, :boolean => true) do
desc "Indicate that server is in domain mode"
newvalues :true, :false
defaultto :true

munge do |val|
val == :true or val == true
end
end

newparam(:controller) do
desc "Domain controller host:port address"
validate do |value|
if value == nil or value.to_s == 'undef'
raise ArgumentError, "Domain controller must be provided"
end
end
end

newparam :ctrluser do
desc 'A user name to connect to controller'
end

newparam :ctrlpasswd do
desc 'A password to be used to connect to controller'
end

newparam :retry do
desc "Number of retries."
defaultto 3
end

newparam :retry_timeout do
desc "Retry timeout in seconds"
defaultto 1
end


PuppetX::Coi::Jboss::Type::ConfigNode.define(self)
end
Loading

0 comments on commit 1c2d57f

Please sign in to comment.