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

Custom Resources DSL to `use` a helper #9077

lamont-granquist opened this issue Nov 7, 2019 · 0 comments


Copy link

@lamont-granquist lamont-granquist commented Nov 7, 2019

Design proposal is that it would work as simply as:

  1. create a file named _myhelper.rb in the resources directory.

  2. the load_resources routine would be patched to ignore all files in that directory starting with a leading _.

  3. in the actual myresource.rb file the user would declare use myhelper.

  4. this would class_eval the helper file against the being-built resource class.

That would replace the need for all this garbage:

Would also be usable directly in core-chef without any modifications.

  • We MUST protect against automatic loading of the file by the resource loader so there has to be some kind of trickery around what the helpers file is called to identify it as a helpers file. Alternatively to the _ prefix we could have a completely separate segment for helpers, but that violates locality. Using a suffix like .hlp would break automatic syntax highlighting in editors for ruby files (since it is a ruby file it should be a .rb file).

  • We can support paths and relative paths in the use syntax so use "../whatever/myhelper" would work. We can also support allowing the user to throw the _ on there and the .rb (or we could just force that for unambiguity, but I tend to like the syntax of use "myhelper" rather than use "_myhelper.rb").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.