From 4883178f2217b124e760e615d0277c18c8748ac1 Mon Sep 17 00:00:00 2001 From: Michael T Lombardi Date: Wed, 30 Oct 2019 11:00:54 -0500 Subject: [PATCH 1/2] (MAINT) Remove puppet feature from build This commit removes the code from the rakefile for inserting a puppet feature at build time. This is because the feature/confine pattern is not supported in the resource_api and therefore not usable at this time by the puppet module. --- Rakefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Rakefile b/Rakefile index c63a3fd0..0f729a6e 100644 --- a/Rakefile +++ b/Rakefile @@ -93,18 +93,10 @@ end desc 'Build for Puppet' task :build_module do - # Ready for module building - content = "require 'puppet/util/feature'\n\nPuppet.features.add(:ruby_pwsh, :libs => ['ruby-pwsh'])\n" - feature_path = 'lib/puppet/feature/ruby_pwsh.rb' - unless File.exist?(feature_path) ? File.read(feature_path) == content : false - FileUtils.mkdir_p(File.dirname(feature_path)) - File.open(feature_path, 'wb') { |file| file.write(content) } - end actual_readme_content = File.read('README.md') FileUtils.copy_file('pwshlib.md', 'README.md') # Build run_local_command('pdk build --force') # Cleanup File.open('README.md', 'wb') { |file| file.write(actual_readme_content) } - FileUtils.rm_r('lib/puppet') if File.exist?('lib/puppet') end From ae106295c47625656addb83a524fb7b42e8b7550 Mon Sep 17 00:00:00 2001 From: Michael T Lombardi Date: Wed, 30 Oct 2019 11:01:50 -0500 Subject: [PATCH 2/2] (MAINT) Update puppet module directions This module ensures that the example code for building a puppet module using the resource_api includes the correct begin/rescue block for the requires statement. --- pwshlib.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pwshlib.md b/pwshlib.md index 5dc1ba8b..c1ce21fb 100644 --- a/pwshlib.md +++ b/pwshlib.md @@ -11,7 +11,11 @@ Include `puppetlabs-pwshlib` as a dependency in your module and you can leverage ```ruby require 'puppet/resource_api/simple_provider' -require 'ruby-pwsh' +begin + require 'ruby-pwsh' +rescue LoadError + raise 'Could not load the "ruby-pwsh" library; is the dependency module puppetlabs-pwshlib installed in this environment?' +end # Implementation for the foo type using the Resource API. class Puppet::Provider::Foo::Foo < Puppet::ResourceApi::SimpleProvider