Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modulesync 2.12.0 #153

Merged
merged 8 commits into from
May 22, 2020
Merged

modulesync 2.12.0 #153

merged 8 commits into from
May 22, 2020

Conversation

dhoppe
Copy link
Member

@dhoppe dhoppe commented Dec 6, 2019

No description provided.

@dhoppe dhoppe changed the title modulesync 2.9.0 modulesync 2.10.0 Jan 17, 2020
@dhoppe dhoppe changed the title modulesync 2.10.0 modulesync 2.10.1 Jan 27, 2020
@dhoppe dhoppe changed the title modulesync 2.10.1 modulesync 2.11.o Feb 10, 2020
@dhoppe dhoppe changed the title modulesync 2.11.o modulesync 2.11.0 Feb 10, 2020
@dhoppe
Copy link
Member Author

dhoppe commented Feb 10, 2020

The files metadata.json and manifests/params.pp contain different releases. For example: Ubuntu 12.04 (Precise) is EOL since the beginning of 2019.

@bastelfreak
Copy link
Member

I think in the past we sometimes dropped one OS from the metadata.json and didn't purge all related code.

@dhoppe dhoppe changed the title modulesync 2.11.0 modulesync 2.12.0 May 5, 2020
Comment on lines 18 to 45
# strict variables wasn't added until 3.5.0, so this should be fine.
if ! $::settings::strict_variables {
$xfacts = {
'lsbdistid' => $::lsbdistid,
'lsbdistcodename' => $::lsbdistcodename,
'lsbmajdistrelease' => $::lsbmajdistrelease,
'lsbdistrelease' => $::lsbdistrelease,
'lsbdistid' => $facts['os']['distro']['id'],
'lsbdistcodename' => $facts['os']['distro']['codename'],
'lsbmajdistrelease' => $facts['os']['distro']['release']['major'],
'lsbdistrelease' => $facts['os']['distro']['release']['full'],
}
} else {
# Strict variables facts lookup compatibility
$xfacts = {
'lsbdistid' => defined('$lsbdistid') ? {
true => $::lsbdistid,
true => $facts['os']['distro']['id'],
default => undef,
},
'lsbdistcodename' => defined('$lsbdistcodename') ? {
true => $::lsbdistcodename,
true => $facts['os']['distro']['codename'],
default => undef,
},
'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? {
true => $::lsbmajdistrelease,
true => $facts['os']['distro']['release']['major'],
default => undef,
},
'lsbdistrelease' => defined('$lsbdistrelease') ? {
true => $::lsbdistrelease,
true => $facts['os']['distro']['release']['full'],
default => undef,
},
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach doesn't work with structured facts. If lsb-release is not installed, $facts['os']['distro'] is not defined and you'll get an error that you can't call [] on Undef. I'd suggest to use fact() from stdlib which does the right thing. This also removes the need for the special case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In another module, we use dig() to check if $facts['os']['distro'] exists.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But fact() was exactly designed for this purpose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at https://voxpupuli.org/docs/reviewing_pr/ , we agreed on using fact():

Are facts used? They should only be accessed via $facts[] or fact() function from stdlib, but not topscope variables

so I would go with fact() in this particular usecase, or uppdate our styleguide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's different because it's Ruby, not Puppet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be explicit, I think this whole block can be replaced with:

$xfacts = {
  'lsbdistid'         => fact('os.distro.id'),
  'lsbdistcodename'   => fact('os.distro.codename'),
  'lsbmajdistrelease' => fact('os.distro.release.major'),
  'lsbdistrelease'    => fact('os.distro.release.full'),
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not according to my local tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can probably get rid of a lot anyway: #164 is a start.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#165 would take it a step further. I'd suggest to look at those 2 PRs and then rebase modulesync based on that. In my experience it's better to first simplify and modernize.

@ekohl
Copy link
Member

ekohl commented May 21, 2020

#169 & #170 should IMHO be merged before this is rebased.

@ghoneycutt
Copy link
Member

@ekohl merged and merged :)

@dhoppe dhoppe merged commit 03c13fc into master May 22, 2020
@dhoppe dhoppe deleted the modulesync branch May 22, 2020 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants