Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[library-chart] Use templates for all the non-specific paragraphs in NOTES.txt #185

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/library-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v2
name: library-chart
version: 1.5.33
version: 1.5.34
type: library
41 changes: 37 additions & 4 deletions charts/library-chart/templates/_common.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Return the target Kubernetes version
Return the target Kubernetes version
*/}}
{{- define "library-chart.capabilities.kubeVersion" -}}
{{- if .Values.global }}
Expand All @@ -13,4 +11,39 @@ Return the target Kubernetes version
{{- else }}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return the URL at which the service can be accessed
*/}}
{{- define "library-chart.service-url" -}}
{{- if .Values.ingress.enabled -}}
{{- printf "%s://%s" (.Values.ingress.tls | ternary "https" "http") .Values.ingress.hostname -}}
{{- else if .Values.route.enabled -}}
{{- printf "https://%s" .Values.route.hostname -}}
{{- end -}}
{{- end -}}

{{/*
Return the URL at which the service can be accessed
*/}}
{{- define "library-chart.sparkui-url" -}}
{{- if (.Values.spark).sparkui -}}
{{- if .Values.ingress.enabled -}}
{{- printf "%s://%s" (.Values.ingress.tls | ternary "https" "http") .Values.ingress.sparkHostname -}}
{{- else if .Values.route.enabled -}}
{{- printf "https://%s" .Values.route.sparkHostname -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return the URL at which the user-defined custom port(s) can be accessed
*/}}
{{- define "library-chart.user-url" -}}
{{- if .Values.ingress.enabled -}}
{{- printf "%s://%s" (.Values.ingress.tls | ternary "https" "http") .Values.ingress.userHostname -}}
{{- else if .Values.route.enabled -}}
{{- printf "https://%s" .Values.route.userHostname -}}
{{- end -}}
{{- end -}}
163 changes: 163 additions & 0 deletions charts/library-chart/templates/_notes.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{{/*
Generate a general message as a NOTES header.
*/}}
{{- define "library-chart.general-message" -}}
{{- if and (eq .Values.userPreferences.language "fr" (.Values.message).fr) -}}
{{- (.Values.message).fr }}
{{ else -}}
{{- (.Values.message).en }}
{{ end -}}
{{- end -}}


{{/*
Generate NOTES about connection to the service.

Usage:
{{ include "library-chart.notes-connection" (dict "serviceName" "Visual Studio Code" "context" $) }}

Params:
- serviceName - String - Optional. The human readable name of the service.
- context - Dict - Required. The context for the template evaluation.
*/}}
{{- define "library-chart.notes-connection" -}}
{{- $serviceName := .serviceName | default .context.Chart.Name -}}
{{- with .context -}}
{{- if eq .Values.userPreferences.language "fr" -}}
{{- if or (.Values.ingress).enabled (.Values.route).enabled }}
- Vous pouvez vous connecter à {{ $serviceName }} depuis votre navigateur en utilisant [ce lien]({{ include "library-chart.service-url" . }}).
{{ else }}
- Votre service {{ $serviceName }} n'est pas directement exposé sur internet.
Vous pouvez tout de même y accéder en executant la commande suivante depuis un terminal :
`kubectl port-forward service/{{ include "library-chart.fullname" . }} <port-local>:{{ .Values.networking.service.port }}`
puis en vous connectant depuis votre navigateur à l'URL suivante : `http://localhost:<port-local>`
{{ end -}}
- Votre password: {{ .Values.security.password }}
{{ else -}}
{{- if or (.Values.ingress).enabled (.Values.route).enabled }}
- You can connect to {{ $serviceName }} with your browser using [this link]({{ include "library-chart.service-url" . }}).
{{ else }}
- Your service {{ $serviceName }} is not exposed on the internet.
You can still access it by running the following command from a terminal:
`kubectl port-forward service/{{ include "library-chart.fullname" . }} <local-port>:{{ .Values.networking.service.port }}`
and then use the following URL with your browser: `http://localhost:<local-port>`
{{ end -}}
- Your password: {{ .Values.security.password }}
{{ end -}}
{{- end -}}
{{- end -}}


{{/*
Generate NOTES about connection to the Spark UI (if enabled).
*/}}
{{- define "library-chart.notes-sparkui" -}}
{{- if (.Values.spark).sparkui -}}
{{- if eq .Values.userPreferences.language "fr" -}}
{{- if or (.Values.ingress).enabled (.Values.route).enabled }}
- Vous pouvez vous connecter à l'interface Spark depuis votre navigateur en utilisant [ce lien]({{ include "library-chart.sparkui-url" . }}).
{{ else }}
- Votre interface Spark n'est pas directement exposée sur internet.
Vous pouvez tout de même y accéder en executant la commande suivante depuis un terminal :
`kubectl port-forward service/{{ include "library-chart.fullname" . }} <port-local>:{{ .Values.networking.sparkui.port }}`
puis en vous connectant depuis votre navigateur à l'URL suivante : `http://localhost:<port-local>`
{{ end -}}
- Votre nom d'utilisateur : **`{{ .Values.environment.user }}`**
- Votre mot de passe : **`{{ .Values.security.password }}`**
{{ else -}}
{{- if or (.Values.ingress).enabled (.Values.route).enabled }}
- You can connect to the Spark UI with your browser using [this link]({{ include "library-chart.sparkui-url" . }}).
{{ else }}
- Your Spark interface is not exposed on the internet.
You can still access it by running the following command from a terminal:
`kubectl port-forward service/{{ include "library-chart.fullname" . }} <local-port>:{{ .Values.networking.sparkui.port }}`
and then use the following URL with your browser: `http://localhost:<local-port>`
{{ end -}}
- Your login: **`{{ .Values.environment.user }}`**
- Your password: **`{{ .Values.security.password }}`**
{{ end -}}
{{- end -}}
{{- end -}}


{{/*
Generate NOTES about custom user-defined port exposition.
*/}}
{{- define "library-chart.notes-custom-ports" -}}
{{- if and
((.Values.networking).user).enabled
(or .Values.networking.user.ports .Values.networking.user.port)
(or (.Values.ingress).enabled (.Values.route).enabled)
-}}
{{- $userPorts := .Values.networking.user.ports | default (list .Values.networking.user.port) -}}
{{- $URL := include "library-chart.user-url" . -}}
{{- if eq .Values.userPreferences.language "fr" -}}
{{- if eq (len $userPorts) 1 }}
Vous pouvez vous connecter à votre port personnalisé ({{ first $userPorts }}) en utilisant [ce lien]({{ $URL }}).
{{- else }}
Vous pouvez vous connecter à vos ports personnalisés en utilisant les liens ci-dessous :
{{ range $userPort := $userPorts -}}
- [Port {{ $userPort }}]({{ regexReplaceAll "([^\\.]+)\\.(.*)" $URL (printf "${1}-%d.${2}" (int $userPort)) }})
{{ end -}}
{{- end -}}
Si vous accédez ces URL sans démarrer vos services personnalisés, vous obtiendrez une erreur 502 Bad Gateway.
{{ else -}}
{{- if eq (len $userPorts) 1 }}
You can connect to your custom port ({{ first $userPorts }}) using [this link]({{ $URL }}).
{{- else }}
You can connect to your custom ports using the following links:
{{ range $userPort := $userPorts -}}
- [Port {{ $userPort }}]({{ regexReplaceAll "([^\\.]+)\\.(.*)" $URL (printf "${1}-%d.${2}" (int $userPort)) }})
{{ end -}}
{{- end -}}
If you access these URL without starting the corresponding services you will get a 502 bad gateway error.
{{ end -}}
{{- end -}}
{{- end -}}


{{/*
Generate NOTES about service deletion.
*/}}
{{- define "library-chart.notes-deletion" -}}
{{- if not (and (.Values.persistence).enabled .Values.persistence.existingClaim) -}}
{{- if eq .Values.userPreferences.language "fr" }}
**REMARQUES concernant la suppression :**
Votre répertoire de travail `/home/{{ .Values.environment.user }}/work`
sera **immédiatement effacé** à la suppression de votre service {{ .Chart.Name }}.
Assurez-vous de sauvegarder toutes vos ressources de travail sur des supports persistants :
- Votre code peux être stocké dans une forge logicielle telle que git.
- Vos données et modèles peuvent être stockés dans un système de stockage objet tel que S3.
Il est possible d'associer un script d'initialisation à votre service pour mettre en place un environnement de travail sur mesure
(télécharger vos ressources, installer les bibliothèques et outils dont vous avez besoin, configurer votre service, etc.)
{{ else }}
**NOTES about deletion:**
Your work directory `/home/{{ .Values.environment.user }}/work`
will be **immediately deleted** upon the termination of your {{ .Chart.Name }} service.
Make sure to save all your work resources on persistent storage:
- Your code can be stored in a version control system such as git.
- Your data and models can be stored in an object storage system such as S3.
It is possible to associate an initialization script with your service to set up a customized working environment
(download your resources, install the libraries and tools you need, configure your service, etc.).
{{ end -}}
{{- end -}}
{{- end -}}


{{/*
Prints out all NOTES.

Usage:
{{- template "library-chart.notes" (dict "serviceName" "Visual Studio Code" "context" $) -}}

Params:
- serviceName - String - Optional. The human readable name of the service.
- context - Dict - Required. The context for the template evaluation.
*/}}
{{- define "library-chart.notes" -}}
{{- template "library-chart.general-message" .context -}}
{{- template "library-chart.notes-connection" . -}}
{{- template "library-chart.notes-sparkui" .context -}}
{{- template "library-chart.notes-custom-ports" .context -}}
{{- template "library-chart.notes-deletion" .context -}}
{{- end -}}
Loading