-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add support for user data files in sparkleformation templates #117
Conversation
cab5071
to
aede9bf
Compare
def add_expr(src, code, indicator) | ||
case indicator | ||
when '=' | ||
src << " #{@bufvar} << (" << code << ');' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I have a rough idea what this line does. But I wonder if this can be simplified a bit as the brackets could be redundant in the following evaluation, e.g.
src << " #{@bufvar} << #{code};"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That breaks the test for custom vars, instead of returning the variables value it returns true.
-"Fn::Base64" => {"Fn::Join"=>["", ["#!/bin/bash\n", "test_var", "\n", "yes", "\n"]]},
+"Fn::Base64" => {"Fn::Join"=>["", ["#!/bin/bash\n", "test_var", "\n", true, "\n"]]},
f7cb323
to
01d33a1
Compare
I'm pretty excited for this! I haven't tested it out yet (perhaps tomorrow), but it looks very promising. 👍 on green. |
Should this be a separate Gem? I think this would be useful when using plain Sparkle without stack_master. That being said, I like this approach. 👍 |
dabee46
to
ab915ca
Compare
end | ||
end | ||
|
||
class TemplateContext < AttributeStruct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are monkey patching SparkleFormation::SparkleAttribute::Aws
why can't we also monkey patch SparkleFormation::SparkleStruct
. That way we don't have to define this TempalteContext
just for erubis evaluation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would that be better? Variables require defining methods, so this throw away class means no side effects between multiple user data evaluations in the same template/process, if we patched SF then we'd need to clean those up so I prefer this approach instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum.. that actually make good sense.
Made some updates, added custom vars. I think this is ready to be merged now. @patrobinson yeah it could be a separate gem but it could also live in SparkleFormation itself. For now I'll leave it here. |
LGTM |
98ebded
to
3113822
Compare
👍, I'm pretty happy with this. Nice job @stevehodgkiss! Now let's get to work on command hooks and |
Belated 👍 Nice one! |
Based on the code in this comment sparkleformation/sparkle_formation#54 (comment)
With this change, you can write the following in templates:
It will look in templates/user_data/* for user data files, read the template and compile it with each line being a separate string in the final array. The files can look like this and make use of SF helpers:
Renders like this:
Ref: #104