diff options
author | Paula McMaw <paula@puppet.com> | 2017-05-10 11:00:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-10 11:00:48 +0100 |
commit | 18620765d5a732a87214c8ac6e21ddf00b25ec83 (patch) | |
tree | 65b67776a89d9dd640c6fada8266a233bfe7e95d | |
parent | 052d55b046706b6d68b69ac91e8d688009b3fdc1 (diff) | |
parent | 51fd72ca4accb2760a364d65dfe6f9b672f68d83 (diff) |
Merge pull request #776 from puppetlabs/release
Merge back 4.17.0
-rw-r--r-- | CHANGELOG.md | 14 | ||||
-rw-r--r-- | lib/puppet/parser/functions/defined_with_params.rb | 2 | ||||
-rw-r--r-- | lib/puppet/parser/functions/ensure_packages.rb | 1 | ||||
-rw-r--r-- | metadata.json | 2 | ||||
-rw-r--r-- | spec/fixtures/test/manifests/deftype.pp | 3 | ||||
-rwxr-xr-x | spec/functions/defined_with_params_spec.rb | 10 | ||||
-rwxr-xr-x | spec/functions/ensure_packages_spec.rb | 8 | ||||
-rwxr-xr-x | spec/functions/ensure_resource_spec.rb | 18 |
8 files changed, 56 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index eeca835..19b19cd 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 7f1fe93..e0d4e37 100644 --- a/lib/puppet/parser/functions/defined_with_params.rb +++ b/lib/puppet/parser/functions/defined_with_params.rb @@ -29,7 +29,7 @@ ENDOFDOC # 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 17942b8..034f997 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -36,6 +36,7 @@ third argument to the ensure_resource() function. 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 1905884..8c05d79 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 0000000..825f8fe --- /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 7118d85..491a03b 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -55,4 +55,14 @@ describe 'defined_with_params' do 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 6f94d72..1f89785 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -34,6 +34,14 @@ describe 'ensure_packages' do 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 5366205..c847bf7 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -38,6 +38,13 @@ describe 'ensure_resource' do 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 @@ describe 'ensure_resource' do } 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 |