hi everyone. i have a question about the helm back...
# general
n
hi everyone. i have a question about the helm backend and dependency inference. 🧵
in the documentation it states for it to work one just needs to add a
source_root
. my setup is something like: pants.toml
Copy code
...
[source]
root_patterns = [
    "src/infrastructure/helm-charts/*"
]
...
src/infrastructure/helm-charts/base/Chart.yaml
Copy code
apiVersion: v2
description: Common utilities for helm charts
name: base
version: 1.0.0
src/infrastructure/helm=charts/core/Chart.yaml
Copy code
apiVersion: v2
description: Core dependencies for any kubernetes cluster
name: core
version: 1.0.0

dependencies:
- name: base
Each folder has the build file which tailor generated correctly. As per the documentation this should be sufficient for the base dependency to be discovered from core. But:
Copy code
./pants dependencies src/infrastructure/helm-charts/core
Returns nothing
What am i missing? Thanks in advance!
h
Just a guess, but what happens if you make your source root
src/infrastructure/helm-charts
(without the
*
)?
Setting the root to
src/infrastructure/helm-charts/*
means that every folder under
helm-charts
is a separate root, which is probably not what you intended?
👍 1
n
oh, i see. then i got confused by the documentation
unfortunately i get the same result after changing this 😞
Copy code
[source]
root_patterns = [
  "pants-plugins",
  "src/infrastructure/helm-charts"
]
Screenshot 2022-08-11 at 17.35.41.png
that’s my folder structure. service should depend on base.
Copy code
apiVersion: v2
name: service
description: Deploys a microservice application
version: 1.0.0
dependencies:
  - name: base
i was trying to follow this part.
h
cc @witty-family-13337 - I think you’re best placed to help out here?
w
your source root pattern should be,
src/infrastructure/helm-charts/*
h
It sounds like that was their original setting in the top of the thread
w
right, sorry, I think I know what is happening
what version of Pants are you using? any chance you could test this with latest SHA from pants’ repo?
the was an oversight issue with previous release in which the dependency inference rules where not registered when enabling the backend
👍 1
it's fixed in
main
and could backport it into 2.13
h
So every dir under
src/infrastructure/helm-charts/
should be a root for them? That went against my intuition, so good thing I cc’d you… 🙂
w
yeah that's right, in essence, the location of the
Chart.yaml
is the root
👍 1
h
it's fixed in main and could backport it into 2.13
Yeah, I think that'd be helpful given that 2.14 is a few weeks out at lesat
👍 1
w
it's a very small fix, so I will get a PR ready
❤️ 1
n
thanks for the help! this is a fresh repo:
Copy code
pants_version = "2.12.0"
w
oh, I see, would need to backport it to 2.12 too
n
i can try what you need, but 2.12 is what the quickstart script is generating 🙂
i tried with
2.14.0.dev5
and
/*
and it works
Copy code
./pants dependencies src/infrastructure/helm-charts/service
19:42:07.55 [INFO] Initializing scheduler...
19:42:07.86 [INFO] Scheduler initialized.
src/infrastructure/helm-charts/base:base
w
great, so it is what I suspected
n
it also works with
src/infrastructure/helm-charts
as root through 🤔
should there be a difference?
w
to resolve dependency it works regardless
n
if you need a playground i can just share the full thing, it is a fresh repo just with this helm stuff
w
but if you don't include the /* then the final chart package will include the root folder inside the tarball
n
oh, understood 👍
w
and that's going to cause issues with other Helm operations
👍 1
I’ll try to get a backport asap, as soon as I get home, I’m at my phone right now, in the middle of a training session 😅
n
no rush! so then the docs are correct, it was an actual bug correct?
w
yup! it's a bug
n
dope! thanks for the quick help. do you need me to test in other versions or anything else or you already have all you need?
w
no worries, it's a 1 line change that I totally overlooked
n
unrelated question, how would i be able to do
helm template
? i should write my own goal for this or there is already a way?
w
no any actual way right now, that would come with 2.14 as it adds support for deployments
if you could describe your use case I can try to make it available
n
just printing the result, or writing it to a file. might be helpful for debugging
w
I was thinking of adding it as part of the
export-codegen
goal
but it may take a while as I stabilise the implementation for supporting deployments
n
hm, sorry i’m not familiar enough with pants in general. sort of started today.. but maybe it makes sense 😁
w
this is because rendering a chart requires some of the machinery that is used in the deployments implementation
n
is this
deployments
something with the helm implementation or something intended to become some kind of pants primitive? where can i read more about it?
w
yeah, that's it
n
ah i see the doc, so deployment will be a way of grouping templates to values… to do env specific stuff etc no?
then yes, i think some dry run or knowing what might get deployed if you do trigger the new
deploy
goal would be beneficial.
w
dry run was another option
I’ll get the backport first, then continue on polishing this deployment support for 2.14
n
i was somewhat coming from bazel and read this back in the day. i think it is a sensible way of doing things and may serve as inspiration. in short: • rule for rendering. input: chart + values, output: rendered.yaml • rule for deploying. input: the yaml i liked this approach because one can plumb whatever in between. for example the deploy rule could take my own yaml, or one generated by helm, or kustomize, or whatever.
w
deployments will come as an experimental feature in 2.14, happy to gather feedback as we roll it out
the implementation right now is based on helm install though
n
amazing!
w
Backports of the fix for chart dependency inference for Pants 2.12 and Pants 2.13: • https://github.com/pantsbuild/pants/pull/16490https://github.com/pantsbuild/pants/pull/16491
n
thanks for working on this!
👍 1
should this work on
pants_version = "2.12.0"
or not yet?
oh i see GH actions is still working on it
w
I guess it will be part of 2.12.1 release
h
Yep, we’ll do some point releases soon
maybe even today
For Slack historians, this fix from Alonso gets rid of source root configuration entirely for Helm: https://github.com/pantsbuild/pants/pull/16531
Since we know what the source root has to be (the dir of the Chart.yaml), why force you to configure it? Great work @witty-family-13337!
🙂 2
🙌 2