Skip to content

Determine root_home without shelling out#1278

Merged
jordanbreen28 merged 1 commit intopuppetlabs:mainfrom
ekohl:simplify-root-home
Oct 17, 2022
Merged

Determine root_home without shelling out#1278
jordanbreen28 merged 1 commit intopuppetlabs:mainfrom
ekohl:simplify-root-home

Conversation

@ekohl
Copy link
Copy Markdown
Collaborator

@ekohl ekohl commented Oct 14, 2022

This uses Ruby's Etc library to determine the root home. This avoids shelling out and writing multiple implementations.

Comment thread lib/facter/root_home.rb
end
end

Facter.add(:root_home) do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice removal of code @ekohl.

What do you think about confining the fact to osx and linux? I noticed the test just checks for nil when :kernel is Windows.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today there's also fact for AIX and I'd expect this code to work on any unix (like Solaris). However, I can't test that since I don't have access to those systems. Any you could confine it to non-Windows but I think this is effectively the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point!

This uses Ruby's Etc library to determine the root home. This avoids
shelling out and writing multiple implementations.
@ekohl ekohl force-pushed the simplify-root-home branch from 8a8ebc0 to 657cd71 Compare October 17, 2022 11:15
Copy link
Copy Markdown
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks @ekohl.

@jordanbreen28 jordanbreen28 merged commit 199e514 into puppetlabs:main Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants