-
Notifications
You must be signed in to change notification settings - Fork 2
Write templates to specified path #2217
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
Conversation
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.
LGTM! 🥇
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.
💯
Co-authored-by: Simon <[email protected]>
return nil | ||
if flags.outputDir != "" { | ||
for _, res := range templateResources.RenderedTemplate { | ||
filePath := filepath.Join(flags.outputDir, *res.Path) |
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.
Please use SecureJoin https://github.com/fluxcd/flux2/blob/9c3750613014b4b499675b231f7b08103ac5e8d1/pkg/manifestgen/manifest.go#L24 we're accepting data from a user, so we should make sure not to allow escapes!
Closes #2215
What changed?
gitops create template template.yaml --values CLUSTER_NAME=ewq --export
(go run cmd/gitops/main.go create template ...
)only renders to stdout. We want to respect the file paths returned and write out the yaml to those paths, relative to the
--outDir
flag. e.g:gitops create template --outDir ./out --values CLUSTER_NAME=ewq
should write out:./out/clusters/ewq.yaml
How did you validate the change?
Tested with
go run cmd/gitops/main.go create template cmd/gitops/app/create/templates/testdata/template.yaml --values RESOURCE_NAME=ewq NAMESPACE=default TEMPLATE_PATH=./ GIT_REPO_NAME=test GIT_REPO_NAMESPACE=default --outDir=./out
after updating
template.yaml
to:The directories and files that got created:

Documentation Changes
Need to update docs.