From c19e0ce86a5577e161f310e8c6bdafbf8f5ef6c5 Mon Sep 17 00:00:00 2001 From: Florian Dambrine Date: Mon, 3 Jul 2023 18:14:46 +0200 Subject: [PATCH] Colorful NOTES.txt --- charts/monochart/Chart.yaml | 4 +- charts/monochart/templates/NOTES.txt | 64 ++++++++++++++++++++++++- charts/monochart/templates/_helpers.tpl | 8 +++- 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/charts/monochart/Chart.yaml b/charts/monochart/Chart.yaml index 71ec828..9453f0c 100644 --- a/charts/monochart/Chart.yaml +++ b/charts/monochart/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 description: A declarative helm chart for deploying common types of services on Kubernetes name: monochart -version: 1.0.2 -appVersion: 1.0.2 +version: 1.0.3 +appVersion: 1.0.3 home: https://github.com/Lowess/charts/tree/master/charts/monochart icon: https://raw.githubusercontent.com/cloudposse/charts/master/incubator/monochart/logo.png maintainers: diff --git a/charts/monochart/templates/NOTES.txt b/charts/monochart/templates/NOTES.txt index 44448bd..67b86fe 100644 --- a/charts/monochart/templates/NOTES.txt +++ b/charts/monochart/templates/NOTES.txt @@ -1,3 +1,63 @@ -Thank you for installing {{ .Chart.Name }}. +{{- $digIngress := (dict "host" (first (keys (dig "default" "hosts" (dict) .Values.ingress)))) -}} +{{- $digSvc := (dict "host" (dig "default" "annotations" "external-dns.alpha.kubernetes.io/hostname" (dict) .Values.service)) -}} +{{- $appUrl := "-" -}} +{{- range $url := (pluck "host" $digIngress $digSvc) -}} + {{- if not (empty $url) -}} + {{ $appUrl = $url }} + {{- end -}} +{{- end -}} -Your release is named {{ .Release.Name }}. +------------------------------------ +πŸ“¦ {{ include "colorize" (list "red" .Chart.Name) }} {{ include "colorize" (list "blue" .Chart.Version) }} +└── πŸŒ€ Namespace: {{ include "colorize" (list "green" .Release.Namespace) }} +└── πŸš€ Release: {{ include "colorize" (list "yellow" .Release.Name) }} +└── 🐳 Container: {{ print (include "colorize" (list "gray" .Values.image.repository)) ":" (include "colorize" (list "purple" .Values.image.tag)) }} +└── 🌐 URL: {{ include "colorize" (list "cyan" (print "https://" $appUrl)) }} +------------------------------------ + +{{- $nested := list "configMaps" "secrets" "service" "ingress" "crd" }} + +πŸ“šManifests deployed: +β”‚ +{{- range $key, $val := .Values -}} + {{- if kindIs "map" $val -}} + {{- if not (empty $val) -}} + {{- /* If kind is a nested objects */ -}} + {{- if has $key $nested -}} + {{ $nested_obj := dict }} + {{- range $nkey, $nval := $val -}} + {{- /* handle CRDs */ -}} + {{- if eq $key "crd" -}} + {{- range $crdkey, $crdval := $nval -}} + {{- range $crdobj_key, $crdobj_val := $crdval -}} + {{- if (and (hasKey $crdobj_val "enabled") (get $crdobj_val "enabled")) -}} + {{- $_ := set $nested_obj $crdkey (append (get $nested_obj $crdkey | default list) $crdobj_key) -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- /* other nested objects */ -}} + {{- else if (and (hasKey $nval "enabled") (get $nval "enabled")) -}} + {{- $_ := set $nested_obj $nkey list -}} + {{- end -}} + {{- end -}} + {{- /* Display nested objects */ -}} + {{- if gt (len $nested_obj) 0 -}} + {{ print "β”œβ”€ βœ…" (include "colorize" (list "green" ($key | camelcase))) | nindent 0 }} + {{- range $k, $v := $nested_obj -}} + {{- if gt (len $v) 0 -}} + {{- print "β”‚ └── βœ…" (include "colorize" (list "purple" ($k | camelcase))) | nindent 0 -}} + {{- range $elem := $v -}} + {{- print "β”‚ └── βœ…" $elem | nindent 0 -}} + {{- end -}} + {{- else -}} + {{- print "β”‚ └── βœ…" $k | nindent 0 -}} + {{- end -}} + + {{- end -}} + {{- end -}} + {{- else if (and (hasKey $val "enabled") (get $val "enabled")) -}} + {{ print "β”œβ”€ βœ…" (include "colorize" (list "green" ($key | camelcase))) | nindent 0 }} + {{- end }} + {{- end -}} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/monochart/templates/_helpers.tpl b/charts/monochart/templates/_helpers.tpl index 70e4eb8..9a7d916 100644 --- a/charts/monochart/templates/_helpers.tpl +++ b/charts/monochart/templates/_helpers.tpl @@ -1,5 +1,12 @@ {{/* vim: set filetype=mustache: */}} +{{- define "colorize" -}} +{{- $colors := dict "reset" "\033[0m" "red" "\033[31m" "green" "\033[32m" "yellow" "\033[33m" "blue" "\033[34m" "purple" "\033[35m" "cyan" "\033[36m" "gray" "\033[37m" "white" "\033[97m" -}} +{{- $color := index . 0 -}} +{{- $txt := index . 1 -}} +{{ print (get $colors $color) $txt (get $colors "reset")}} +{{- end -}} + {{/* Fullname of configMap/secret that contains environment vaiables */}} @@ -154,4 +161,3 @@ The pod anti-affinity rule to prefer not to be scheduled onto a node if that nod - {{ .Release.Name | quote }} topologyKey: "kubernetes.io/hostname" {{- end -}} -