Closed brodock closed 8 years ago
I was trying to implement a method to retrieve version from a VERSION file:
File.open(File.join(workdir, 'VERSION'), &:read).chomp
While this works, I can't use it with version recipe definition, as I don't have workdir defined at that moment.
version
This is just an example, but could illustrate other places that could be dynamically defined (like URL, Maintainer, Revision, etc).
One way to make this works, is with lambdas:
instead of
version File.open(File.join(workdir, 'VERSION'), &:read).chomp`
version -> { File.open(File.join(workdir, 'VERSION'), &:read).chomp }
But for this to work, there must need to make sure it will have access to the same "context", and the lambda must receive a .call at the right moment.
.call
Do you think this is valuable?
I think the hiera PR would solve your use case, right?
See: https://github.com/bernd/fpm-cookery/pull/150
This might be solved by using the hiera backend implemented in #150.
Please re-open if this doesn't help in your case. Thank you!
I was trying to implement a method to retrieve version from a VERSION file:
While this works, I can't use it with
version
recipe definition, as I don't have workdir defined at that moment.This is just an example, but could illustrate other places that could be dynamically defined (like URL, Maintainer, Revision, etc).
One way to make this works, is with lambdas:
instead of
But for this to work, there must need to make sure it will have access to the same "context", and the lambda must receive a
.call
at the right moment.Do you think this is valuable?