Improving DRY principle support on gitea Ingress host name #498
Reference in New Issue
Block a user
No description provided.
Delete Branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the change
Introducing
tpl
function on variables related to hostname in./templates/gitea/ingress.yaml
Benefits
The change is intending to support the following syntax in a values.yaml such as:
Possible drawbacks
N/A
Applicable issues
N/A
Additional information
N/A
Thanks.
I am not familiar using the
tpl
function in such cases. I've checked some other charts and none were usingtpl
within the ingress definition.Can you assure that this is not a breaking change? And maybe link some existing charts which do this?
Hello,
The change I have done is backward-compatible.
It allows to use placeholders in the values.yaml file (such as the example in the Benefit section) which are filled when the template are being rendered as explained in https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function.
In short, it evaluates the value that was set in the values.yaml and if the variable has such placeholder, it replaces with value corresponding to the path bound to the placeholder, as it does implicitly in any of the template, else it uses the value as-is.
You can use the example provided with helm template command to see what is generated for
./templates/gitea/ingress.yaml
with it. Another advantage is for those using the gitea chart into an umbrella chart and having its default values with the example provided, one could easily override the value of "global.giteaHostName" using the--set
flag and it would be applied anywhere "global.giteaHostName" is referenced.Unfortunately, I have not come by a public chart using the
tpl
function yet.ced.
Thanks for the explanation. Sounds promising. If the
tpl
function is so flexible, we should consider using it in all places in which. | quote
is being used currently.@justusbunsi What are your thoughts on this?
tpl
is a neat way to DRY. 😀 I even submitted a PR to another Helm Chart in the past to further supporting that1.So I have nothing against it in our Helm Chart. I'd like to have a test ensuring correct behavior. @Ceddaerrix could you add one please? My linked PR in the Jenkins Helm Chart uses the same toolset IIRC. So you could adapt this into your PR.
EDIT: 😀 Found your PR at the Jenkins chart2. Nice.
@pat-s Not sure if we should invest time to add it everywhere blindly. If there is a need, there will be a PR. Like this one. So I'd leave it open to the community.
https://github.com/jenkinsci/helm-charts/pull/509 ↩︎
https://github.com/jenkinsci/helm-charts/pull/908 ↩︎
I was thinking about consistency and avoiding many small PRs that add the same logic in multiple places. But I am fine with both.
TBH, I don't see where else it currently makes sense. I went through the templates and the only part where it would make sense for me are labels or annotations. But I am not fully sure about it either.
For this PR here, I'd expect unit tests ensuring correct rendering behavior. Then I am happy to approve. (@Ceddaerrix)
Any guide on the creation of unit test for such case?
I am still ramping up about Helm chart in general
See https://github.com/helm-unittest/helm-unittest and the existing tests in this repo.
@justusbunsi , @pat-s
Please let me know if I should consider more cases in the unit tests or if it is enough.
LGTM. Thanks for adding the test that ensures the correct behavior.