-
Notifications
You must be signed in to change notification settings - Fork 15
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
refactor: use jsonnet render engine in go binary #54
base: master
Are you sure you want to change the base?
Conversation
return nil | ||
} | ||
|
||
if err := root.Execute(); err != nil { | ||
log.Fatalln(err) | ||
} | ||
} | ||
|
||
// importer wraps jsonnet.FileImporter |
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.
This part is copied from pkg/docsonnet/load.go
.
for k, v := range output { | ||
fullpath := filepath.Join(*dir, k) | ||
dir := filepath.Dir(fullpath) | ||
if err := os.MkdirAll(dir, os.ModePerm); err != nil { | ||
return err | ||
} | ||
if err := os.WriteFile(fullpath, []byte(v), 0644); 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.
This part is copied from pkg/render/render.go
.
While running this against |
This PR removes the Go implementation of the render engine and replacing it by simply invoking the jsonnet code from doc-util in a Jsonnet VM.
This'll get rid of the diverging behavior in rendering engines and reduce toil on maintenance while still providing a binary for those that prefer that.
This also removes the option show the Package data as JSON, I believe they mostly existed to debug the Extract and Transform functions of the go code.
Considering the low number of lines (~100), I've also dropped everything in main.go.
Fixes #35
Replaces #37
Replaces #39
This PR takes a very similar approach as #39 but far more destructive as it doesn't intend to maintain the Go version.
In #39, @yorinasub17 suggests that it hits a max-stack-frames on (tf-libsonnet/hashicorp-aws), I was not able to reproduce that with this PR. Performance wise it was terribly slow, I've ran the same code with
jrsonnet
(rust version) and that was magnitudes faster (~40x) and didn't burn up my CPU. So perhaps it would be beneficial to use the jrsonnet C bindings here instead of the native Go implementation (next PR?).I've also resolved the
./render.libsonnet
import with a simple strings.ReplaceAll on themain.libsonnet
, embedding the whole thing.