Allow using base64 encoded string to parsing customized logo files

Currently using svg file content for customized logo might break helm
format checking as Go doesn't know how to parse it.
This patch propose allow using base64 string to parse logo file.
Now we can use like below to avoid format issue:
  logo: "{{ lookup('file', inventory_dir ~ '/files/logo.svg') | b64encode }}"

And parse base64 format string is way more Go/helm friendly.

Change-Id: I2c35502e0592e1d1f6b3b10a5d6350e1fb78f53b
This commit is contained in:
ricolin 2024-05-13 15:58:05 +08:00
parent 42c455a4e8
commit 7d83bd0048
4 changed files with 27 additions and 4 deletions

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Horizon
name: horizon
version: 0.3.21
version: 0.3.22
home: https://docs.openstack.org/horizon/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Horizon/OpenStack_Project_Horizon_vertical.png
sources:

View File

@ -90,9 +90,30 @@ function start () {
# Copy custom logo images
{{- if .Values.manifests.configmap_logo }}
cp /tmp/favicon.ico ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/favicon.ico
cp /tmp/logo.svg ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/logo.svg
cp /tmp/logo-splash.svg ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/logo-splash.svg
if [ -f /tmp/favicon.ico ]; then
favicon=$(cat /tmp/favicon.ico)
if [[ "$favicon" =~ ^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$ ]]; then
echo $(echo $favicon | base64 --decode) > ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/favicon.ico
else
cp /tmp/favicon.ico ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/favicon.ico
fi
fi
if [ -f /tmp/logo-splash.svg ]; then
logo_splash=$(cat /tmp/logo-splash.svg)
if [[ "$logo_splash" =~ ^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$ ]]; then
echo $(echo $logo_splash | base64 --decode) > ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/logo-splash.svg
else
cp /tmp/logo-splash.svg ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/logo-splash.svg
fi
fi
if [ -f /tmp/logo.svg ]; then
logo=$(cat /tmp/logo.svg)
if [[ "$logo" =~ ^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$ ]]; then
echo $(echo $logo | base64 --decode) > ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/logo.svg
else
cp /tmp/logo.svg ${SITE_PACKAGES_ROOT}/openstack_dashboard/static/dashboard/img/logo.svg
fi
fi
{{- end }}
# Compress Horizon's assets.

View File

@ -78,6 +78,7 @@ conf:
- status
horizon:
branding:
# logo, logo_splash and favicon accepts base64 encoded string.
logo:
logo_splash:
favicon:

View File

@ -58,4 +58,5 @@ horizon:
- 0.3.19 Add 2024.1 overrides
- 0.3.20 Enable custom annotations for Openstack secrets
- 0.3.21 Update images used by default
- 0.3.21 Allow using base64 str for parsing logo file
...