Files
chart/create_app.sh
Stavros Kois 37b070fe7a NAS-121454 / 23.10 / Add nginx-proxy-manager to community train (#1117)
* Add nginx-proxy-manager (initial commit)

* Update questions and readme

* Add a note/fixme

* remove host network
2023-04-20 01:26:20 +03:00

60 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
VERSION="v4.31.1"
BINARY="yq_linux_amd64"
YQ_PATH="/tmp/yq"
BASE_PATH="library/ix-dev"
if [[ ! -f "$YQ_PATH" ]]; then
wget -q "https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}" -O "$YQ_PATH" && \
chmod +x "$YQ_PATH"
fi
function check_args(){
local arg=$1
if [[ -z "$arg" ]]; then
echo "Error: $2 not specified"
exit 1
fi
}
function copy_app() {
local train=$1
local app=$2
# Check arguments have values
check_args "$train"
check_args "$app"
# Grab version from Chart.yaml
version=$("$YQ_PATH" '.version' "$BASE_PATH/$train/$app/Chart.yaml")
check_args "$version"
# Make sure directories exist
mkdir -p "$train/$app/$version"
helm dependency update "$BASE_PATH/$train/$app"
# Copy files over
rsync --archive --delete "$BASE_PATH/$train/$app/" "$train/$app/$version"
# Rename values.yaml to ix_values.yaml
mv "$train/$app/$version/values.yaml" "$train/$app/$version/ix_values.yaml"
# Remove CI directory from the versioned app
rm -r "$train/$app/$version/ci"
# Grab icon and categories from Chart.yaml
icon=$("$YQ_PATH" '.icon' "$BASE_PATH/$train/$app/Chart.yaml")
check_args "$icon"
categories=$("$YQ_PATH" '.keywords' "$BASE_PATH/$train/$app/Chart.yaml")
check_args "$categories"
# Create item.yaml
echo "" > "$train/$app/item.yaml"
ICON="$icon" "$YQ_PATH" '.icon_url = env(ICON)' --inplace "$train/$app/item.yaml"
CATEGORIES="$categories" "$YQ_PATH" '.categories = env(CATEGORIES)' --inplace "$train/$app/item.yaml"
}
# TODO: Call this function for each changed app
copy_app "$1" "$2"