diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..e7a54b6 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + repositories: + stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" + concat: "https://github.com/puppetlabs/puppetlabs-concat.git" + symlinks: + tomcat: "#{source_dir}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a970b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.*.sw? +/pkg +/spec/fixtures/manifests +/spec/fixtures/modules +/.rspec_system +/.vagrant +/.bundle +/vendor +/Gemfile.lock +/junit +/log +.yardoc +coverage +.DS_Store diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..4b1ec0e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,152 @@ +# Relaxed.Ruby.Style + +AllCops: + Exclude: + - 'spec/fixtures/**/*' + - 'pkg/**/*' + +Style/Alias: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylealias + +Style/BeginBlock: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylebeginblock + +Style/BlockDelimiters: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters + +Style/Documentation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledocumentation + +Style/DotPosition: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledotposition + +Style/DoubleNegation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledoublenegation + +Style/EndBlock: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleendblock + +Style/FormatString: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleformatstring + +Style/IfUnlessModifier: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier + +Style/Lambda: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylelambda + +Style/ModuleFunction: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylemodulefunction + +Style/MultilineBlockChain: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain + +Style/NegatedIf: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylenegatedif + +Style/NegatedWhile: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile + +Style/ParallelAssignment: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleparallelassignment + +Style/PercentLiteralDelimiters: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters + +Style/PerlBackrefs: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs + +Style/Semicolon: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesemicolon + +Style/SignalException: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesignalexception + +Style/SingleLineBlockParams: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams + +Style/SingleLineMethods: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods + +Style/SpaceBeforeBlockBraces: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces + +Style/SpaceInsideParens: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens + +Style/SpecialGlobalVars: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars + +Style/StringLiterals: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylestringliterals + +Style/TrailingCommaInLiteral: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral + +Style/WhileUntilModifier: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier + +Lint/AmbiguousRegexpLiteral: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral + +Lint/AssignmentInCondition: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockNesting: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/LineLength: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +Metrics/BlockLength: + Enabled: false diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..e69de29 diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..bfb93a7 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1 @@ +Bryan Belanger diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e6b9609 --- /dev/null +++ b/Gemfile @@ -0,0 +1,39 @@ +source 'https://rubygems.org' + +group :test do + gem 'metadata-json-lint' + gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 4.8' + gem 'puppetlabs_spec_helper' + gem 'rake' + gem 'rspec' + gem 'rspec-puppet' # , git: 'https://github.com/rodjek/rspec-puppet.git' + gem 'rspec-puppet-facts' + gem 'rubocop' + gem 'rubocop-rspec' + gem 'simplecov' + gem 'simplecov-console' + + gem 'puppet-blacksmith' + + gem 'puppet-lint-absolute_classname-check' + gem 'puppet-lint-classes_and_types_beginning_with_digits-check' + gem 'puppet-lint-leading_zero-check' + gem 'puppet-lint-resource_reference_syntax' + gem 'puppet-lint-trailing_comma-check' + gem 'puppet-lint-unquoted_string-check' + gem 'puppet-lint-version_comparison-check' +end + +group :development do + gem 'guard-rake' + gem 'travis' + gem 'travis-lint' +end + +group :system_tests do + gem 'beaker' + gem 'beaker-puppet_install_helper' + gem 'beaker-rspec' + + gem 'fog-aws' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..5edc793 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,556 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.5) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + ansi (1.5.0) + ast (2.3.0) + aws-sdk-v1 (1.67.0) + json (~> 1.4) + nokogiri (~> 1) + backports (3.10.3) + beaker (3.27.0) + beaker-aws (~> 0.1) + beaker-docker (~> 0.1) + beaker-google (~> 0.1) + beaker-hiera (~> 0.0) + beaker-hostgenerator + beaker-openstack (~> 0.1) + beaker-puppet (~> 0.0) + beaker-vagrant (~> 0.1) + beaker-vcloud (~> 0.1) + beaker-vmpooler (~> 1.0) + beaker-vmware (~> 0.1) + hocon (~> 1.0) + in-parallel (~> 0.1) + inifile (~> 3.0) + minitar (~> 0.6) + minitest (~> 5.4) + net-scp (~> 1.2) + net-ssh (~> 4.0) + open_uri_redirections (~> 0.2.1) + pry-byebug (~> 3.4.2) + rb-readline (~> 0.5.3) + rsync (~> 1.0.9) + stringify-hash (~> 0.0) + thor (~> 0.19) + beaker-aws (0.3.0) + aws-sdk-v1 (~> 1.57) + stringify-hash (~> 0.0.0) + beaker-docker (0.2.0) + docker-api + stringify-hash (~> 0.0.0) + beaker-google (0.1.0) + google-api-client (~> 0.9) + stringify-hash (~> 0.0.0) + beaker-hiera (0.1.1) + stringify-hash (~> 0.0.0) + beaker-hostgenerator (1.1.3) + deep_merge (~> 1.0) + stringify-hash (~> 0.0.0) + beaker-openstack (0.1.0) + fog (~> 1.38) + stringify-hash (~> 0.0.0) + beaker-puppet (0.8.0) + in-parallel (~> 0.1) + oga + stringify-hash (~> 0.0.0) + beaker-puppet_install_helper (0.7.1) + beaker (>= 2.0) + beaker-rspec (6.2.1) + beaker (~> 3.0) + rspec (~> 3.0) + serverspec (~> 2) + specinfra (~> 2) + beaker-vagrant (0.1.0) + stringify-hash (~> 0.0.0) + beaker-vcloud (0.2.0) + beaker-vmpooler + beaker-vmware + rbvmomi (~> 1.9) + stringify-hash (~> 0.0.0) + beaker-vmpooler (1.1.0) + stringify-hash (~> 0.0.0) + beaker-vmware (0.2.0) + fission (~> 0.4) + rbvmomi (~> 1.9) + stringify-hash (~> 0.0.0) + builder (3.2.3) + byebug (9.0.6) + coderay (1.1.2) + connection_pool (2.2.1) + declarative (0.0.10) + declarative-option (0.1.0) + deep_merge (1.1.1) + diff-lcs (1.3) + docile (1.1.5) + docker-api (1.33.6) + excon (>= 0.38.0) + json + domain_name (0.5.20170404) + unf (>= 0.0.5, < 1.0.0) + ethon (0.11.0) + ffi (>= 1.3.0) + excon (0.59.0) + facter (2.5.1) + facterdb (0.4.1) + facter + jgrep + faraday (0.13.1) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.12.2) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.0) + ffi (1.9.18) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.41.0) + fog-aliyun (>= 0.1.0) + fog-atmos + fog-aws (>= 0.6.0) + fog-brightbox (~> 0.4) + fog-cloudatcost (~> 0.1.0) + fog-core (~> 1.45) + fog-digitalocean (>= 0.3.0) + fog-dnsimple (~> 1.0) + fog-dynect (~> 0.0.2) + fog-ecloud (~> 0.1) + fog-google (<= 0.1.0) + fog-internet-archive + fog-joyent + fog-json + fog-local + fog-openstack + fog-powerdns (>= 0.1.1) + fog-profitbricks + fog-rackspace + fog-radosgw (>= 0.0.2) + fog-riakcs + fog-sakuracloud (>= 0.0.4) + fog-serverlove + fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-vsphere (>= 0.4.0) + fog-xenserver + fog-xml (~> 0.1.1) + ipaddress (~> 0.5) + json (>= 1.8, < 2.0) + fog-aliyun (0.2.0) + fog-core (~> 1.27) + fog-json (~> 1.0) + ipaddress (~> 0.8) + xml-simple (~> 1.1) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (1.4.1) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.13.0) + fog-core (~> 1.22) + fog-json + inflecto (~> 0.0.2) + fog-cloudatcost (0.1.2) + fog-core (~> 1.36) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-core (1.45.0) + builder + excon (~> 0.58) + formatador (~> 0.2) + fog-digitalocean (0.3.0) + fog-core (~> 1.42) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.5) + fog-dnsimple (1.0.0) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-dynect (0.0.3) + fog-core + fog-json + fog-xml + fog-ecloud (0.3.0) + fog-core + fog-xml + fog-google (0.1.0) + fog-core + fog-json + fog-xml + fog-internet-archive (0.0.1) + fog-core + fog-json + fog-xml + fog-joyent (0.0.1) + fog-core (~> 1.42) + fog-json (>= 1.0) + fog-json (1.0.2) + fog-core (~> 1.0) + multi_json (~> 1.10) + fog-local (0.4.0) + fog-core (~> 1.27) + fog-openstack (0.1.22) + fog-core (>= 1.40) + fog-json (>= 1.0) + ipaddress (>= 0.8) + fog-powerdns (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + fog-profitbricks (4.0.0) + fog-core (~> 1.42) + fog-json (~> 1.0) + fog-rackspace (0.1.5) + fog-core (>= 1.35) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.8) + fog-radosgw (0.0.5) + fog-core (>= 1.21.0) + fog-json + fog-xml (>= 0.0.1) + fog-riakcs (0.1.0) + fog-core + fog-json + fog-xml + fog-sakuracloud (1.7.5) + fog-core + fog-json + fog-serverlove (0.1.2) + fog-core + fog-json + fog-softlayer (1.1.4) + fog-core + fog-json + fog-storm_on_demand (0.1.1) + fog-core + fog-json + fog-terremark (0.1.0) + fog-core + fog-xml + fog-vmfusion (0.1.0) + fission + fog-core + fog-voxel (0.1.0) + fog-core + fog-xml + fog-vsphere (1.13.1) + fog-core + rbvmomi (~> 1.9) + fog-xenserver (0.3.0) + fog-core + fog-xml + fog-xml (0.1.3) + fog-core + nokogiri (>= 1.5.11, < 2.0.0) + formatador (0.2.5) + gettext (3.2.4) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.28) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + gh (0.14.0) + addressable + backports + faraday (~> 0.8) + multi_json (~> 1.0) + net-http-persistent (>= 2.7) + net-http-pipeline + google-api-client (0.10.3) + addressable (~> 2.3) + googleauth (~> 0.5) + httpclient (~> 2.7) + hurley (~> 0.1) + memoist (~> 0.11) + mime-types (>= 1.6) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + googleauth (0.6.1) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) + logging (~> 2.0) + memoist (~> 0.12) + multi_json (~> 1.11) + os (~> 0.9) + signet (~> 0.7) + guard (2.14.1) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-rake (1.0.0) + guard + rake + hiera (3.4.2) + highline (1.7.8) + hirb (0.7.3) + hocon (1.2.5) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + hurley (0.2) + in-parallel (0.1.17) + inflecto (0.0.2) + inifile (3.0.0) + ipaddress (0.8.3) + jgrep (1.5.0) + json (1.8.6) + json-schema (2.8.0) + addressable (>= 2.4) + json_pure (1.8.6) + jwt (2.1.0) + launchy (2.4.3) + addressable (~> 2.3) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + little-plugger (1.1.4) + locale (2.1.2) + logging (2.2.2) + little-plugger (~> 1.1) + multi_json (~> 1.10) + lumberjack (1.0.12) + mcollective-client (2.11.3) + json + stomp + systemu + memoist (0.16.0) + metaclass (0.0.4) + metadata-json-lint (2.0.2) + json-schema (~> 2.8) + spdx-licenses (~> 1.0) + method_source (0.9.0) + mime-types (2.99.3) + mini_portile2 (2.3.0) + minitar (0.6.1) + minitest (5.10.3) + mocha (1.3.0) + metaclass (~> 0.0.1) + multi_json (1.12.2) + multipart-post (2.0.0) + nenv (0.3.0) + net-http-persistent (3.0.0) + connection_pool (~> 2.2) + net-http-pipeline (1.0.1) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (4.2.0) + net-telnet (0.1.1) + netrc (0.11.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) + notiffany (0.1.1) + nenv (~> 0.1) + shellany (~> 0.0) + oga (2.11) + ast + ruby-ll (~> 2.1) + open_uri_redirections (0.2.1) + os (0.9.6) + parallel (1.12.0) + parser (2.4.0.0) + ast (~> 2.2) + powerpack (0.1.1) + pry (0.11.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-byebug (3.4.3) + byebug (>= 9.0, < 9.1) + pry (~> 0.10) + public_suffix (3.0.0) + puppet (4.10.8) + facter (> 2.0, < 4) + gettext-setup (>= 0.10, < 1) + hiera (>= 2.0, < 4) + json_pure (~> 1.8) + locale (~> 2.1) + puppet-blacksmith (3.4.0) + puppet (>= 2.7.16) + rest-client (~> 1.8.0) + puppet-lint (2.3.3) + puppet-lint-absolute_classname-check (0.2.4) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-classes_and_types_beginning_with_digits-check (0.1.2) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-leading_zero-check (0.1.1) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-resource_reference_syntax (1.0.10) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-trailing_comma-check (0.3.2) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-unquoted_string-check (0.3.0) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-version_comparison-check (0.2.1) + puppet-lint (>= 1.0, < 3.0) + puppet-syntax (2.4.1) + rake + puppetlabs_spec_helper (2.4.0) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + pusher-client (0.6.2) + json + websocket (~> 1.0) + rainbow (2.2.2) + rake + rake (12.2.1) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rb-readline (0.5.5) + rbvmomi (1.11.3) + builder (~> 3.0) + json (>= 1.8) + nokogiri (~> 1.5) + trollop (~> 2.1) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + rest-client (1.8.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) + retriable (3.1.1) + rspec (3.7.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-core (3.7.0) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-its (1.2.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-puppet (2.6.9) + rspec + rspec-puppet-facts (1.8.0) + facter + facterdb (>= 0.3.0) + json + mcollective-client + puppet + rspec-support (3.7.0) + rsync (1.0.9) + rubocop (0.51.0) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-rspec (1.19.0) + rubocop (>= 0.51.0) + ruby-ll (2.1.2) + ansi + ast + ruby-progressbar (1.9.0) + ruby_dep (1.5.0) + serverspec (2.41.2) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.72) + sfl (2.3) + shellany (0.0.1) + signet (0.8.1) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simplecov (0.15.1) + docile (~> 1.1.0) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-console (0.4.2) + ansi + hirb + simplecov + simplecov-html (0.10.2) + spdx-licenses (1.1.0) + specinfra (2.72.0) + net-scp + net-ssh (>= 2.7, < 5.0) + net-telnet + sfl + stomp (1.4.4) + stringify-hash (0.0.2) + systemu (2.6.5) + text (1.3.1) + thor (0.20.0) + travis (1.8.8) + backports + faraday (~> 0.9) + faraday_middleware (~> 0.9, >= 0.9.1) + gh (~> 0.13) + highline (~> 1.6) + launchy (~> 2.1) + pusher-client (~> 0.4) + typhoeus (~> 0.6, >= 0.6.8) + travis-lint (2.0.0) + json + trollop (2.1.2) + typhoeus (0.8.0) + ethon (>= 0.8.0) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.4) + unicode-display_width (1.3.0) + websocket (1.2.4) + xml-simple (1.1.5) + +PLATFORMS + ruby + x86_64-darwin-16 + +DEPENDENCIES + beaker + beaker-puppet_install_helper + beaker-rspec + fog-aws + guard-rake + metadata-json-lint + puppet (~> 4.8) + puppet-blacksmith + puppet-lint-absolute_classname-check + puppet-lint-classes_and_types_beginning_with_digits-check + puppet-lint-leading_zero-check + puppet-lint-resource_reference_syntax + puppet-lint-trailing_comma-check + puppet-lint-unquoted_string-check + puppet-lint-version_comparison-check + puppetlabs_spec_helper + rake + rspec + rspec-puppet + rspec-puppet-facts + rubocop + rubocop-rspec + simplecov + simplecov-console + travis + travis-lint + +BUNDLED WITH + 1.16.0.pre.3 diff --git a/Rakefile b/Rakefile index d1e11f7..a62bfae 100644 --- a/Rakefile +++ b/Rakefile @@ -1,18 +1,75 @@ require 'rubygems' +require 'bundler/setup' + require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet_blacksmith/rake_tasks' +require 'puppet/version' require 'puppet-lint/tasks/puppet-lint' -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] +require 'puppet-syntax/tasks/puppet-syntax' +require 'rubocop/rake_task' + +if RUBY_VERSION >= '1.9' + require 'rubocop/rake_task' + RuboCop::RakeTask.new +end -desc "Validate manifests, templates, and ruby files" +desc 'Validate manifests, templates, and ruby files' task :validate do Dir['manifests/**/*.pp'].each do |manifest| sh "puppet parser validate --noop #{manifest}" end - Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| - sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ + Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| + sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures} end Dir['templates/**/*.erb'].each do |template| sh "erb -P -x -T '-' #{template} | ruby -c" end end + +# require 'controlrepo/rake_tasks' + +# These gems aren't always present, for instance +# on Travis with --without development +begin + require 'puppet_blacksmith/rake_tasks' +rescue LoadError # rubocop:disable Lint/HandleExceptions +end + +# RuboCop::RakeTask.new + +Rake::Task[:lint].clear + +PuppetLint.configuration.relative = true +PuppetLint.configuration.disable_80chars +PuppetLint.configuration.disable_class_inherits_from_params_class +PuppetLint.configuration.disable_class_parameter_defaults +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp'] + +exclude_paths = [ + "bundle/**/*", + "pkg/**/*", + "vendor/**/*", + "spec/**/*" +] + +PuppetLint::RakeTask.new :lint do |config| + config.ignore_paths = exclude_paths +end + +PuppetSyntax.exclude_paths = exclude_paths + +desc "Populate CONTRIBUTORS file" +task :contributors do + system("git log --format='%aN' | sort -u > CONTRIBUTORS") +end + +desc "Run syntax, lint, and spec tests." +task test: %i[ + syntax + metadata_lint + lint + validate + rubocop + spec +] diff --git a/manifests/init.pp b/manifests/init.pp index 7fea8be..43adcad 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -81,10 +81,9 @@ $install_base_path = '/opt/drush' $drush_exe_default = '/usr/local/bin/drush' - class{'drush::setup': } - -> class{'drush::config': } - ~> class{'drush::cacheclear': } + class{'::drush::setup': } + -> class{'::drush::config': } + ~> class{'::drush::cacheclear': } -> Class['drush'] } - diff --git a/manifests/install.pp b/manifests/install.pp index cc1eb33..e801768 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -60,9 +60,8 @@ exec { "${drush}-first-run": command => "su - -c '${drush_exe} status'", + path => '/bin:/usr/bin', require => File[$drush_exe], refreshonly => true, } - } - diff --git a/manifests/setup.pp b/manifests/setup.pp index 1824599..ff24a72 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -3,7 +3,6 @@ # Private class. # class drush::setup { - #private() if $caller_module_name != $module_name { warning("${name} is not part of the public API of the ${module_name} \ @@ -19,15 +18,17 @@ } } - concat{ 'drush-sh-profile': + concat { 'drush-sh-profile': ensure => present, path => '/etc/profile.d/drush.sh', } + concat::fragment { 'drush-sh-profile-header': target => 'drush-sh-profile', content => "# MANAGED BY PUPPET\n\n", order => 0, } + if $drush::php_path { validate_absolute_path($drush::php_path) concat::fragment { 'drush-sh-profile-php-path': @@ -36,6 +37,7 @@ order => 1, } } + if $drush::php_ini_path { validate_absolute_path($drush::php_ini_path) concat::fragment { 'drush-sh-profile-php-ini-path': @@ -44,6 +46,7 @@ order => 1, } } + if $drush::drush_ini_path { validate_absolute_path($drush::drush_ini_path) concat::fragment { 'drush-sh-profile-drush-ini-path': @@ -74,10 +77,11 @@ # {'6' => {'version' => '6'}, 'master' => {'version' => 'master'}} validate_array($drush::versions) $versions = parseyaml(template('drush/install-versions-hash.erb')) + $defaults = { install_type => $drush::install_type, autoupdate => $drush::autoupdate, - method => 'composer' + method => 'composer', } create_resources('drush::install', $versions, $defaults) @@ -91,4 +95,3 @@ } } - diff --git a/metadata.json b/metadata.json index 638c8d0..741f2ed 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "jonhattan-drush", - "version": "0.5.0", + "version": "0.6.0", "author": "jonhattan", "summary": "Installs several versions of Drush system-wide.", "license": "MIT", @@ -29,8 +29,7 @@ }, { "name": "puppetlabs/concat", - "version_requirement": ">=1.1.0 <2.0.0" + "version_requirement": ">=4.0.0 <5.0.0" } ] } - diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb new file mode 100644 index 0000000..12513b8 --- /dev/null +++ b/spec/classes/coverage_spec.rb @@ -0,0 +1 @@ +at_exit { RSpec::Puppet::Coverage.report! } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 5102d7c..43534a0 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,7 +1,19 @@ require 'spec_helper' + describe 'drush' do + context 'supported operating systems' do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + context "drush class without any parameters" do + it { is_expected.to compile.with_all_deps } - context 'with defaults for all parameters' do - it { should contain_class('drush') } + it { is_expected.to contain_class('drush') } + end + end + end end end diff --git a/spec/fixtures/modules/drush b/spec/fixtures/modules/drush new file mode 120000 index 0000000..671d289 --- /dev/null +++ b/spec/fixtures/modules/drush @@ -0,0 +1 @@ +/Users/bryanbelanger/Documents/git/drush \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5fda588..3d64a8e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,21 @@ -dir = File.expand_path(File.dirname(__FILE__)) -$LOAD_PATH.unshift File.join(dir, 'lib') +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +# require 'rubocop-rspec' -require 'mocha' -require 'puppet' -require 'rspec' -require 'spec/autorun' +include RspecPuppetFacts -Spec::Runner.configure do |config| - config.mock_with :mocha +require 'simplecov' +require 'simplecov-console' + +SimpleCov.start do + add_filter '/spec' + add_filter '/vendor' + formatter SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console + ]) end -# We need this because the RAL uses 'should' as a method. This -# allows us the same behaviour but with a different method name. -class Object - alias :must :should +RSpec.configure do |c| + c.hiera_config = File.expand_path(File.join(__FILE__, '../fixtures/hiera.yaml')) end diff --git a/tests/init.pp b/tests/init.pp index 9175faa..8bd554f 100644 --- a/tests/init.pp +++ b/tests/init.pp @@ -9,4 +9,4 @@ # Learn more about module testing here: # http://docs.puppetlabs.com/guides/tests_smoke.html # -include drush +include ::drush