diff --git a/CHANGELOG.md b/CHANGELOG.md index eeca835dd..19b19cd2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## Supported Release 4.17.0 +### Summary +This release adds support for internationalization. It also contains Japanese translations for the README, summary and description of the metadata.json and major cleanups in the README. Additional folders have been introduced called locales and readmes where translation files can be found. A number of features and bug fixes are also included in this release. It also adds a new function `glob()` for expanding file lists. Also works around an issue that appeared in puppet 4.6.0 involving types being declared multiple times. + +#### Features +- Addition of POT file / folder structure for i18n. +- Addition of Internationalized READMEs. +- `glob()` function + +### Fixed +- Occasional duplicate type definitions when using `defined_with_params()` +- `file_line` encoding issue on ruby 1.8 (unsupported) +- Huge readme refresh + ## Supported Release 4.16.0 ### Summary diff --git a/lib/puppet/parser/functions/defined_with_params.rb b/lib/puppet/parser/functions/defined_with_params.rb index 7f1fe9376..e0d4e37e6 100644 --- a/lib/puppet/parser/functions/defined_with_params.rb +++ b/lib/puppet/parser/functions/defined_with_params.rb @@ -29,7 +29,7 @@ # Workaround for PE-20308 if reference.is_a?(String) type_name, title = Puppet::Resource.type_and_title(reference, nil) - type = Puppet::Type.type(type_name) + type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type_or_class(find_global_scope, type_name) elsif reference.is_a?(Puppet::Resource) type = reference.resource_type title = reference.title diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index 17942b8a4..034f997c2 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -36,6 +36,7 @@ module Puppet::Parser::Functions Puppet::Parser::Functions.function(:ensure_resource) packages.each { |package_name| + raise(Puppet::ParseError, 'ensure_packages(): Empty String provided for package name') if package_name.length == 0 if !findresource("Package[#{package_name}]") function_ensure_resource(['package', package_name, defaults ]) end diff --git a/metadata.json b/metadata.json index 1905884d2..8c05d793d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "4.16.0", + "version": "4.17.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", diff --git a/spec/fixtures/test/manifests/deftype.pp b/spec/fixtures/test/manifests/deftype.pp new file mode 100644 index 000000000..825f8fe2d --- /dev/null +++ b/spec/fixtures/test/manifests/deftype.pp @@ -0,0 +1,3 @@ +define test::deftype($param = 'foo') { + notify { "deftype: $title": } +} diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 7118d85f5..491a03be7 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -55,4 +55,14 @@ end end end + + describe 'when passed a defined type' do + let :pre_condition do + 'test::deftype { "foo": }' + end + it { is_expected.to run.with_params('Test::Deftype[foo]', {}).and_return(true) } + it { is_expected.to run.with_params('Test::Deftype[bar]', {}).and_return(false) } + it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[foo]'), {}).and_return(true) } + it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[bar]'), {}).and_return(false) } + end end diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 6f94d72a6..1f8978565 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -34,6 +34,14 @@ end end + context 'given an empty packages array' do + let(:pre_condition) { 'notify { "hi": } -> Package <| |>; $somearray = ["vim",""]; ensure_packages($somearray)' } + + describe 'after running ensure_package(["vim", ""])' do + it { expect { catalogue }.to raise_error(Puppet::ParseError, /Empty String provided/) } + end + end + context 'given hash of packages' do before { subject.call([{"foo" => { "provider" => "rpm" }, "bar" => { "provider" => "gem" }}, { "ensure" => "present"}]) } before { subject.call([{"パッケージ" => { "ensure" => "absent"}}]) } diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index 5366205d5..c847bf76b 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -38,6 +38,13 @@ it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } it { expect(lambda { catalogue }).to contain_user('username1').without_gid } end + + describe 'after running ensure_resource("test::deftype", "foo", {})' do + before { subject.call(['test::deftype', 'foo', {}]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure } + end end context 'given a catalog with UTF8 chars' do @@ -114,4 +121,15 @@ } end end + + context 'given a catalog with "test::deftype { foo: }"' do + let(:pre_condition) { 'test::deftype { "foo": }' } + + describe 'after running ensure_resource("test::deftype", "foo", {})' do + before { subject.call(['test::deftype', 'foo', {}]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure } + end + end end