From 3a22a601fef64d3c4c05c5bdfce2706de3442d4a Mon Sep 17 00:00:00 2001 From: Corey Hemminger Date: Tue, 14 Jan 2025 13:43:24 -0600 Subject: [PATCH 1/2] fix lib name for chef-client 18.6.2 and greater Signed-off-by: Corey Hemminger --- libraries/helpers.rb | 8 +++----- spec/recipes/default_spec.rb | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 79d8dcb..a6231ca 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -20,8 +20,8 @@ # class HomebrewUserWrapper - require 'chef/mixin/homebrew_user' - include Chef::Mixin::HomebrewUser + require Chef::VERSION >= Chef::Version.new('18.6.2') ? 'chef/mixin/homebrew' : 'chef/mixin/homebrew_user' + include Chef::VERSION >= Chef::Version.new('18.6.2') ? Chef::Mixin::Homebrew : Chef::Mixin::HomebrewUser include Chef::Mixin::Which end @@ -60,9 +60,7 @@ def exist? def owner @owner ||= begin - # once we only support 14.0 we can switch this to find_homebrew_username - require 'etc' - ::Etc.getpwuid(HomebrewUserWrapper.new.find_homebrew_uid).name + find_homebrew_username rescue Chef::Exceptions::CannotDetermineHomebrewOwner calculate_owner end.tap do |owner| diff --git a/spec/recipes/default_spec.rb b/spec/recipes/default_spec.rb index 229a54d..0cef0dc 100644 --- a/spec/recipes/default_spec.rb +++ b/spec/recipes/default_spec.rb @@ -40,7 +40,7 @@ end before do - allow_any_instance_of(Chef::Mixin::HomebrewUser).to receive(:find_homebrew_uid).and_return(Process.uid) + allow_any_instance_of(Chef::Mixin::Homebrew).to receive(:find_homebrew_uid).and_return(Process.uid) end it 'does not run homebrew installation' do From b73089c748fa24649235cb9881f7296206d8d2e5 Mon Sep 17 00:00:00 2001 From: Corey Hemminger Date: Tue, 14 Jan 2025 13:48:43 -0600 Subject: [PATCH 2/2] updated changelog Signed-off-by: Corey Hemminger --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ca996..6b10cda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the homebrew cookbook. ## Unreleased +- Updated library call for new homebrew class name + ## 5.4.9 - *2024-11-18* Standardise files with files in sous-chefs/repo-management