Folks, does anyone know what's the general process...
# development
c
Folks, does anyone know what's the general process for using a lockfile? I'm implementing lockfiles for terraform. It's easy enough to implement the
generate-lockfiles
goal. but when I'm installing dependencies, can I just try to infer a dependency on it during dep inference and have it pulled in? The backends which use lockfiles (python, jvm, and js) all seem to be very different and pass lockfiles through some platform-specific machinery and I can't trace it easily
w
@happy-kitchen-89482 would know the most about this
h
Dep inference is entirely orthogonal to lockfile use. Dep inference is entirely in terms of targets. Only when actually placing the third-party deps in the sandbox (e.g., on the pythonpath of the python process, or the classpath of the jvm process) do we run backend-specific logic to figure out if and how to turn a lockfile into the files that we stick in the sandbox
Does that make sense?
c
I think so. So if I have a .terraform.lock.hcl, I shouldn't infer a dependency link on it. Instead, I should use it when downloading deps (in the way that makes sense for terraform it's as part of init). I guess my question would be, how do I get it into the process sandbox where I'm running terrform to download the deps? I'm not sure how to pull it into a digest since it's not a target
h
Yeah, I think the way to model this is to infer deps between targets, but fulfil the deps with the help of a lockfile.
so .terraform.lock.hcl would be generated by
generate-lockfiles
and checked in?
Do you want to support multiple such lockfiles in different parts of the codebase, like we do for python, or is that overkill?
c
I was thinking of starting with multiple lockfiles, terraform autogenerates 1 per root module (deployment) so we don't have to worry about combining multiple lockfiles. I currently have
generate-lockfiles
working for that, just need to read the lockfile somewhere/how
h
And what data is in a terraform lockfile?
c
Some HCl with module names and their hashes. Terraform wants that file to exist on disk, though (there are things we could do to get around that by downloading the modules directly, but that sounds like a future goal)
h
So is it just a matter of placing that file in the sandbox at the expected location?
c
Yep! Just not sure how to get a handle on it, since it's not a target and doesn't have an address, afaik
h
In python there is a mapping from "logical resolve name" to "location of lockfile on disk relative to the repo root"
But with tf those files are always in a well-known location IIRC? Or can the user muck with them?
c
Yep, they're always in a well-known location
h
So just globbing it off the filesystem then?
c
Oh right, I forgot about globs. I was so focussed on targets and addresses. Thanks!