terraform/internal
Martin Atkins 2332a7ab47 replacefile: don't create the temporary file in TMPDIR
ioutil.TempFile has a special case where an empty string for its dir
argument is interpreted as a request to automatically look up the system
temporary directory, which is commonly /tmp .

We don't want that behavior here because we're specifically trying to
create the temporary file in the same directory as the file we're hoping
to replace. If the file gets created in /tmp then it might be on a
different device and thus the later atomic rename won't work.

Instead, we'll add our own special case to explicitly use "." when the
given filename is in the current working directory. That overrides the
special automatic behavior of ioutil.TempFile and thus forces the
behavior we need.

This hadn't previously mattered for earlier callers of this code because
they were creating files in subdirectories, but this codepath was failing
for the dependency lock file due to it always being created directly
in the current working directory.

Unfortunately since this is a picky implementation detail I couldn't find
a good way to write a unit test for it without considerable refactoring.
Instead, I verified manually that the temporary filename wasn't in /tmp on
my Linux system, and hope that the comment inline will explain this
situation well enough to avoid an accidental regression in future
maintenence.
2020-10-20 16:29:59 -07:00
..
copy deprecate helper/copy 2020-10-08 08:42:16 -04:00
depsfile internal/depsfile: Update the dependency lock file atomically 2020-10-14 08:01:19 -07:00
didyoumean didyoumean: move from "helper" to "internal" 2020-10-02 13:35:07 -07:00
earlyconfig remove LegacyProvider (#26433) 2020-10-05 08:33:49 -04:00
getproviders use a single log writer 2020-10-19 14:29:54 -04:00
initwd use a single log writer 2020-10-19 14:29:54 -04:00
logging remove LevelFilter 2020-10-19 14:31:05 -04:00
modsdir internal/modsdir: Fix Dropped Error (#24600) 2020-06-04 10:26:26 -04:00
providercache command/init: Mention using the lock file for provider selection 2020-10-09 09:26:23 -07:00
replacefile replacefile: don't create the temporary file in TMPDIR 2020-10-20 16:29:59 -07:00
tfplugin5 Add support for provider metadata to modules. (#22583) 2020-03-05 16:53:24 -08:00
typeexpr configs: Experimental support for optional object type attributes 2020-10-12 10:12:28 -07:00