From 9244c67206363f8e887531b164fc24cef729f3d8 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 27 Apr 2017 10:00:04 +0100 Subject: Test for defined_with_params() returning false for defined types defined_with_params() now returns false for defined types, causing duplicate resources when using ensure_resources(). Introduced by 4f19c27 in PE-20308. --- spec/fixtures/test/manifests/deftype.pp | 3 +++ spec/functions/defined_with_params_spec.rb | 8 ++++++++ spec/functions/ensure_resource_spec.rb | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 spec/fixtures/test/manifests/deftype.pp 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..775fa74 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -55,4 +55,12 @@ 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) } + end end 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 -- cgit v1.2.3 From 32e5a87bb3b8c1d0fabc1e8c2687e4a750173cb5 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 28 Apr 2017 15:48:56 -0700 Subject: (PE-20308) Also fix defined type strings & references --- lib/puppet/parser/functions/defined_with_params.rb | 2 +- spec/functions/defined_with_params_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 775fa74..491a03b 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -62,5 +62,7 @@ describe 'defined_with_params' do 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 -- cgit v1.2.3 From 567b6d3fad75727de66b6ef339d77ef181316603 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 28 Apr 2017 10:02:42 -0700 Subject: Release prep 4.17.0 --- CHANGELOG.md | 12 ++++++++++++ metadata.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeca835..518040b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## Supported Release 4.17.0 +### Summary +This release 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. + +### Added +- `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/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", -- cgit v1.2.3 From 419ffeb1d167a05af6858e2e4749f6414532f5d2 Mon Sep 17 00:00:00 2001 From: tphoney Date: Mon, 8 May 2017 11:08:59 +0100 Subject: (MODULES-4706) release prep 4.17.0 --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 518040b..19b19cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ ## Supported Release 4.17.0 ### Summary -This release 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. +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. -### Added +#### Features +- Addition of POT file / folder structure for i18n. +- Addition of Internationalized READMEs. - `glob()` function ### Fixed -- cgit v1.2.3 From 5ad49ebaecbdbc6faa58282c45aad1c46d4d7f2c Mon Sep 17 00:00:00 2001 From: Alex Dacre Date: Wed, 26 Apr 2017 12:47:29 +0100 Subject: Fix issue where the following causes obscure catalog compilation errors: ``` file { '/tmp/somefile': ensure => 'file', } File['/tmp/somefile'] -> Package <| |> ensure_packages($somearray) ``` If $somearray is undefined or one of the elements contains an empty string, an error like the following is thrown: Could not find resource 'Package[]' for relationship from 'File[/tmp/somefile]' on node $::fqdn --- lib/puppet/parser/functions/ensure_packages.rb | 1 + 1 file changed, 1 insertion(+) 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 -- cgit v1.2.3 From 51fd72ca4accb2760a364d65dfe6f9b672f68d83 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 28 Apr 2017 13:47:47 -0700 Subject: add tests --- spec/functions/ensure_packages_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) 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"}}]) } -- cgit v1.2.3