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

Support puppetlabs/apt 10.x; require >= 9.2 #1116

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Support puppetlabs/apt 10.x; require >= 9.2 #1116

merged 1 commit into from
Jan 6, 2025

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Jan 6, 2025

Pull Request (PR) description

This Pull Request (PR) fixes the following issues

@evgeni evgeni added the enhancement New feature or request label Jan 6, 2025
@@ -16,7 +16,7 @@
apt::source { 'jenkins':
location => $location,
release => 'binary/',
repos => '',
repos => undef,
Copy link
Member

Choose a reason for hiding this comment

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

If this is undef, can't we simply leave it out?

Suggested change
repos => undef,

Copy link
Member

Choose a reason for hiding this comment

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

In either case, that would result in main being used?? (The module default). I'm guessing this isn't the intention.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the intention is to get an empty string in the generated file. Won't an explicit undef do that?

Copy link
Member

Choose a reason for hiding this comment

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

Don't think so. I think you'll just get the module's default which is the string 'main'. I'm not familiar with the workings of the module though as I use Puppet mainly on RPM based systems.

Copy link
Member

Choose a reason for hiding this comment

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

No, undef means "use whatever is defined" elsewhere I think. So it ends up being main.

@@ -16,7 +16,7 @@
apt::source { 'jenkins':
location => $location,
release => 'binary/',
repos => '',
repos => undef,
Copy link
Member

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.

AFAIK undef is always allowed. It just means it ends up using the default.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not use the default, no.

# cat lol.pp 
$location = 'https://pkg.jenkins.io/debian-stable'
$gpg_key_id = '63667EE74BBA1F0A08A698725BA31D57EF5975CA'

    apt::source { 'jenkins':
      location => $location,
      release  => 'binary/',
      repos    => undef,
      include  => {
        'src' => false,
      },
      key      => {
        'id'     => $gpg_key_id,
        'source' => "${location}/jenkins.io-2023.key",
      },
    }

# puppet apply lol.pp 
Notice: Compiled catalog for eb3b185efcfa.redhat.com in environment production in 0.10 seconds
Notice: /Stage[main]/Apt/File[sources.list]/ensure: created
Notice: /Stage[main]/Apt/File[preferences]/ensure: created
Notice: /Stage[main]/Apt/Package[gnupg]/ensure: created
Notice: /Stage[main]/Apt/Apt::Setting[conf-update-stamp]/File[/etc/apt/apt.conf.d/15update-stamp]/ensure: defined content as '{sha256}2e6eb1f5f20262bfc6b7dfb26a302f00b4ab5fee803abd9e07ad8378cce067d5'
Notice: /Stage[main]/Main/Apt::Source[jenkins]/Apt::Key[Add key: 63667EE74BBA1F0A08A698725BA31D57EF5975CA from Apt::Source jenkins]/Apt_key[Add key: 63667EE74BBA1F0A08A698725BA31D57EF5975CA from Apt::Source jenkins]/ensure: created
Notice: /Stage[main]/Main/Apt::Source[jenkins]/Apt::Setting[list-jenkins]/File[/etc/apt/sources.list.d/jenkins.list]/ensure: defined content as '{sha256}f853a9845679b71b1e95e04d20508cabc490f9ba393274037bda37f87429408a'
Notice: /Stage[main]/Apt::Update/Exec[apt_update]: Triggered 'refresh' from 1 event
Notice: Applied catalog in 4.54 seconds

# cat /etc/apt/sources.list.d/jenkins.list
# This file is managed by Puppet. DO NOT EDIT.
# jenkins
deb https://pkg.jenkins.io/debian-stable binary/

Copy link
Member

Choose a reason for hiding this comment

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

It might, but you're probably hitting this code: https://github.com/puppetlabs/puppetlabs-apt/blob/966d39cfe2cd85a5b481e67e8da51e2024b336d2/manifests/source.pp#L140-L144

Note release is binary/ so $_components is just $_release, not ${_release} ${repos}. I expect that if you change release to binary you will see it as deb https://pkg.jenkins.io/debian-stable binary main.

If not, it would violate the type Variant[String[1], Array[String[1]]] which doesn't allow undef.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah. Yes indeed.

WHY IS THERE SO MUCH MAGIC?!

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, but I still think we should leave it out

Suggested change
repos => undef,

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Requires puppetlabs/puppetlabs-apt@ce8e484 tho.

Copy link
Member

Choose a reason for hiding this comment

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

Bleh. I submitted puppetlabs/puppetlabs-apt#1215 so you can also use repos => [] which IMHO is cleaner since it's explicit, but I think only requiring 9.x as the lower bound is probably better.

@ekohl
Copy link
Member

ekohl commented Jan 6, 2025

Linking a related PR that attempts to do the same: #1116.

@evgeni
Copy link
Member Author

evgeni commented Jan 6, 2025

As shown in #1115, this works "as intended" (but yes, I don't like that api change in puppetlabs/apt either).

This uses the new logic introduced in 9.2.0 [1] and thus bumps the lower
bound.

[1] puppetlabs/puppetlabs-apt@ce8e484
@bastelfreak bastelfreak changed the title Support puppetlabs/apt 10.x Support puppetlabs/apt 10.x; require >= 9 Jan 6, 2025
@evgeni evgeni changed the title Support puppetlabs/apt 10.x; require >= 9 Support puppetlabs/apt 10.x; require >= 9.2 Jan 6, 2025
@evgeni evgeni merged commit 5fcacf5 into master Jan 6, 2025
4 of 22 checks passed
@evgeni evgeni deleted the apt10 branch January 6, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants