wooden-thailand-8386
11/06/2020, 6:25 PM./pants --changed-since ... filter --target-type=files --granularity=target
and that would bring me
only:
services-terraform/docs
instead of (the current results when using filter)
services/terraform/docs
services/terraform/docs/backend.tf
services/terraform/docs/main.tf
services/terraform/docs/outputs.tf
services/terraform/docs/variables.tf
services/terraform/docs/versions.tf
and with that I can use it with terraform
or docker
(when I need to know which Dockerfile) on my CI.
Eric then pointed out that what @witty-crayon-22786 is proposing is a slightly different proposal than what I may want:
Stu’s proposal still will be printing Pants addresses every time:
* services/terraform/docs is a “base” address, and shorthand for service/terraform/docs:docs
* services/terraform/docs:tests is a “base” address
* services/terraform/docs/backend.tf is a “file” address, and shorthand for services/terraform/docs/backend.tf:docs, meaning, that the original metadata comes from the services/terraform/docs:docs target
* services/terraform/docs/backend.tf:tests is a “file” address, meaning the original metadata comes from services/terraform/docs:tests
So, with Stu’s proposal, you’d often get things that look like just file names or just directories, but you could still get services/terraform/docs:tests and services/terraform/docs/backend.tf:tests in the mixWe ended up discussing that maybe this wouldnt be an “issue” if we already had plugins availables for tools such as
docker
, helm
and terraform
and
that plugins
is a way forward but it would be nice if we could also support a better “piping” support so it could be used together with those other tools.
I had a very simplistic idea of maybe having another target such as output
or pipe
that would bring me what I need the way I want.
Eric said:
I think this could be as simple as adding a flag like --raw to list, filter, dependencies, and dependees. Rather than outputting addresses, it will always output file names and/or directoriesThat’s a very rough summary of the conversation and would love to have everyone’s thoughts 🙂
average-vr-56795
11/06/2020, 6:48 PM./pants --changed-since ... filter --target-type=files --granularity=target | cut -d: -f1 | sort | uniq
wooden-thailand-8386
11/06/2020, 7:07 PMaverage-vr-56795
11/06/2020, 7:10 PMwooden-thailand-8386
11/06/2020, 7:57 PMDockerfile
in itenough-analyst-54434
11/06/2020, 8:00 PMpants
as the middleman here required at all? Can you just use git
?wooden-thailand-8386
11/06/2020, 8:06 PMpants
for this one bc those Dockerfiles show up only when I use --changed-dependees=transitive
witty-crayon-22786
11/06/2020, 8:27 PMSo, with Stu’s proposal, you’d often get things that look like just file names or just directories, but you could still get services/terraform/docs:tests and services/terraform/docs/backend.tf:tests in the mixi’d say that the point of the proposal on #11050 is to be able to effectively say “show me only files” or “show me only targets”
hundreds-father-404
11/06/2020, 8:28 PMI don’t think I fully understand the use-case, but is there a reason to do this in pants, instead of outside?Indeed, it’s possible to post-process results. But the idea here is to add better first-class support for piping from Pants to external tooling. Map from the world of targets to files/directories
witty-crayon-22786
11/06/2020, 8:28 PMhundreds-father-404
11/06/2020, 8:29 PM“show me only files”This isn’t quite it, iiuc. They are “file” addresses, not files. Often they look like files, but not always, e.g.
services/terraform/docs/backend.tf:tests
I think there are two proposals here:
1. Your proposal to have filter --granularity={target,file}
2. A --raw
flag, which rather than loses the target info and gives back directories/files
We’d need a combo of both for Thale’s use case.enough-analyst-54434
11/06/2020, 8:32 PM./pants --changed-since ... filter --target-type=files
is === git diff --name-only ...
hundreds-father-404
11/06/2020, 8:32 PM--changed-dependees=transitive
, which git doesn’t have on its own. Plus filtering by target typeenough-analyst-54434
11/06/2020, 8:33 PMwitty-crayon-22786
11/06/2020, 8:33 PMenough-analyst-54434
11/06/2020, 8:35 PMenough-analyst-54434
11/06/2020, 8:35 PMenough-analyst-54434
11/06/2020, 8:36 PMenough-analyst-54434
11/06/2020, 8:36 PMwitty-crayon-22786
11/06/2020, 8:39 PMWe ended up discussing that maybe this wouldnt be an “issue” if we already had plugins availables for tools such as,docker
andhelm
andterraform
thatas @enough-analyst-54434 said, it’s odd that the final thing you’re trying to match on is ais a way forward but it would be nice if we could also support a better “piping” support so it could be used together with those other tools.plugins
files
target rather than a docker
target, for example… but it’s still the case that if what you want out of your query is “the files (not targets) that were affected transitively by a changed file”, then we need to answer the question of how to filter to just files, regardless of the target type that owns them.average-vr-56795
11/06/2020, 8:47 PM./pants --changed-since ... filter --target-type=files --granularity=target | ./pants list-files
seems like it’d be a pretty reasonable solution to this problem?hundreds-father-404
11/06/2020, 8:49 PM./pants list-files(I think that’s basically
./pants filedeps
, without the BUILD files included)witty-crayon-22786
11/06/2020, 8:49 PM--granularity=target
doesn’t exist currently, but yea, potentially. i also don’t think it’s strictly necessary for the command you showed though… the second command can consume either typewitty-crayon-22786
11/06/2020, 8:50 PMwitty-crayon-22786
11/06/2020, 8:51 PMwitty-crayon-22786
11/06/2020, 8:55 PMwooden-thailand-8386
11/06/2020, 8:56 PMarchive
that contains the .pex file and some loose files there… the next step I’ll move that .tar.gz
to a folder with a Dockerfile
and build that image. The thing is, I’m not even using docker build
directly inside my pipeline, it’s a company’s rule thing so I have to pass where that Dockerfile lives inside the repo and they build/do whatever they do (including pushing it to our internal registry).
I solved that issue by asking here and someone else also had a similar issue and he suggested that I’d simple declare a `files`that contains that Dockerfile
and add the archive
/ pex_binary
as a dependency of that files
. Semantically it doesn’t make sense, it definitely should be docker
target or something like that but when I do it this way, if something changes on my project I can then just use ./pants with the tag --build
and that’ll return the files that I need.. I do the same thing for everything else: my terraform modules and helm charts.wooden-thailand-8386
11/06/2020, 8:57 PMenough-analyst-54434
11/06/2020, 9:00 PMwitty-crayon-22786
11/06/2020, 10:24 PMwitty-crayon-22786
11/06/2020, 10:24 PMwitty-crayon-22786
11/06/2020, 10:25 PM