Skip to content

Implement stdlib 9 compatibility #657

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

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
fixtures:
repositories:
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib'
forge_modules:
stdlib:
repo: "puppetlabs/stdlib"
ref: "8.4.0"
inifile:
repo: "puppetlabs/inifile"
ref: "5.3.0"
Expand All @@ -17,5 +16,3 @@ fixtures:
facts:
repo: "puppetlabs/facts"
ref: "1.4.0"
symlinks:
puppet_agent: "#{source_dir}"
13 changes: 3 additions & 10 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
# The `is_pe` fact currently works by echoing out the puppet version
# and greping for "puppet enterprise". With Puppet 4 and PE 2015.2, there
# is no longer a "PE Puppet", and so that fact will no longer work.
# Instead check for the `is_pe` fact or if a PE provided function is available
$_is_pe = (getvar('::is_pe') or is_function_available('pe_compiling_server_version'))
# Instead check for the `is_pe` fact or if the `pe_anchor` resource type
# provided by the puppet_enterprise module exist.
$_is_pe = (getvar('::is_pe') or defined('pe_anchor'))
if $_is_pe {
# Calculate the default collection
$_pe_version = pe_build_version()
Expand All @@ -68,17 +69,9 @@
else {
$collection = 'puppet8'
}
# The aio puppet-agent version currently installed on the compiling master
# (only used in PE)
if is_function_available('pe_compiling_server_aio_build') {
$master_agent_version = pe_compiling_server_aio_build()
} else {
$master_agent_version = undef
}
} else {
$_pe_version = undef
$pe_repo_dir = undef
$master_agent_version = undef
$collection = 'PC1'
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": [
{
"name": "puppetlabs-stdlib",
"version_requirement": ">= 5.1.0 < 9.0.0"
"version_requirement": ">= 5.1.0 < 10.0.0"
},
{
"name": "puppetlabs-inifile",
Expand Down
2 changes: 0 additions & 2 deletions spec/classes/puppet_agent_osfamily_aix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' }
end

it { is_expected.to contain_file('/opt/puppetlabs') }
Expand Down Expand Up @@ -75,7 +74,6 @@

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' }
end

it {
Expand Down
5 changes: 0 additions & 5 deletions spec/classes/puppet_agent_osfamily_darwin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
require 'spec_helper'

describe 'puppet_agent' do
master_package_version = '1.10.100'
before(:each) do
# Need to mock the PE functions
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
master_package_version
end

allow(Puppet::FileSystem).to receive(:exist?).and_call_original
allow(Puppet::FileSystem).to receive(:read_preserve_line_endings).and_call_original
allow(Puppet::FileSystem).to receive(:exist?).with('/opt/puppetlabs/puppet/VERSION').and_return true
Expand Down
4 changes: 0 additions & 4 deletions spec/classes/puppet_agent_osfamily_debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
package_version
end
end

let(:facts) do
Expand Down
4 changes: 0 additions & 4 deletions spec/classes/puppet_agent_osfamily_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
'5.5.4'
end
end

let(:facts) do
Expand Down
8 changes: 0 additions & 8 deletions spec/classes/puppet_agent_osfamily_solaris_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ def install_script(ver, arch)
pe_version
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
package_version
end

# Ensure we get a versionable package provider
pkg = Puppet::Type.type(:package)
allow(pkg).to receive(:defaultprovider).and_return(pkg.provider(:pkg))
Expand Down Expand Up @@ -310,10 +306,6 @@ def install_script(ver, arch)
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
pe_version
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
package_version
end
end

let(:facts) do
Expand Down
4 changes: 0 additions & 4 deletions spec/classes/puppet_agent_osfamily_suse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
package_version
end
end

describe 'supported environment' do
Expand Down
4 changes: 0 additions & 4 deletions spec/classes/puppet_agent_osfamily_windows_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
pe_version
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
package_version
end

allow(Puppet::Util).to receive(:absolute_path?).and_call_original
allow(Puppet::Util).to receive(:absolute_path?).with(version_file).and_return true
allow(Puppet::FileSystem).to receive(:exist?).and_call_original
Expand Down
14 changes: 1 addition & 13 deletions spec/classes/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,6 @@ def global_facts(facts, os)
end
end

context 'package_version is undef if pe_compiling_server_aio_build is not defined' do
let(:facts) do
global_facts(facts, os).merge(is_pe: true)
end

it { is_expected.to contain_class('puppet_agent').with_package_version(nil) }
end

context 'package_version is same as master when set to auto' do
let(:params) { { package_version: 'auto' } }
let(:node_params) { { serverversion: '7.6.5' } }
Expand Down Expand Up @@ -237,7 +229,7 @@ def global_facts(facts, os)
before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_version, type: :rvalue) { |_args| '2.20.200' }
Puppet::Parser::Functions.newfunction(:defined, type: :rvalue) { |_args| true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Mocking defined to return true might break things. According to the tests I did with the module it seems to be fine, but it feel fragile 😨.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand why this is getting mocked here; @bastelfreak can you shed some light?

end

context 'package_version is initialized automatically' do
Expand Down Expand Up @@ -268,10 +260,6 @@ def global_facts(facts, os)
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
'1.10.100'
end
end
end

Expand Down
4 changes: 0 additions & 4 deletions spec/classes/puppet_agent_windows_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) do |_args|
'4.10.100'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) do |_args|
package_version
end
end

let(:facts) { facts.merge({ is_pe: true }) }
Expand Down