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

Patch - ensure that facts specified by environment variables take precedence #4

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions lib/facter/util/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def load_env(fact = nil)
next if fact and env_name != fact

Facter.add($1) do
from_environment
setcode { value }
end

Expand Down
14 changes: 13 additions & 1 deletion lib/facter/util/resolution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,29 @@ def confine(confines)
end
end

# Say this resolution came from the environment
def from_environment
@from_environment = true
end

# Create a new resolution mechanism.
def initialize(name)
@name = name
@confines = []
@value = nil
@timeout = 0
@from_environment = false
end

# Return the number of confines.
def length
@confines.length
# If the resolution came from an environment variable
# say we're very very sure about the value of the resolution
if @from_environment
1_000_000_000
else
@confines.length
end
end

# We need this as a getter for 'timeout', because some versions
Expand Down