Does anyone know of an existing example of referen...
# development
g
Does anyone know of an existing example of referencing a non-Pants file into a sandbox? For example, a file from
~/.config
. A lot of tools can merge those with site configuration, but I'd rather not expose $HOME etc if I can avoid it.
c
.netrc
and `.env`(scie specific?) handling might be possible examples.
r
I've done this in plugins by cheating and using
cp
to pull the file into the sandbox 😅
g
In this case I think the file will have to be discovered but remain in place, since it may contain relative paths. So it'd be passed as a CLI argument withan absolute path.
f
I would ask, what kind of tool is consuming the config?
g
kubectl
in this case. I'm adding some plumbing so other tools (gcloud, talosctl, etc) can be used as a source the config. And so the alternative is that it's not from anywhere in pants, which means it's on the host. But I want to make that explicit.
Copy code
host_kubeconfig(...)
# or
kubeconfig(
    ...,
    generated=[":talosctl_gen_kubeconfig"]
)
etc
(And then the other targets will reference this kubeconfig explicitly, instead of implicitly getting it from the env.)
r
HAH my plugin actually does almost the exact same thing, but I did recently discover you can ref file contents from
pants.toml
if you wanted to embed the kubectl config as a subsystem option
g
I do not. 😛 Most things aren't singletons in a large codebase. At work we have four different ways of authing with clusters, and if I need to differentiate between them I'd much rather do it all in BUILD files than half in toml and half in Python
I'm starting more and more to treat the root BUILD like bazel's WORKSPACE where I can configure state that drives the codespace. I'm going to do a similar thing for my Rust toolchains later, where you declare them like any other target and so you can say
Copy code
rust_toolchain(
    name="rust-1.71",
    version="1.71.2",
    targets=["wasm32-unknown-unknown", "x86_64-unknown-linux-gnu"],
)

cargo_package(
    toolchain=[":rust-1.71"]
)
(And also makes it very easy to do support from
rust-toolchain.toml
and it still being symmetric.)
b
If you’re looking for more potential examples, I think the s3 file source backend might be able to pull in the aws config files?
g
Thanks, will look at that as well!