-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Toolbox template #3287
Toolbox template #3287
Conversation
c9af5c5
to
f373335
Compare
cc @mad01 |
f373335
to
e1ebdc6
Compare
/retest |
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.
Questions for you
pkg/util/file.go
Outdated
) | ||
|
||
// isDirectory checks if a path points to a directory | ||
func isDirectory(path string) (bool, error) { |
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.
We don't have any code like this or in or dependencies?
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.
I've just taken a look at the util package in kubernetes but i can't anything that stands out .. I'll try again though
pkg/util/file.go
Outdated
} | ||
|
||
// ExpandFiles is responsible for resolving any references to directories | ||
func ExpandFiles(path string) ([]string, error) { |
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.
I think there is some code in kubectl that we should probably reuse. I can check tomorrow.
@justinsb thoughts?
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.
same as above
pkg/util/render.go
Outdated
@@ -0,0 +1,130 @@ | |||
/* |
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.
Can we cut and actual package name for this? Maybe templater, you pick a name. Util pkg name drives me nuts.
pkg/util/render.go
Outdated
} | ||
|
||
// templateFuncsMap returns a map if the template functions for this template | ||
func (r *Renderer) templateFuncsMap(tm *template.Template) template.FuncMap { |
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.
Wonder if we should use a library for this. What is helm using?
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.
@chrislovecnm Helm is based on text/template
to be able to use gotemplate i guess. The helm templating code is going a bit more then just what the text/template
package gives and were not that portable. i guess with some effort the helm templating can be a package but that is not without effort.
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.
A couple of nit picks. Looks good overall. Wonder if we should use a lib like what helm uses for stuff like join and indent.
cmd/kops/toolbox_template.go
Outdated
for _, x := range options.configPath { | ||
list, err := putil.ExpandFiles(utils.ExpandPath(x)) | ||
if err != nil { | ||
return err |
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.
Fmt error please
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.
indeed! .. and fixed
cmd/kops/toolbox_template.go
Outdated
list, err := putil.ExpandFiles(utils.ExpandPath(x)) | ||
if err != nil { | ||
return err | ||
} |
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.
Fmt? Helps me trace where the erro was returned
@chrislovecnm @gambol99 for joins |
e1ebdc6
to
94d1f7b
Compare
the sprig library is a good shout so i've updated to using that ... One question though how are managing the vendor directory? .. or you just copying in code? ... or i'm i missing something completely (admittedly i'm only familiar with godeps and glide) @chrislovecnm @justinsb |
There are docs on how to vendor with the sub modules, you will probably want to do just a PR to add the vendoring. The docs are under dev folder in docs. |
94d1f7b
to
91efafd
Compare
91efafd
to
cf0425b
Compare
any other issues on this one? ... |
@gambol99 sorry to be picky, but can we break the vendoring into a separate PR, and get that in first? Then we can get this code in. That is the workflow that we have followed in the past for new deps. Thanks |
I previously looked at this and meant to apply lgtm - sorry for delay. I was able to follow the deps so I don't think these need to be split up... /lgtm |
/test all [submit-queue is verifying that this PR is safe to merge] |
/test pull-kops-e2e-kubernetes-aws |
You may need another rebase to be e2e to pass. @justinsb I cannot remember when you put in the fix in kops that fixed e2e. |
cf0425b
to
83c7397
Compare
/test pull-kops-e2e-kubernetes-aws |
/lgtm |
/test all [submit-queue is verifying that this PR is safe to merge] |
Some more examples would be awesome, we should probably look at getting this out of toolbox ;) |
83c7397
to
2e1f424
Compare
/lgtm cancel //PR changed after LGTM, removing LGTM. @chrislovecnm @gambol99 @justinsb |
2e1f424
to
616860d
Compare
@gambol99 sorry for the nit pick, but can you squash into appropriate chunks of work. I would like to have the vendoring commit moved to the first commit if you can. After that let's get it in ... I want to try it :) |
616860d
to
3d34292
Compare
Extending the current implementation of toolbox template to include multiple files and snippets. Note, i've removed the requirements for defaults as I think people should be forced to specifically pass them. - fixing the vetting iseues to the method YamlToJson -> YAMLToJSON - adding a safety check to ensure templates don't reference an unknown value - extending the unit test to ensure the above works on main and snippets - include the ability to specify multiple configuration files, useful for common.yaml and prod.yaml etc Requested Changes - Toolbox Templating Added the requested changes - moved the templater into it's own package rather than using base util - moved to using the sprig library for additional template function - @note: i couldn't find a native way in sprig to do snippets, also the i've overloaded the indent as it appears to do the indent on all lines rather than on the newline, meaning i'd have to shift my first line back by the indent to get it to work, which seems ugly
Adding the dependecies for the templating
3d34292
to
404d940
Compare
/test pull-kops-e2e-kubernetes-aws |
1 similar comment
/test pull-kops-e2e-kubernetes-aws |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chrislovecnm, gambol99, justinsb The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
Holy crap batman - it merged |
Extending the current implementation of toolbox template to include multiple files and snippets. Note, I've removed the requirements for defaults as I think people should be forced to specifically pass them
Examples of a snippet
We currently use something similar to template our cluster and instances group documents, handling the differences between prod, ci and ephemeral