Skip to content

Commit

Permalink
Colorful NOTES.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Lowess committed Jul 3, 2023
1 parent 20ed2de commit c19e0ce
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
4 changes: 2 additions & 2 deletions charts/monochart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
64 changes: 62 additions & 2 deletions charts/monochart/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 -}}
8 changes: 7 additions & 1 deletion charts/monochart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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
*/}}
Expand Down Expand Up @@ -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 -}}

0 comments on commit c19e0ce

Please sign in to comment.