From 0dcd91b6e8d2b2519228c534fe4976e9d2a3a1d6 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 11 Jan 2023 17:20:51 +0000 Subject: [PATCH 1/3] (CONT-356) Syntax update Code now compliant with the following rules: relative_classname_inclusion relative_classname_reference parameter_documentation parameter_types top scope facts legacy facts anchor resource --- .puppet-lint.rc | 4 ---- .sync.yml | 6 ------ Rakefile | 5 ----- manifests/adopt.pp | 34 +++++++++++++++++----------------- manifests/adoptium.pp | 27 +++++++++++++-------------- manifests/download.pp | 30 +++++++++++++++--------------- manifests/init.pp | 20 +++++++++----------- manifests/sap.pp | 25 ++++++++++++------------- 8 files changed, 66 insertions(+), 85 deletions(-) diff --git a/.puppet-lint.rc b/.puppet-lint.rc index c5be7aab..cc96ece0 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,5 +1 @@ --relative ---no-parameter_types-check ---no-relative_classname_inclusion-check ---no-legacy_facts-check ---no-anchor_resource-check diff --git a/.sync.yml b/.sync.yml index 3b69f7ad..d03bffc6 100644 --- a/.sync.yml +++ b/.sync.yml @@ -28,9 +28,3 @@ spec/spec_helper.rb: unmanaged: false .travis.yml: delete: true -Rakefile: - extra_disabled_lint_checks: - - parameter_types - - relative_classname_inclusion - - legacy_facts - - anchor_resource diff --git a/Rakefile b/Rakefile index 21c1ccca..2906c15b 100644 --- a/Rakefile +++ b/Rakefile @@ -42,11 +42,6 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') -PuppetLint.configuration.send('disable_parameter_types') -PuppetLint.configuration.send('disable_relative_classname_inclusion') -PuppetLint.configuration.send('disable_legacy_facts') -PuppetLint.configuration.send('disable_anchor_resource') - if Bundler.rubygems.find_name('github_changelog_generator').any? GitHubChangelogGenerator::RakeTask.new :changelog do |config| diff --git a/manifests/adopt.pp b/manifests/adopt.pp index fde321b8..5b6ccc16 100644 --- a/manifests/adopt.pp +++ b/manifests/adopt.pp @@ -13,7 +13,8 @@ # Major version which should be installed, e.g. '8u101' or '9.0.4'. Must be used together with version_minor. # # @param version_minor -# Minor version which should be installed, e.g. 'b12' (for version = '8') or '11' (for version != '8'). Must be used together with version_major. +# Minor version which should be installed, e.g. 'b12' (for version = '8') or '11' (for version != '8'). +# Must be used together with version_major. # # @param java # Type of Java Standard Edition to install, jdk or jre. @@ -32,7 +33,7 @@ # /usr/lib/jvm for Debian and /usr/java for RedHat. # # @param manage_basedir -# Whether to manage the basedir directory. Defaults to false. +# Whether to manage the basedir directory. # Note: /usr/lib/jvm is managed for Debian by default, separate from this parameter. # # @param package_type @@ -47,22 +48,22 @@ # The name for the optional symlink in the installation directory. # define java::adopt ( - $ensure = 'present', - $version = '8', - $version_major = undef, - $version_minor = undef, - $java = 'jdk', - $proxy_server = undef, - $proxy_type = undef, - $url = undef, - $basedir = undef, - $manage_basedir = true, - $package_type = undef, - $manage_symlink = false, - $symlink_name = undef, + String[1] $ensure = 'present', + String[1] $version = '8', + Optional[String] $version_major = undef, + Optional[String] $version_minor = undef, + String $java = 'jdk', + Optional[String] $proxy_server = undef, + Optional[String] $proxy_type = undef, + Optional[String] $url = undef, + Optional[String] $basedir = undef, + Boolean $manage_basedir = true, + Optional[String] $package_type = undef, + Boolean $manage_symlink = false, + Optional[String] $symlink_name = undef, ) { # archive module is used to download the java package - include ::archive + include archive # validate java Standard Edition to download if $java !~ /(jre|jdk)/ { @@ -188,7 +189,6 @@ # set java architecture nomenclature $os_architecture = $facts['os']['architecture'] ? { - undef => $facts['architecture'], default => $facts['os']['architecture'] } diff --git a/manifests/adoptium.pp b/manifests/adoptium.pp index 6f87e602..e1cf2ce6 100644 --- a/manifests/adoptium.pp +++ b/manifests/adoptium.pp @@ -42,21 +42,21 @@ # The name for the optional symlink in the installation directory. # define java::adoptium ( - $ensure = 'present', - $version_major = undef, - $version_minor = undef, - $version_patch = undef, - $version_build = undef, - $proxy_server = undef, - $proxy_type = undef, - $url = undef, - $basedir = undef, - $manage_basedir = true, - $manage_symlink = false, - $symlink_name = undef, + String[1] $ensure = 'present', + Optional[String] $version_major = undef, + Optional[String] $version_minor = undef, + Optional[String] $version_patch = undef, + Optional[String] $version_build = undef, + Optional[String] $proxy_server = undef, + Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef, + Optional[String] $url = undef, + Optional[String] $basedir = undef, + Boolean $manage_basedir = true, + Boolean $manage_symlink = false, + Optional[String] $symlink_name = undef, ) { # archive module is used to download the java package - include ::archive + include archive $install_path = "jdk-${version_major}.${version_minor}.${version_patch}+${version_build}" @@ -93,7 +93,6 @@ # set java architecture nomenclature $os_architecture = $facts['os']['architecture'] ? { - undef => $facts['architecture'], default => $facts['os']['architecture'] } diff --git a/manifests/download.pp b/manifests/download.pp index 8c31fbef..85e24384 100644 --- a/manifests/download.pp +++ b/manifests/download.pp @@ -54,21 +54,21 @@ # The name for the optional symlink in the installation directory. # define java::download ( - $ensure = 'present', - $version = '8', - $version_major = undef, - $version_minor = undef, - $java_se = 'jdk', - $proxy_server = undef, - $proxy_type = undef, - $url = undef, - $jce = false, - $jce_url = undef, - $basedir = undef, - $manage_basedir = false, - $package_type = undef, - $manage_symlink = false, - $symlink_name = undef, + String[1] $ensure = 'present', + String[1] $version = '8', + Optional[String] $version_major = undef, + Optional[String] $version_minor = undef, + String[1] $java_se = 'jdk', + Optional[String] $proxy_server = undef, + Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef, + Optional[String] $url = undef, + Boolean $jce = false, + Optional[String] $jce_url = undef, + Optional[String] $basedir = undef, + Boolean $manage_basedir = false, + Optional[String] $package_type = undef, + Boolean $manage_symlink = false, + Optional[String] $symlink_name = undef, ) { # archive module is used to download the java package include archive diff --git a/manifests/init.pp b/manifests/init.pp index 43811e7c..c70ee162 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,15 +36,15 @@ # environment variable. # class java ( - String $distribution = 'jdk', - Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present', - Optional[String] $package = undef, - Optional[Array] $package_options = undef, - Optional[String] $java_alternative = undef, - Optional[String] $java_alternative_path = undef, - Optional[String] $java_home = undef + String $distribution = 'jdk', + Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present', + Optional[String] $package = undef, + Optional[Array] $package_options = undef, + Optional[String] $java_alternative = undef, + Optional[String] $java_alternative_path = undef, + Optional[String] $java_home = undef ) { - include ::java::params + contain java::params $default_package_name = has_key($java::params::java, $distribution) ? { false => undef, @@ -118,12 +118,10 @@ } } - anchor { 'java::begin:': } - -> package { 'java': + package { 'java': ensure => $version, install_options => $package_options, name => $use_java_package_name, } -> class { 'java::config': } - -> anchor { 'java::end': } } diff --git a/manifests/sap.pp b/manifests/sap.pp index e8e893d2..1eb75990 100644 --- a/manifests/sap.pp +++ b/manifests/sap.pp @@ -26,7 +26,7 @@ # /usr/lib/jvm for Debian and /usr/java for RedHat. # # @param manage_basedir -# Whether to manage the basedir directory. Defaults to false. +# Whether to manage the basedir directory. # Note: /usr/lib/jvm is managed for Debian by default, separate from this parameter. # # @param manage_symlink @@ -36,19 +36,19 @@ # The name for the optional symlink in the installation directory. # define java::sap ( - $ensure = 'present', - $version = '8', - $version_full = undef, - $java = 'jdk', - $proxy_server = undef, - $proxy_type = undef, - $basedir = undef, - $manage_basedir = true, - $manage_symlink = false, - $symlink_name = undef, + String[1] $ensure = 'present', + String[1] $version = '8', + Optional[String] $version_full = undef, + String[1] $java = 'jdk', + Optional[String] $proxy_server = undef, + Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef, + Optional[String] $basedir = undef, + Boolean $manage_basedir = true, + Boolean $manage_symlink = false, + Optional[String] $symlink_name = undef, ) { # archive module is used to download the java package - include ::archive + include archive # validate java edition to download if $java !~ /(jre|jdk)/ { @@ -128,7 +128,6 @@ } $_os_architecture = $facts['os']['architecture'] ? { - undef => $facts['architecture'], default => $facts['os']['architecture'] } From cf18185a9195014253df260a1a714122bff9eca4 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius <97180854+LukasAud@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:38:34 +0000 Subject: [PATCH 2/3] Fix non-empty string missing Co-authored-by: Tim Meusel --- manifests/adopt.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/adopt.pp b/manifests/adopt.pp index 5b6ccc16..baa4fa66 100644 --- a/manifests/adopt.pp +++ b/manifests/adopt.pp @@ -52,7 +52,7 @@ String[1] $version = '8', Optional[String] $version_major = undef, Optional[String] $version_minor = undef, - String $java = 'jdk', + String[1] $java = 'jdk', Optional[String] $proxy_server = undef, Optional[String] $proxy_type = undef, Optional[String] $url = undef, From 6ff04d5b165498d11c146950fdc0c3313f367302 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 12 Jan 2023 15:31:17 +0000 Subject: [PATCH 3/3] Addressing $ensure datatype --- manifests/adopt.pp | 2 +- manifests/adoptium.pp | 2 +- manifests/download.pp | 2 +- manifests/sap.pp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/adopt.pp b/manifests/adopt.pp index baa4fa66..957a7f03 100644 --- a/manifests/adopt.pp +++ b/manifests/adopt.pp @@ -48,7 +48,7 @@ # The name for the optional symlink in the installation directory. # define java::adopt ( - String[1] $ensure = 'present', + Enum['present'] $ensure = 'present', String[1] $version = '8', Optional[String] $version_major = undef, Optional[String] $version_minor = undef, diff --git a/manifests/adoptium.pp b/manifests/adoptium.pp index e1cf2ce6..c39d36b5 100644 --- a/manifests/adoptium.pp +++ b/manifests/adoptium.pp @@ -42,7 +42,7 @@ # The name for the optional symlink in the installation directory. # define java::adoptium ( - String[1] $ensure = 'present', + Enum['present'] $ensure = 'present', Optional[String] $version_major = undef, Optional[String] $version_minor = undef, Optional[String] $version_patch = undef, diff --git a/manifests/download.pp b/manifests/download.pp index 85e24384..e8593820 100644 --- a/manifests/download.pp +++ b/manifests/download.pp @@ -54,7 +54,7 @@ # The name for the optional symlink in the installation directory. # define java::download ( - String[1] $ensure = 'present', + Enum['present'] $ensure = 'present', String[1] $version = '8', Optional[String] $version_major = undef, Optional[String] $version_minor = undef, diff --git a/manifests/sap.pp b/manifests/sap.pp index 1eb75990..05618be4 100644 --- a/manifests/sap.pp +++ b/manifests/sap.pp @@ -36,7 +36,7 @@ # The name for the optional symlink in the installation directory. # define java::sap ( - String[1] $ensure = 'present', + Enum['present'] $ensure = 'present', String[1] $version = '8', Optional[String] $version_full = undef, String[1] $java = 'jdk',