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

Proposal (to be discussed) for allowing function that USE context #20

Conversation

kwisatz
Copy link
Contributor

@kwisatz kwisatz commented Nov 19, 2016

This is related to https://monitoring-portal.org/index.php?thread/38672-trouble-figuring-out-variables-macros-in-apply-rules-with-puppet/&postID=239378#post239378 but in no way meant to be a final PR, but rather something to base an actual solution on.

This regex allows to have parameters of the form

param => 'function (var) use (context) { expression }' 

where only var will be further parsed by the expression parser in utils.rb.

Side-question: How does one run a single spec?

I've tried

~$ bundle exec rake spec spec/defines/object_spec.rb

but that will still run ALL of the specs.

@bobapple
Copy link
Contributor

Sorry, didn't close this by intention!

@bobapple bobapple reopened this Nov 21, 2016
icingaadmin pushed a commit that referenced this pull request Nov 22, 2016
@kwisatz kwisatz changed the title Proposal (tbd) for allowing function that USE context Proposal (to be discussed) for allowing function that USE context Nov 23, 2016
@kwisatz
Copy link
Contributor Author

kwisatz commented Nov 23, 2016

OK, I found a case (very early already) where the regex above is not working. I will try feeding this info into the corresponding ticket on dev.icinga.com. In case the function body contains an operator (e.g. +), the first regex matches and not the new one I was naively suggesting.

This e.g. is an example that does not work:

name                      => 'function () use (vhost) { "check-http-" + vhost }',
name = function () use ("vhost) { "check-http-"" + "vhost }"

@bobapple bobapple merged commit 6d03814 into voxpupuli:feature/support-for-functions-as-parameters-13273 Nov 23, 2016
@bobapple bobapple changed the base branch from feature/how-attribute-parsing-works-documentation-13219 to feature/support-for-functions-as-parameters-13273 November 23, 2016 12:54
@bobapple
Copy link
Contributor

I cannot re-open the PR anymore since it's marked as "Merged" now that I changed the base. Can you create a new PR pleas? Sorry for the trouble

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants