Skip to content

Commit

Permalink
memoize root_user/root_group methods
Browse files Browse the repository at this point in the history
Summary:
We don't expect the platform to change mid-run, so memoizing these
methods to save calls to `#value_for_platform`, which has node attribute reads
under the hood.

Differential Revision: D55338996

fbshipit-source-id: 7c563a1f5f13c58b35b081b2796143b9d6939cd7
  • Loading branch information
dafyddcrosby authored and facebook-github-bot committed Mar 26, 2024
1 parent 3ee3d06 commit 2f830f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cookbooks/fb_helpers/libraries/node_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ def solo?
end

def root_user
value_for_platform(
@root_user ||= value_for_platform(
'windows' => { 'default' => 'Administrator' },
'default' => 'root',
)
Expand All @@ -999,7 +999,7 @@ def root_user
def root_group
# rubocop:disable Chef/Correctness/InvalidPlatformValueForPlatformHelper
# See the `macos?` method above
value_for_platform(
@root_group ||= value_for_platform(
%w{openbsd freebsd mac_os_x macos} => { 'default' => 'wheel' },
'windows' => { 'default' => 'Administrators' },
'default' => 'root',
Expand Down

0 comments on commit 2f830f4

Please sign in to comment.