Fix notes.txt problems

We were using a bad method to read the ingress values. It's not ensured
by using the service names + checking the "ingress" key.
This commit is contained in:
2024-04-21 16:35:32 +02:00
parent d48fd2f911
commit 9826a54187
4 changed files with 55 additions and 19 deletions

View File

@@ -242,7 +242,11 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) {
f.Write([]byte(readme)) f.Write([]byte(readme))
f.Close() f.Close()
notes := extrafiles.NotesFile() services := make([]string, 0)
for _, service := range project.Services {
services = append(services, service.Name)
}
notes := extrafiles.NotesFile(services)
f, err = os.Create(notesPath) f, err = os.Create(notesPath)
if err != nil { if err != nil {
fmt.Println(utils.IconFailure, err) fmt.Println(utils.IconFailure, err)

View File

@@ -1,11 +1,31 @@
package extrafiles package extrafiles
import _ "embed" import (
_ "embed"
"fmt"
"strings"
)
//go:embed notes.tpl //go:embed notes.tpl
var notesTemplate string var notesTemplate string
// NoteTXTFile returns the content of the note.txt file. // NotesFile returns the content of the note.txt file.
func NotesFile() string { func NotesFile(services []string) string {
return notesTemplate // build a list of ingress URLs if there are any
ingresses := make([]string, len(services))
for i, service := range services {
condition := fmt.Sprintf(`{{- if and .Values.%[1]s.ingress .Values.%[1]s.ingress.enabled }}`, service)
line := fmt.Sprintf(`{{- $count = add1 $count -}}{{- $listOfURL = printf "%%s\n- http://%%s" $listOfURL .Values.%s.ingress.host -}}`, service)
ingresses[i] = fmt.Sprintf("%s\n%s\n{{- end }}", condition, line)
}
// inject the list of ingress URLs into the notes template
notes := strings.Split(notesTemplate, "\n")
for i, line := range notes {
if strings.Contains(line, "ingress_list") {
notes[i] = strings.Join(ingresses, "\n")
}
}
return strings.Join(notes, "\n")
} }

View File

@@ -1,27 +1,39 @@
Your release is named {{ .Release.Name }}. Thanks to have installed {{ .Chart.Name }} {{ .Chart.Version }} as {{ .Release.Name }} ({{.Chart.AppVersion }}).
# Get release information
To learn more about the release, try: To learn more about the release, try:
$ helm -n {{ .Release.Namespace }} status {{ .Release.Name }} $ helm -n {{ .Release.Namespace }} status {{ .Release.Name }}
$ helm -n {{ .Release.Namespace }} get values {{ .Release.Name }}
$ helm -n {{ .Release.Namespace }} get all {{ .Release.Name }} $ helm -n {{ .Release.Namespace }} get all {{ .Release.Name }}
To delete the release, run: # To delete the release
$ helm -n {{ .Release.Namespace }} delete {{ .Release.Name }} Use helm uninstall command to delete the release.
$ helm -n {{ .Release.Namespace }} uninstall {{ .Release.Name }}
Note that some resources may still be in use after a release is deleted. For exemple, PersistentVolumeClaims are not deleted by default for some storage classes or if some annotations are set.
# More information
You can see this notes again by running: You can see this notes again by running:
$ helm -n {{ .Release.Namespace }} get notes {{ .Release.Name }} $ helm -n {{ .Release.Namespace }} get notes {{ .Release.Name }}
{{- $count := 0 -}} {{- $count := 0 -}}
{{- range $s, $v := .Values -}} {{- $listOfURL := "" -}}
{{- if and $v $v.ingress -}} {{* DO NOT REMOVE, replaced by notes.go: ingress_list *}}
{{- $count = add $count 1 -}} {{- if gt $count 0 }}
{{- if eq $count 1 }}
The ingress list is: # List of activated ingresses URL:
{{ end }} {{ $listOfURL }}
- {{ $s }}: http://{{ $v.ingress.host }}{{ $v.ingress.path }}
{{- end -}}
{{ end -}}
You can get these urls with kubectl:
kubeclt get ingress -n {{ .Release.Namespace }}
{{- end }}
Thanks for using Helm!

View File

@@ -22,10 +22,10 @@
{{- define "__APP__.labels" -}} {{- define "__APP__.labels" -}}
{{ include "__APP__.selectorLabels" .}} {{ include "__APP__.selectorLabels" .}}
{{ if .Chart.Version -}} {{ if .Chart.Version -}}
{{ printf "__PREFIX__chart-version: %s" .Chart.Version }} {{ printf "__PREFIX__chart-version: '%s'" .Chart.Version }}
{{- end }} {{- end }}
{{ if .Chart.AppVersion -}} {{ if .Chart.AppVersion -}}
{{ printf "__PREFIX__app-version: %s" .Chart.AppVersion }} {{ printf "__PREFIX__app-version: '%s'" .Chart.AppVersion }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}