Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lib name for chef-client 18.6.2 and greater #191

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading