terraform/internal/depsfile
Martin Atkins 21d6fb5a37 depsfile: Don't panic when lock file is unreadable
Previously we were expecting that the *hcl.File would always be non-nil,
even in error cases. That isn't always true, so now we'll be more robust
about it and explicitly return an empty locks object in that case, along
with the error diagnostics.

In particular this avoids a panic in a strange situation where the user
created a directory where the lock file would normally go. There's no
meaning to such a directory, so it would always be a mistake and so now
we'll return an error message about it, rather than panicking as before.

The error message for the situation where the lock file is a directory is
currently not very specific, but since it's HCL responsible for generating
that message we can't really fix that at this layer. Perhaps in future
we can change HCL to have a specialized error message for that particular
error situation, but for the sake of this commit the goal is only to
stop the panic and return a normal error message.
2020-12-15 17:00:35 -08:00
..
testdata/locks-files depsfile: Flatten the "hashes" locks to a single set of strings 2020-09-24 14:01:54 -07:00
doc.go internal/depsfile: Loading locks from HCL files on disk 2020-09-08 09:50:58 -07:00
locks.go command/init: Read, respect, and update provider dependency locks 2020-10-09 09:26:23 -07:00
locks_file.go depsfile: Don't panic when lock file is unreadable 2020-12-15 17:00:35 -08:00
locks_file_test.go depsfile: Don't panic when lock file is unreadable 2020-12-15 17:00:35 -08:00
locks_test.go depsfile: Locks.Equal and Locks.Empty methods 2020-10-09 09:26:23 -07:00
paths.go internal/depsfile: Loading locks from HCL files on disk 2020-09-08 09:50:58 -07:00
testing.go command/init: Read, respect, and update provider dependency locks 2020-10-09 09:26:23 -07:00