#Passing a tempdir from a function

1 messages · Page 1 of 1 (latest)

devout portal
#

Here's the snippet

#

Relevant bits:

tmpDir, err := os.MkdirTemp("", "dagger-dev-engine-*")

[...]
dag.Host().Directory(tmpDir [...])
[...]

#

I have dag.Workdir() but in this case, os.MkdirTemp gives me an absolute path, and I have nowhere to put it

#

I guess I can fix my call to MkdirTemp to create it inside home directory. Still feels leaky

#

Now that I look at that snippet, I don't understand why I need to go through the local filesystem at all...

umbral lichen
#

It looks like you could skip it by using Container.AsTarball instead

#

it's just because our tests need an engine image tarball

devout portal
#

Yeah was just doing that 🙂

#

And feeling verty good doing it

#

I just don't know why it wasn't that way initially. I didn't write this code, lifted it from ./hack/xxx many moons ago

#

I guess it predates Container.AsTarball?

umbral lichen
#

yeah definitely