anchore / stereoscope

go library for processing container images and simulating a squash filesystem
Apache License 2.0
78 stars 43 forks source link

Providing an option to mention tempDirectory instead of relying on tmp directory provided by os.TempDir #287

Open pckvcode opened 2 weeks ago

pckvcode commented 2 weeks ago

What would you like to be added: Providing an option to mention tempDirectory instead of relying on tmp directory provided by os.TempDir when GetImage https://github.com/anchore/stereoscope/blob/e6d086e8bef5fab4fcfbd60c9a759c4cb229decf/client.go#L69

Why is this needed: We had a requirement where a customer wants to mention tempDirectory to be used by stereoscope while getting a docker image.

Additional context:

I examined the Stereoscope code to see if we could set a custom tempDir, but currently, that option isn’t available.

Here we are using global variable rootTempDirGenerator and not exposed to change. https://github.com/anchore/stereoscope/blob/e6d086e8bef5fab4fcfbd60c9a759c4cb229decf/client.go#L19

Can we provide an option to update rootLocation in TempDirGenerator https://github.com/anchore/stereoscope/blob/e6d086e8bef5fab4fcfbd60c9a759c4cb229decf/pkg/file/temp_dir_generator.go#L12

willmurphyscode commented 1 week ago

Hi @pckvcode thanks for the request! This is an enhancement we'd be happy to see.

In the meantime os.TempDir respects the usual environment variables for choosing the temp directory, e.g. TMPDIR on mac and Linux, so this might help your use case.