-
Notifications
You must be signed in to change notification settings - Fork 581
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
(FACT-932) Add new function, fact() #787
Conversation
|
Would be nice to split this into 2 functions. One to dig like this into any hash and then use that in the fact function. |
|
@ripienaar any ideas for what to call the dig-like part? |
|
I'm not a good guy to ask about naming things :P core has |
|
I looked briefly at just splitting this into two functions and it looked like doing that might make it harder to keep the error messages specific to the fact-lookup use case. It could be possible to extend the existing function with a two-argument dispatch, such that it could be called for other arbitrary arrays, but when called with only one argument it behaves as it does today. @ripienaar is there a specific use case you're thinking of for having the function split? As you mentioned Would the ability to call $simple = fact('os.family')
$arbitrary = $alternative.fact('os.family') |
The fact() function allows dot-notation reference to facts. It is an
alternative to using $facts directly with array-indexing. Array-indexing
is often onerous to use since it doesn't align with how structured facts
are accessed elsewhere in the ecosystem and if any element in a
multi-step path doesn't exist, array indexing can cause a compilation
failure.
Example usage:
fact('os.family')
Because sometimes people want to use an alternative data set, but treat it like it's a set of facts.
|
The dot notation is just quite nice and now quite pervasive throughout so the use case is just to use it on other hashes - I wish core Naming seems off to be able to pass a extra parameter to something called fact to them dig into another non fact thing to me |
|
@ripienaar I think I agree with you on the name. I had a good time for a minute writing up a commit to allow using alternative facts, but in the end I think it's probably best for now to keep things simple and let Reverting in the PR for now, but leaving the commit in the history so we can still look at it conversationally if we want to. |
This reverts commit 409a974. After thinking about this, use case, and function naming, I think it's probably best for now to keep things simple and let `fact()` be single-purpose for looking up facts with no potentially confusing extensions. The only use case where the name makes sense is where it's being used on the `$facts` hash, and I think we'd rather in that circumstance promote the raw use of `fact()`.
|
What's up with the Appveyor build failures? They don't look related to this PR at all. |
|
@reidmv i will look into the appveyor failure it smells bad to me |
|
@ripienaar for the record, as part of the conversation that @reidmv and I had prompting this PR, I wrote exactly that function and proposed it in a different PR #759 If there is value in a |
(FACT-932) Add new function, fact()
|
@reidmv do we need another PR to document this new function in the README? |
|
@npwalker Doh! Yes, we do. |
This PR doesn't solve for FACT-932, but is related to it and discussion
there.
The fact() function allows dot-notation reference to facts. It is an
alternative to using $facts directly with array-indexing. Array-indexing
is often onerous to use since it doesn't align with how structured facts
are accessed elsewhere in the ecosystem and if any element in a
multi-step path doesn't exist, array indexing can cause a compilation
failure.
Example usage: