mirror of
https://github.com/truecharts/charts.git
synced 2026-07-07 01:41:20 -03:00
feat(common): list internal urls in notes.txt (#34048)
**Description** This renders a line in notes.txt for each service-port combo. That way users have an easy representation of how they can connect things internally without needing to guess/know/calculate the url themselves. ⚒️ Fixes #31882 **⚙️ Type of change** - [x] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code - [ ] 📜 Documentation Changes **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made changes to the documentation - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning - [ ] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or `fix(docs):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Kjeld Schouten <info@kjeldschouten.nl> Signed-off-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com> Co-authored-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com> Co-authored-by: Stavros Kois <s.kois@outlook.com>
This commit is contained in:
@@ -48,5 +48,4 @@ sources:
|
||||
- https://hub.docker.com/_/
|
||||
- https://hub.docker.com/r/mikefarah/yq
|
||||
type: library
|
||||
version: 28.2.4
|
||||
|
||||
version: 28.3.0
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
{{/* Primary validation for enabled service. */}}
|
||||
{{- include "tc.v1.common.lib.service.primaryValidation" $ -}}
|
||||
{{/* Initialize with existing URLs or an empty list */}}
|
||||
{{- $allUrls := $.Values.chartContext.internalUrls | default list -}}
|
||||
|
||||
{{- range $name, $service := .Values.service -}}
|
||||
{{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict
|
||||
@@ -15,45 +17,57 @@
|
||||
"name" $name "caller" "Service"
|
||||
"key" "service")) -}}
|
||||
|
||||
{{- if eq $enabled "true" -}}
|
||||
{{- if ne $enabled "true" -}}{{- continue -}}{{- end -}}
|
||||
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $service) -}}
|
||||
{{/* Create a copy of the configmap */}}
|
||||
{{- $objectData := (mustDeepCopy $service) -}}
|
||||
{{- $namespace := (include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $ "objectData" $service "caller" "Service")) -}}
|
||||
|
||||
{{/* Init object name */}}
|
||||
{{- $objectName := $name -}}
|
||||
{{/* Init object name */}}
|
||||
{{- $objectName := $name -}}
|
||||
|
||||
{{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict
|
||||
"rootCtx" $ "objectData" $objectData
|
||||
"name" $name "caller" "Service"
|
||||
"key" "service")) -}}
|
||||
|
||||
{{- if eq $expandName "true" -}}
|
||||
{{/* Expand the name of the service if expandName resolves to true */}}
|
||||
{{- $objectName = $fullname -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $expandName "true") (not $objectData.primary) -}}
|
||||
{{/* If the service is not primary append its name to fullname */}}
|
||||
{{- $objectName = (printf "%s-%s" $fullname $name) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.util.metaListToDict" (dict "objectData" $objectData) -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Service") -}}
|
||||
{{- include "tc.v1.common.lib.service.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{/* Set the name of the service */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.service" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict
|
||||
"rootCtx" $ "objectData" $objectData
|
||||
"name" $name "caller" "Service"
|
||||
"key" "service")) -}}
|
||||
|
||||
{{- if eq $expandName "true" -}}
|
||||
{{/* Expand the name of the service if expandName resolves to true */}}
|
||||
{{- $objectName = $fullname -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $expandName "true") (not $objectData.primary) -}}
|
||||
{{/* If the service is not primary append its name to fullname */}}
|
||||
{{- $objectName = (printf "%s-%s" $fullname $name) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.util.metaListToDict" (dict "objectData" $objectData) -}}
|
||||
|
||||
{{/* Perform validations */}}
|
||||
{{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}}
|
||||
{{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Service") -}}
|
||||
{{- include "tc.v1.common.lib.service.validation" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
{{/* Set the name of the service */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Now iterate over the ports in the service */}}
|
||||
{{- range $port := $service.ports -}}
|
||||
{{- $enabledP := (include "tc.v1.common.lib.util.enabled" (dict
|
||||
"rootCtx" $ "objectData" $port
|
||||
"name" $name "caller" "service"
|
||||
"key" "port")) -}}
|
||||
{{- if ne $enabledP "true" -}}{{- continue -}}{{- end -}}
|
||||
{{- $internalUrl := (printf "%s.%s.svc.cluster.local:%s" $objectName $namespace $port.port) -}}
|
||||
{{/* Append URLS */}}
|
||||
{{- $allUrls = mustAppend $allUrls $internalUrl -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.service" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Update internalUrls after the loop */}}
|
||||
{{- $_ := set $.Values.chartContext "internalUrls" $allUrls -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -450,6 +450,16 @@ notes:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{- if .Values.chartContext.internalUrls }}
|
||||
## Connecting Internally
|
||||
|
||||
You can reach this chart inside your cluster, using the following service URLS:
|
||||
{{- range $url := .Values.chartContext.internalUrls -}}
|
||||
- {{ $url }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
## Sources for {{ .Chart.Name }}
|
||||
|
||||
{{- range .Chart.Sources }}
|
||||
|
||||
Reference in New Issue
Block a user