-
Notifications
You must be signed in to change notification settings - Fork 330
Conversation
cty.StringVal("testdata/filesystem/hello.txt"), | ||
}), | ||
false, | ||
}, |
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 deleted these tests cause they were overly dependent on an exact file structure and the functionality was already tested by other cases. The "overly dependent" property was resulting in failures due to test files introduced for the jsonnet tests.
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.
Just one question about what deletes the tempdir. It doesn't look like anything does, which means users will accidentally create a ton of them?
}, | ||
Type: function.StaticReturnType(cty.String), | ||
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { | ||
td, err := ioutil.TempDir("", "waypoint") |
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.
What deletes the tempdir?
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.
Nobody, this is behaving the same way as template*
functions at the moment where we dangle the temp dirs. The hope is it goes into a system temp dir that gets cleared at some point currently (mine does on both macOS and Linux, at least). I think in the future we can try some process-wide cleanup if you wanted but I think that should be a separate PR.
Oh zoinks. I want to fix that then. Go ahead with this and I’ll fix the
tempdir issue in the 0.4 cycle.
On Mon, Apr 19, 2021 at 6:51 PM Mitchell Hashimoto ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In internal/config/funcs/jsonnet.go
<#1360 (comment)>:
> +// stored in a temporary directory that is returned; the original files are
+// untouched.
+var JsonnetDirFunc = function.New(&function.Spec{
+ Params: []function.Parameter{
+ {
+ Name: "dir",
+ Type: cty.String,
+ },
+ {
+ Name: "options",
+ Type: cty.DynamicPseudoType,
+ },
+ },
+ Type: function.StaticReturnType(cty.String),
+ Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
+ td, err := ioutil.TempDir("", "waypoint")
Nobody, this is behaving the same way as template* functions at the
moment where we dangle the temp dirs. The hope is it goes into a system
temp dir that gets cleared at some point currently (mine does on both macOS
and Linux, at least). I think in the future we can try some process-wide
cleanup if you wanted but I think that should be a separate PR.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1360 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAAB2DAQNELHKIOMMFSYDTJTM3HANCNFSM43GXB5HA>
.
--
Evan Phoenix // ***@***.***
|
Sounds good. My recommendation would be to maintain a global var of cleanup things and call a package-level cleanup at some point. We need to keep these directories around longer than expected because plugins may use them all the way until Waypoint exits. |
Yup! I was also thinking about making a tempdir on start and setting it to
TMPDIR so that any plugins that use tempdir will be in the one we cleanup
on exit.
On Mon, Apr 19, 2021 at 7:06 PM Mitchell Hashimoto ***@***.***> wrote:
Sounds good. My recommendation would be to maintain a global var of
cleanup things and call a package-level cleanup at some point. We need to
keep these directories around longer than expected because plugins may use
them all the way until Waypoint exits.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1360 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAAB5H5BA4P2PBVK4U4PTTJTORVANCNFSM43GXB5HA>
.
--
Evan Phoenix // ***@***.***
|
This introduces two new HCL functions
jsonnetfile
andjsonnetdir
which behave similarly to our template functions: they process a file or directory, respectively, and convert Jsonnet-formatted files to JSON. They return a path to the processed file or directory, which is copied rather than updated in-place (behaving the same as our templating functions).These functions can be used anywhere, but are created particularly to pair with #1357 since Jsonnet is a popular way to manage K8S configurations in certain environments.
Features
jsonnet
file or a directory of files.jsonnet
are processed.json
suffix addedExample
Building on #1357