Skip to content

Commit

Permalink
optional_default
Browse files Browse the repository at this point in the history
  • Loading branch information
david22swan committed Aug 18, 2022
1 parent 83082c0 commit 0598065
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
1 change: 0 additions & 1 deletion .puppet-lint.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
--no-anchor_resource-check
--no-strict_indent-check
--no-unquoted_string_in_case-check
--no-optional_default-check
1 change: 0 additions & 1 deletion .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ Rakefile:
- anchor_resource
- strict_indent
- unquoted_string_in_case
- optional_default
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ PuppetLint.configuration.send('disable_parameter_documentation')
PuppetLint.configuration.send('disable_anchor_resource')
PuppetLint.configuration.send('disable_strict_indent')
PuppetLint.configuration.send('disable_unquoted_string_in_case')
PuppetLint.configuration.send('disable_optional_default')


if Bundler.rubygems.find_name('github_changelog_generator').any?
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
Expand Down
50 changes: 24 additions & 26 deletions manifests/pin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
# Names the label of the packages in the directory tree of the Release file.
#
define apt::pin (
Enum['file', 'present', 'absent'] $ensure = present,
Optional[String] $explanation = undef,
Variant[Integer] $order = 50,
Variant[String, Array] $packages = '*',
Variant[Numeric, String] $priority = 0,
Optional[String] $release = '', # a=
Optional[String] $origin = '',
Optional[String] $version = '',
Optional[String] $codename = '', # n=
Optional[String] $release_version = '', # v=
Optional[String] $component = '', # c=
Optional[String] $originator = '', # o=
Optional[String] $label = '', # l=
Enum['file', 'present', 'absent'] $ensure = present,
Optional[String] $explanation = undef,
Variant[Integer] $order = 50,
Variant[String, Array] $packages = '*',
Variant[Numeric, String] $priority = 0,
Optional[String] $release = undef, # a=
Optional[String] $origin = undef,
Optional[String] $version = undef,
Optional[String] $codename = undef, # n=
Optional[String] $release_version = undef, # v=
Optional[String] $component = undef, # c=
Optional[String] $originator = undef, # o=
Optional[String] $label = undef, # l=
) {
if $explanation {
$_explanation = $explanation
Expand All @@ -58,15 +58,13 @@
}
}

$pin_release_array = [
$release,
$codename,
$release_version,
$component,
$originator,
$label,
]
$pin_release = join($pin_release_array, '')
$pin_release = ''
$pin_release_array = [$release, $codename, $release_version, $component, $originator, $label]
$pin_release_array.each |$value| {
if $value {
$pin_release = join([$pin_release, $value], '')
}
}

# Read the manpage 'apt_preferences(5)', especially the chapter
# 'The Effect of APT Preferences' to understand the following logic
Expand All @@ -78,15 +76,15 @@
}

if $packages_string != '*' { # specific form
if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
( $version != '' and ( $pin_release != '' or $origin != '' )) {
if ( $pin_release != '' and ( $origin or $version )) or
( $version and ( $pin_release != '' or $origin )) {
fail('parameters release, origin, and version are mutually exclusive')
}
} else { # general form
if $version != '' {
if $version {
fail('parameter version cannot be used in general form')
}
if ( $pin_release != '' and $origin != '' ) {
if ( $pin_release != '' and $origin ) {
fail('parameters release and origin are mutually exclusive')
}
}
Expand Down

0 comments on commit 0598065

Please sign in to comment.