-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Namespacing the aws funcs #148
Conversation
The problem with this approach, as it stands right now, is that the function has to be exported to be visible, so it changes to |
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.
See comments on sync.Once
aws/aws.go
Outdated
|
||
// NS - | ||
func NS() *awsFuncs { | ||
if af == nil { |
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.
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.
thanks, this seemed inelegant, but I didn't want to use init()
- I'll replace with sync.Once
🙂
aws/aws.go
Outdated
type awsFuncs struct{} | ||
|
||
func (a *awsFuncs) EC2Region(def ...string) string { | ||
if meta == nil { |
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.
Ditto this conditional.
877836c
to
9ce9d1e
Compare
I've been doing some digging around the upper/lower-case function name problem, and I found some discussion of how they did it in hugo - gohugoio/hugo#3042 It looks like basically the same approach was tried initially but in the end they seem to have gone with something more complex. I'm still wrapping my head around what exactly was done - most of the magic seems to be in https://github.com/spf13/hugo/tree/master/tpl |
9ce9d1e
to
3d14852
Compare
Ok, seems I totally misunderstood what's going on in hugo - they don't seem to support lower-cased function names in namespaces. What I was looking at was aliases, which are in the global namespace. We're stuck with upper-cased function names. NBD. I'll move on with life now 😛 |
3a356d2
to
9556e07
Compare
e2ad280
to
8c6440d
Compare
Signed-off-by: Dave Henderson <[email protected]>
Signed-off-by: Dave Henderson <[email protected]>
8c6440d
to
d8f2a93
Compare
@hairyhenderson Are you good with this approach now? |
@sean- yeah, it seems to be fine. There's probably further refinements that could be made to the specifics, but as a general approach I'm happy with it for now. |
This is an offshoot of #145 to try and figure out the best way to namespace built-in functions.
Ideally, I'd like to be able to use the existing function names, and simply move them under a namespace. So, instead of
{{ ec2region }}
, I'd like{{ aws.ec2region }}
.Signed-off-by: Dave Henderson [email protected]