2021-09-07 15:25:30 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
DEFAULT_CHART_RELEASER_VERSION=v1.2.1
|
|
|
|
|
|
|
|
show_help() {
|
|
|
|
cat << EOF
|
|
|
|
Usage: $(basename "$0") <options>
|
|
|
|
-h, --help Display help
|
|
|
|
-v, --version The chart-releaser version to use (default: $DEFAULT_CHART_RELEASER_VERSION)"
|
|
|
|
--config The path to the chart-releaser config file
|
|
|
|
-d, --charts-dir The charts directory (default: charts)
|
|
|
|
-u, --charts-repo-url The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)
|
|
|
|
-o, --owner The repo owner
|
|
|
|
-r, --repo The repo name
|
|
|
|
-p, --production Enables uploading releases to github releases
|
2021-09-07 18:37:52 +00:00
|
|
|
-s, --standalone Disables Chart Releaser and Catalog Validation, for local generation
|
2021-09-07 15:25:30 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
local version="$DEFAULT_CHART_RELEASER_VERSION"
|
|
|
|
local config=
|
2021-09-07 18:37:52 +00:00
|
|
|
local standalone=
|
|
|
|
local charts_dir=charts/**
|
2021-09-07 15:25:30 +00:00
|
|
|
local owner=
|
|
|
|
local repo=
|
|
|
|
local production=
|
|
|
|
local charts_repo_url=
|
2021-09-07 18:37:52 +00:00
|
|
|
local token=${CR_TOKEN:-false}
|
2021-12-04 14:20:01 +00:00
|
|
|
local parthreads=$(($(nproc) * 2))
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
parse_command_line "$@"
|
2021-09-07 18:37:52 +00:00
|
|
|
if [ "${token}" == "false" ]; then
|
2022-03-30 11:38:31 +00:00
|
|
|
echo "env #CR_TOKEN not found, defaulting to production=false"
|
2021-09-07 15:52:00 +00:00
|
|
|
production="false"
|
|
|
|
fi
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
local repo_root
|
|
|
|
repo_root=$(git rev-parse --show-toplevel)
|
|
|
|
pushd "$repo_root" > /dev/null
|
|
|
|
|
|
|
|
echo 'Looking up latest tag...'
|
|
|
|
local latest_tag
|
|
|
|
latest_tag=$(lookup_latest_tag)
|
|
|
|
|
|
|
|
echo "Discovering changed charts since '$latest_tag'..."
|
|
|
|
local changed_charts=()
|
|
|
|
readarray -t changed_charts <<< "$(lookup_changed_charts "$latest_tag")"
|
2022-03-30 12:48:04 +00:00
|
|
|
# copy_general_docs
|
2021-09-07 15:25:30 +00:00
|
|
|
if [[ -n "${changed_charts[*]}" ]]; then
|
|
|
|
|
2022-04-01 10:38:15 +00:00
|
|
|
prep_helm
|
2021-12-04 14:20:01 +00:00
|
|
|
|
2021-12-05 21:14:10 +00:00
|
|
|
parallel -j ${parthreads} chart_runner '2>&1' ::: ${changed_charts[@]}
|
2021-10-20 11:49:34 +00:00
|
|
|
echo "Starting post-processing"
|
2022-07-22 20:10:49 +00:00
|
|
|
# pre_commit
|
2022-03-26 14:22:16 +00:00
|
|
|
validate_catalog
|
2022-03-30 09:23:46 +00:00
|
|
|
if [ "${production}" == "true" ]; then
|
2022-03-30 12:48:04 +00:00
|
|
|
gen_dh_cat
|
2022-03-29 19:07:40 +00:00
|
|
|
upload_catalog
|
|
|
|
upload_dhcatalog
|
2022-03-30 09:23:46 +00:00
|
|
|
fi
|
2021-09-07 15:25:30 +00:00
|
|
|
else
|
|
|
|
echo "Nothing to do. No chart changes detected."
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd > /dev/null
|
|
|
|
}
|
|
|
|
|
2021-12-04 14:20:01 +00:00
|
|
|
chart_runner(){
|
|
|
|
if [[ -d "${1}" ]]; then
|
|
|
|
echo "Start processing ${1} ..."
|
|
|
|
chartversion=$(cat ${1}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }')
|
|
|
|
chartname=$(basename ${1})
|
|
|
|
train=$(basename $(dirname "${1}"))
|
|
|
|
SCALESUPPORT=$(cat ${1}/Chart.yaml | yq '.annotations."truecharts.org/SCALE-support"' -r)
|
|
|
|
helm dependency update "${1}" --skip-refresh || (sleep 10 && helm dependency update "${1}" --skip-refresh) || (sleep 10 && helm dependency update "${1}" --skip-refresh)
|
2022-04-01 10:38:15 +00:00
|
|
|
sync_tag "${1}" "${chartname}" "$train" "${chartversion}" || echo "Tag sync failed..."
|
2022-07-22 16:07:34 +00:00
|
|
|
# create_changelog "${1}" "${chartname}" "$train" "${chartversion}" || echo "changelog generation failed..."
|
|
|
|
# generate_docs "${1}" "${chartname}" "$train" "${chartversion}" || echo "Docs generation failed..."
|
2022-03-30 10:26:37 +00:00
|
|
|
#copy_docs "${1}" "${chartname}" "$train" "${chartversion}" || echo "Docs Copy failed..."
|
|
|
|
#package_chart "${1}"
|
2021-12-04 14:20:01 +00:00
|
|
|
if [[ "${SCALESUPPORT}" == "true" ]]; then
|
|
|
|
clean_apps "${1}" "${chartname}" "$train" "${chartversion}"
|
|
|
|
copy_apps "${1}" "${chartname}" "$train" "${chartversion}"
|
|
|
|
patch_apps "${1}" "${chartname}" "$train" "${chartversion}"
|
|
|
|
include_questions "${1}" "${chartname}" "$train" "${chartversion}"
|
|
|
|
clean_catalog "${1}" "${chartname}" "$train" "${chartversion}"
|
|
|
|
else
|
|
|
|
echo "Skipping chart ${1}, no correct SCALE compatibility layer detected"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Chart '${1}' no longer exists in repo. Skipping it..."
|
|
|
|
fi
|
|
|
|
echo "Done processing ${1} ..."
|
|
|
|
}
|
|
|
|
export -f chart_runner
|
|
|
|
|
2021-09-13 08:46:07 +00:00
|
|
|
include_questions(){
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
|
|
|
local target="catalog/${train}/${chartname}/${chartversion}"
|
|
|
|
echo "Including standardised questions.yaml includes for: ${chartname}"
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2022-08-08 21:25:02 +00:00
|
|
|
# Replace # Include{portalLink} with the standard portalLink codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{portalLink}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/portalLink.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2021-10-20 17:39:05 +00:00
|
|
|
# Replace # Include{global} with the standard global codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{global}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/global.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-20 17:39:05 +00:00
|
|
|
|
2021-09-13 09:12:18 +00:00
|
|
|
# Replace # Include{groups} with the standard groups codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{groups}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/groups.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2021-10-04 11:46:38 +00:00
|
|
|
# Replace # Include{fixedEnv} with the standard fixedEnv codesnippet
|
2021-10-04 11:27:12 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{fixedEnv}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/fixedEnv.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-04 11:27:12 +00:00
|
|
|
|
2022-08-08 21:25:02 +00:00
|
|
|
# Replace # Include{controller} with the standard controller codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controller}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/controller/controller.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{controllerDeployment} with the standard controllerDeployment codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controllerDeployment}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/controller/controllerDeployment.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{controllerStatefullset} with the standard controllerStatefullset codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controllerStatefullset}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/controller/controllerStatefullset.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{controllerDaemonset} with the standard controllerDaemonset codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controllerDaemonset}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/controller/controllerDaemonset.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{replicas} with the standard replicas codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{replicas}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/replicas/replicas.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{replica1} with the standard replica1 codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{replica1}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/replicas/replica1.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{replica2} with the standard replica2 codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{replica2}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/replicas/replica2.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{replica3} with the standard replica3 codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{replica3}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/replicas/replica3.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{strategy} with the standard strategy codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{strategy}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/strategy/strategy.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{recreate} with the standard recreate codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{recreate}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/strategy/recreate.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{rollingupdate} with the standard rollingupdate codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{rollingupdate}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/strategy/rollingupdate.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2021-09-13 10:58:34 +00:00
|
|
|
# Replace # Include{controllerExpert} with the standard controllerExpert codesnippet
|
2021-09-13 09:12:18 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controllerExpert}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/controller/controllerExpert.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2022-08-12 08:40:46 +00:00
|
|
|
# Replace # Include{controllerExpertExtraArgs} with the standard controllerExpertExtraArgs codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controllerExpertExtraArgs}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/controller/controllerExpertExtraArgs.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
|
2022-06-27 09:38:05 +00:00
|
|
|
# Replace # Include{controllerExpertCommand} with the standard controllerExpertCommand codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{controllerExpertCommand}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/controller/controllerExpertCommand.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2022-06-27 09:38:05 +00:00
|
|
|
|
2021-09-13 10:58:34 +00:00
|
|
|
# Replace # Include{containerConfig} with the standard containerConfig codesnippet
|
2021-09-13 09:12:18 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{containerConfig}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/containerConfig.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2022-08-08 21:25:02 +00:00
|
|
|
# Replace # Include{serviceRoot} with the standard serviceRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2022-09-14 21:27:12 +00:00
|
|
|
# Replace # Include{serviceSelectorExtras} with the standard serviceSelectorExtras codesnippet
|
2021-11-06 10:29:34 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
2022-09-14 21:27:12 +00:00
|
|
|
/# Include{serviceSelectorExtras}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceSelectorExtras.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{serviceSelectorSimple} with the standard serviceSelectorSimple codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceSelectorSimple}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceSelectorSimple.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{serviceSelectorClusterIP} with the standard serviceSelectorClusterIP codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceSelectorClusterIP}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceSelectorClusterIP.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{serviceSelectorLoadBalancer} with the standard serviceSelectorLoadBalancer codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceSelectorLoadBalancer}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceSelectorLoadBalancer.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{serviceSelectorNodePort} with the standard serviceSelectorNodePort codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceSelectorNodePort}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceSelectorNodePort.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2022-08-08 21:25:02 +00:00
|
|
|
|
|
|
|
# Replace # Include{advancedPortHTTP} with the standard advancedPortHTTP codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{advancedPortHTTP}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/advancedPortHTTP.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{advancedPortHTTPS} with the standard advancedPortHTTPS codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{advancedPortHTTPS}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/advancedPortHTTPS.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{advancedPortTCP} with the standard advancedPortTCP codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{advancedPortTCP}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/advancedPortTCP.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{advancedPortUDP} with the standard advancedPortUDP codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{advancedPortUDP}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/advancedPortUDP.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{serviceExpertRoot} with the standard serviceExpertRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceExpertRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/service/serviceExpertRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-06 10:29:34 +00:00
|
|
|
|
2021-10-05 10:50:21 +00:00
|
|
|
# Replace # Include{serviceExpert} with the standard serviceExpert codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceExpert}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/service/serviceExpert.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-05 10:50:21 +00:00
|
|
|
|
2021-09-13 10:58:34 +00:00
|
|
|
# Replace # Include{serviceList} with the standard serviceList codesnippet
|
2021-09-13 09:12:18 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{serviceList}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/service/serviceList.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{vctRoot} with the standard vctRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{vctRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/vctRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{persistenceRoot} with the standard persistenceRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{persistenceRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/persistence/persistenceRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2021-11-06 18:23:24 +00:00
|
|
|
# Replace # Include{persistenceBasic} with the standard persistenceBasic codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{persistenceBasic}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/persistence/persistenceBasic.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-06 18:23:24 +00:00
|
|
|
|
|
|
|
# Replace # Include{persistenceAdvanced} with the standard persistenceAdvanced codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{persistenceAdvanced}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/persistence/persistenceAdvanced.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-06 18:23:24 +00:00
|
|
|
|
2021-09-13 10:58:34 +00:00
|
|
|
# Replace # Include{persistenceList} with the standard persistenceList codesnippet
|
2021-09-13 09:12:18 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{persistenceList}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/persistence/persistenceList.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-05 10:50:21 +00:00
|
|
|
|
2022-03-03 14:04:31 +00:00
|
|
|
# Replace # Include{security} with the standard security codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{security}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/security.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2022-08-08 21:25:02 +00:00
|
|
|
# Replace # Include{securityContextAdvancedRoot} with the standard securityContextAdvancedRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{securityContextAdvancedRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/securityContextAdvancedRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2022-01-13 11:18:20 +00:00
|
|
|
# Replace # Include{securityContextAdvanced} with the standard securityContextAdvanced codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{securityContextAdvanced}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/securityContextAdvanced.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2022-08-08 21:25:02 +00:00
|
|
|
# Replace # Include{podSecurityContextRoot} with the standard podSecurityContextRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{podSecurityContextRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/podSecurityContextRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2022-01-13 11:18:20 +00:00
|
|
|
# Replace # Include{podSecurityContextAdvanced} with the standard podSecurityContextAdvanced codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{podSecurityContextAdvanced}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/podSecurityContextAdvanced.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2022-08-08 21:25:02 +00:00
|
|
|
# Replace # Include{ingressRoot} with the standard ingressRoot codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{ingressRoot}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/ingress/ingressRoot.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2021-10-05 10:50:21 +00:00
|
|
|
# Replace # Include{ingressDefault} with the standard ingressDefault codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{ingressDefault}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/ingress/ingressDefault.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-05 10:50:21 +00:00
|
|
|
|
|
|
|
# Replace # Include{ingressTLS} with the standard ingressTLS codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{ingressTLS}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/ingress/ingressTLS.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-05 10:50:21 +00:00
|
|
|
|
|
|
|
# Replace # Include{ingressTraefik} with the standard ingressTraefik codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{ingressTraefik}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/ingress/ingressTraefik.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-10-05 10:50:21 +00:00
|
|
|
|
|
|
|
# Replace # Include{ingressExpert} with the standard ingressExpert codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{ingressExpert}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/ingress/ingressExpert.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2021-09-13 10:58:34 +00:00
|
|
|
# Replace # Include{ingressList} with the standard ingressList codesnippet
|
2021-09-13 09:12:18 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{ingressList}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/ingress/ingressList.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 09:12:18 +00:00
|
|
|
|
2021-09-13 10:58:34 +00:00
|
|
|
# Replace # Include{addons} with the standard addons codesnippet
|
2021-09-13 08:46:07 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
2021-09-13 09:12:18 +00:00
|
|
|
/# Include{addons}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/addons.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 10:58:34 +00:00
|
|
|
|
2021-11-23 20:36:27 +00:00
|
|
|
# Replace # Include{metrics} with the standard metrics codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{metrics}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/metrics/metrics.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-23 20:36:27 +00:00
|
|
|
|
|
|
|
# Replace # Include{metrics3m} with the standard metrics3m codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{metrics3m}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/metrics/metrics3m.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-23 20:36:27 +00:00
|
|
|
|
|
|
|
# Replace # Include{metrics60m} with the standard metrics60m codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{metrics60m}/ { for (i=0;i<n;++i) print a[i]; next }
|
2022-08-08 21:25:02 +00:00
|
|
|
1' templates/questions/metrics/metrics60m.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-23 20:36:27 +00:00
|
|
|
|
|
|
|
# Replace # Include{prometheusRule} with the standard prometheusRule codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{prometheusRule}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/prometheusRule.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-11-23 20:36:27 +00:00
|
|
|
|
2021-10-04 11:46:38 +00:00
|
|
|
# Replace # Include{advanced} with the standard advanced codesnippet
|
2021-09-13 10:58:34 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
2021-10-04 11:46:38 +00:00
|
|
|
/# Include{advanced}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/advanced.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-13 10:58:34 +00:00
|
|
|
|
2021-10-04 11:46:38 +00:00
|
|
|
# Replace # Include{resources} with the standard resources codesnippet
|
2021-09-26 18:44:02 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{resources}/ { for (i=0;i<n;++i) print a[i]; next }
|
2021-12-04 18:49:56 +00:00
|
|
|
1' templates/questions/resources.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2021-09-26 18:44:02 +00:00
|
|
|
|
2022-08-12 11:11:35 +00:00
|
|
|
# Replace # Include{documentation} with the standard resources codesnippet
|
2022-08-12 10:59:24 +00:00
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
2022-08-12 11:11:35 +00:00
|
|
|
/# Include{documentation}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/documentation.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
2022-08-12 10:59:24 +00:00
|
|
|
|
2022-08-27 20:58:46 +00:00
|
|
|
# Replace # Include{[forwardedHeaders]} with the standard forwardedHeaders codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{forwardedHeaders}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/traefik/forwardedHeaders.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
|
|
|
# Replace # Include{proxyProtocol} with the standard proxyProtocol codesnippet
|
|
|
|
awk 'NR==FNR { a[n++]=$0; next }
|
|
|
|
/# Include{proxyProtocol}/ { for (i=0;i<n;++i) print a[i]; next }
|
|
|
|
1' templates/questions/traefik/proxyProtocol.yaml ${target}/questions.yaml > "tmp${chartname}" && mv "tmp${chartname}" ${target}/questions.yaml
|
|
|
|
|
2021-09-13 08:46:07 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f include_questions
|
2021-09-13 08:46:07 +00:00
|
|
|
|
2021-09-12 07:55:20 +00:00
|
|
|
clean_catalog() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2021-09-12 08:00:53 +00:00
|
|
|
cd catalog/${train}/${chartname}
|
|
|
|
local majorversions=$( (find . -mindepth 1 -maxdepth 1 -type d \( ! -iname ".*" \) | sed 's|^\./||g') | sort -Vr | cut -c1 | uniq)
|
|
|
|
echo "Removing old versions for: ${chartname}"
|
2021-09-12 07:55:20 +00:00
|
|
|
for majorversion in ${majorversions}; do
|
2021-09-12 08:00:53 +00:00
|
|
|
local maxofmajor=$( (find . -mindepth 1 -maxdepth 1 -type d \( -iname "${majorversion}.*" \) | sed 's|^\./||g') | sort -Vr | head -n1 )
|
|
|
|
local rmversions=$( (find . -mindepth 1 -maxdepth 1 -type d \( -iname "${majorversion}.*" \) \( ! -iname "${maxofmajor}" \) | sed 's|^\./||g') | sort -Vr )
|
2021-09-12 07:55:20 +00:00
|
|
|
rm -Rf ${rmversions}
|
|
|
|
done
|
|
|
|
cd -
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f clean_catalog
|
2021-09-12 07:55:20 +00:00
|
|
|
|
2022-03-17 09:25:51 +00:00
|
|
|
gen_dh_cat() {
|
|
|
|
rm -rf dh_catalog/*.*
|
|
|
|
rm -rf dh_catalog/*
|
|
|
|
cp -rf catalog/* dh_catalog
|
|
|
|
cd dh_catalog
|
2022-03-17 09:54:05 +00:00
|
|
|
find ./ -type f -name *.yaml -exec sed -i 's/tccr.io/dh.tccr.io/gI' {} \;
|
2022-03-17 09:25:51 +00:00
|
|
|
cd -
|
|
|
|
}
|
|
|
|
export -f gen_dh_cat
|
|
|
|
|
2022-08-08 21:57:58 +00:00
|
|
|
# Designed to ensure the appversion in Chart.yaml is in sync with the primary Chart tag if found
|
2022-07-28 20:39:13 +00:00
|
|
|
# Also makes sure that home link is pointing to the correct url
|
2021-09-08 10:11:42 +00:00
|
|
|
sync_tag() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2021-09-08 10:20:20 +00:00
|
|
|
echo "Attempting to sync primary tag with appversion for: ${chartname}"
|
2021-09-10 14:57:08 +00:00
|
|
|
local tag="$(cat ${chart}/values.yaml | grep '^ tag: ' | awk -F" " '{ print $2 }' | head -1)"
|
2021-09-11 19:44:25 +00:00
|
|
|
tag="${tag%%@*}"
|
2021-09-08 10:11:42 +00:00
|
|
|
tag="${tag:-auto}"
|
2021-10-03 21:11:23 +00:00
|
|
|
tag=$(echo $tag | sed "s/release-//g")
|
|
|
|
tag=$(echo $tag | sed "s/release_//g")
|
|
|
|
tag=$(echo $tag | sed "s/version-//g")
|
|
|
|
tag=$(echo $tag | sed "s/version_//g")
|
2021-10-13 20:46:42 +00:00
|
|
|
tag="${tag#*V.}"
|
|
|
|
tag="${tag#*v-}"
|
2021-09-08 10:11:42 +00:00
|
|
|
tag="${tag#*v}"
|
2021-10-01 14:35:09 +00:00
|
|
|
tag="${tag%-*}"
|
2021-09-08 10:20:20 +00:00
|
|
|
tag="${tag:0:10}"
|
2021-10-03 21:11:23 +00:00
|
|
|
tag="${tag%-}"
|
|
|
|
tag="${tag%_}"
|
|
|
|
tag="${tag%.}"
|
2022-07-29 14:13:18 +00:00
|
|
|
echo "Updating tag of ${chartname} to ${tag}..."
|
2021-09-13 16:49:14 +00:00
|
|
|
sed -i -e "s|appVersion: .*|appVersion: \"${tag}\"|" "${chart}/Chart.yaml"
|
2022-07-29 14:13:18 +00:00
|
|
|
echo "Updating icon of ${chartname}..."
|
2022-08-01 20:54:37 +00:00
|
|
|
sed -i -e "s|icon: .*|icon: https:\/\/truecharts.org\/img\/hotlink-ok\/chart-icons\/${chartname}.png|" "${chart}/Chart.yaml"
|
2022-07-29 14:13:18 +00:00
|
|
|
echo "Updating home of ${chartname}..."
|
2022-07-29 00:17:37 +00:00
|
|
|
sed -i -e "s|home: .*|home: https:\/\/truecharts.org\/docs\/charts\/${train}\/${chartname}|" "${chart}/Chart.yaml"
|
2022-07-31 10:54:01 +00:00
|
|
|
echo "Attempting to update sources of ${chartname}..."
|
2022-07-31 20:27:36 +00:00
|
|
|
echo "Using go-yq verion: <$(go-yq -V)>"
|
2022-07-31 19:15:36 +00:00
|
|
|
# Get all sources (except truecharts)
|
|
|
|
curr_sources=$(go-yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml")
|
|
|
|
# Empty sources list in-place
|
|
|
|
go-yq -i 'del(.sources.[])' "${chart}/Chart.yaml"
|
|
|
|
# Add truechart source
|
|
|
|
tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" go-yq -i '.sources += env(tcsource)' "${chart}/Chart.yaml"
|
|
|
|
# Add the rest of the sources
|
|
|
|
while IFS= read -r line; do
|
|
|
|
src="$line" go-yq -i '.sources += env(src)' "${chart}/Chart.yaml"
|
|
|
|
done <<< "$curr_sources"
|
|
|
|
echo "Sources of ${chartname} updated!"
|
2021-09-08 10:11:42 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f sync_tag
|
2021-09-08 10:11:42 +00:00
|
|
|
|
|
|
|
pre_commit() {
|
|
|
|
if [[ -z "$standalone" ]]; then
|
|
|
|
echo "Running pre-commit test-and-cleanup..."
|
2021-09-08 10:20:20 +00:00
|
|
|
pre-commit run --all ||:
|
2021-09-08 10:11:42 +00:00
|
|
|
# Fix sh files to always be executable
|
|
|
|
find . -name '*.sh' | xargs chmod +x
|
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f pre_commit
|
2021-09-08 10:11:42 +00:00
|
|
|
|
2021-09-07 22:23:29 +00:00
|
|
|
create_changelog() {
|
2021-09-08 10:11:42 +00:00
|
|
|
local chart="$1"
|
2021-09-07 22:23:29 +00:00
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2021-09-08 10:11:42 +00:00
|
|
|
local prevversion="$(git tag -l "${chartname}-*" --sort=-v:refname | head -n 1)"
|
2021-09-07 22:23:29 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2021-09-08 10:11:42 +00:00
|
|
|
echo "Generating changelogs for: ${chartname}"
|
|
|
|
# SCALE "Changelog" containing only last change
|
2021-10-03 21:15:29 +00:00
|
|
|
git-chglog --next-tag ${chartname}-${chartversion} --tag-filter-pattern ${chartname} --path ${chart} -o ${chart}/app-changelog.md ${chartname}-${chartversion}
|
2021-09-08 10:11:42 +00:00
|
|
|
# Append SCALE changelog to actual changelog
|
2021-09-07 22:30:58 +00:00
|
|
|
|
2021-09-08 10:11:42 +00:00
|
|
|
if [[ -f "${chart}/CHANGELOG.md" ]]; then
|
2021-09-08 10:52:13 +00:00
|
|
|
true
|
2021-09-07 22:30:58 +00:00
|
|
|
else
|
2021-09-08 10:11:42 +00:00
|
|
|
touch ${chart}/CHANGELOG.md
|
2021-09-07 22:30:58 +00:00
|
|
|
fi
|
2021-09-08 10:52:13 +00:00
|
|
|
sed -i '1d' ${chart}/CHANGELOG.md
|
2021-10-03 21:15:29 +00:00
|
|
|
cat ${chart}/app-changelog.md | cat - ${chart}/CHANGELOG.md > temp && mv temp ${chart}/CHANGELOG.md
|
2021-09-08 10:52:13 +00:00
|
|
|
sed -i '1s/^/# Changelog<br>\n\n/' ${chart}/CHANGELOG.md
|
2021-10-19 13:29:07 +00:00
|
|
|
rm ${chart}/app-changelog.md || echo "changelog not found..."
|
2021-09-08 10:11:42 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f create_changelog
|
2021-09-07 22:23:29 +00:00
|
|
|
|
2021-09-07 18:37:52 +00:00
|
|
|
copy_general_docs() {
|
2021-09-08 10:11:42 +00:00
|
|
|
yes | cp -rf index.yaml docs/index.yaml 2>/dev/null || :
|
2021-09-07 18:37:52 +00:00
|
|
|
yes | cp -rf .github/README.md docs/index.md 2>/dev/null || :
|
|
|
|
sed -i '1s/^/---\nhide:\n - navigation\n - toc\n---\n/' docs/index.md
|
|
|
|
sed -i 's~<!-- INSERT-DISCORD-WIDGET -->~<iframe src="https://discord.com/widget?id=830763548678291466\&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>~g' docs/index.md
|
|
|
|
yes | cp -rf .github/CODE_OF_CONDUCT docs/about/code_of_conduct.md 2>/dev/null || :
|
|
|
|
yes | cp -rf .github/CONTRIBUTING docs/development/contributing.md 2>/dev/null || :
|
|
|
|
yes | cp -rf .github/SUPPORT.md docs/manual/SUPPORT.md 2>/dev/null || :
|
|
|
|
yes | cp -rf LICENSE docs/about/legal/LICENSE.md 2>/dev/null || :
|
|
|
|
sed -i '1s/^/# License<br>\n\n/' docs/about/legal/LICENSE.md
|
|
|
|
yes | cp -rf NOTICE docs/about/legal/NOTICE.md 2>/dev/null || :
|
|
|
|
sed -i '1s/^/# NOTICE<br>\n\n/' docs/about/legal/NOTICE.md
|
2021-09-08 10:11:42 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f copy_general_docs
|
2021-09-07 18:37:52 +00:00
|
|
|
|
|
|
|
generate_docs() {
|
2021-09-07 15:25:30 +00:00
|
|
|
local chart="$1"
|
2021-09-07 18:37:52 +00:00
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2021-09-08 10:11:42 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2021-09-07 18:37:52 +00:00
|
|
|
echo "Generating Docs"
|
|
|
|
if [ "${chartname}" == "common" ]; then
|
|
|
|
helm-docs \
|
|
|
|
--ignore-file=".helmdocsignore" \
|
|
|
|
--output-file="README.md" \
|
2021-09-07 22:38:37 +00:00
|
|
|
--template-files="/__w/apps/apps/templates/docs/common-README.md.gotmpl" \
|
2021-09-08 17:58:11 +00:00
|
|
|
--chart-search-root="${chart}"
|
2021-09-07 18:37:52 +00:00
|
|
|
helm-docs \
|
|
|
|
--ignore-file=".helmdocsignore" \
|
|
|
|
--output-file="helm-values.md" \
|
2021-09-07 22:38:37 +00:00
|
|
|
--template-files="/__w/apps/apps/templates/docs/common-helm-values.md.gotmpl" \
|
2021-09-08 17:58:11 +00:00
|
|
|
--chart-search-root="${chart}"
|
2021-09-08 10:11:42 +00:00
|
|
|
else
|
2021-09-07 18:37:52 +00:00
|
|
|
helm-docs \
|
|
|
|
--ignore-file=".helmdocsignore" \
|
|
|
|
--output-file="README.md" \
|
2021-09-07 22:38:37 +00:00
|
|
|
--template-files="/__w/apps/apps/templates/docs/README.md.gotmpl" \
|
2021-09-07 18:37:52 +00:00
|
|
|
--chart-search-root="${chart}"
|
|
|
|
helm-docs \
|
|
|
|
--ignore-file=".helmdocsignore" \
|
|
|
|
--output-file="CONFIG.md" \
|
2021-09-07 22:38:37 +00:00
|
|
|
--template-files="/__w/apps/apps/templates/docs/CONFIG.md.gotmpl" \
|
2021-09-07 18:37:52 +00:00
|
|
|
--chart-search-root="${chart}"
|
|
|
|
helm-docs \
|
|
|
|
--ignore-file=".helmdocsignore" \
|
|
|
|
--output-file="helm-values.md" \
|
2021-09-07 22:38:37 +00:00
|
|
|
--template-files="/__w/apps/apps/templates/docs/helm-values.md.gotmpl" \
|
2021-09-07 18:37:52 +00:00
|
|
|
--chart-search-root="${chart}"
|
|
|
|
fi
|
2022-08-22 16:46:38 +00:00
|
|
|
sed -i "s/TRAINPLACEHOLDER/${train}/" "${chart}/README.md"
|
2021-09-08 10:11:42 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f generate_docs
|
2021-09-07 18:37:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
copy_docs() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2021-09-08 10:11:42 +00:00
|
|
|
echo "Copying docs for: ${chart}"
|
2021-09-07 18:37:52 +00:00
|
|
|
if [ "${chartname}" == "common" ]; then
|
2022-08-08 21:57:58 +00:00
|
|
|
mkdir -p docs/charts/common || :
|
|
|
|
yes | cp -rf charts/library/common/README.md docs/charts/common/index.md 2>/dev/null || :
|
|
|
|
yes | cp -rf charts/library/common/helm-values.md docs/charts/common/helm-values.md 2>/dev/null || :
|
2021-09-08 10:11:42 +00:00
|
|
|
else
|
2022-08-08 21:57:58 +00:00
|
|
|
mkdir -p docs/charts/${train}/${chartname} || echo "chart path already exists, continuing..."
|
|
|
|
yes | cp -rf ${chart}/README.md docs/charts/${train}/${chartname}/index.md 2>/dev/null || :
|
|
|
|
yes | cp -rf ${chart}/CHANGELOG.md docs/charts/${train}/${chartname}/CHANGELOG.md 2>/dev/null || :
|
|
|
|
yes | cp -rf ${chart}/security.md docs/charts/${train}/${chartname}/security.md 2>/dev/null || :
|
|
|
|
yes | cp -rf ${chart}/CONFIG.md docs/charts/${train}/${chartname}/CONFIG.md 2>/dev/null || :
|
|
|
|
yes | cp -rf ${chart}/helm-values.md docs/charts/${train}/${chartname}/helm-values.md 2>/dev/null || :
|
|
|
|
rm docs/charts/${train}/${chartname}/LICENSE.md 2>/dev/null || :
|
|
|
|
yes | cp -rf ${chart}/LICENSE docs/charts/${train}/${chartname}/LICENSE.md 2>/dev/null || :
|
|
|
|
sed -i '1s/^/# License<br>\n\n/' docs/charts/${train}/${chartname}/LICENSE.md 2>/dev/null || :
|
2021-09-08 10:11:42 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f copy_docs
|
2021-09-07 18:37:52 +00:00
|
|
|
|
|
|
|
prep_helm() {
|
2021-09-08 10:11:42 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2022-03-29 21:22:16 +00:00
|
|
|
helm repo add truecharts https://charts.truecharts.org
|
2022-03-26 12:04:32 +00:00
|
|
|
helm repo add truecharts-library https://library-charts.truecharts.org
|
2021-09-07 18:37:52 +00:00
|
|
|
helm repo add bitnami https://charts.bitnami.com/bitnami
|
2021-11-10 16:35:49 +00:00
|
|
|
helm repo add metallb https://metallb.github.io/metallb
|
2021-11-21 20:52:23 +00:00
|
|
|
helm repo add grafana https://grafana.github.io/helm-charts
|
2021-11-21 21:37:45 +00:00
|
|
|
helm repo add prometheus https://prometheus-community.github.io/helm-charts
|
2021-09-07 18:37:52 +00:00
|
|
|
helm repo update
|
2021-09-08 10:11:42 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f prep_helm
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
clean_apps() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2022-08-08 21:57:58 +00:00
|
|
|
echo "Cleaning SCALE catalog for Chart: ${chartname}"
|
2021-09-07 18:37:52 +00:00
|
|
|
rm -Rf catalog/${train}/${chartname}/${chartversion} 2>/dev/null || :
|
|
|
|
rm -Rf catalog/${train}/${chartname}/item.yaml 2>/dev/null || :
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f clean_apps
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
patch_apps() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2021-09-07 18:37:52 +00:00
|
|
|
local target="catalog/${train}/${chartname}/${chartversion}"
|
2022-08-08 21:57:58 +00:00
|
|
|
echo "Applying SCALE patches for Chart: ${chartname}"
|
2021-10-19 13:29:07 +00:00
|
|
|
sed -i '100,$ d' ${target}/CHANGELOG.md || :
|
2021-10-03 21:15:29 +00:00
|
|
|
mv ${target}/app-changelog.md ${target}/CHANGELOG.md 2>/dev/null || :
|
2021-10-19 09:21:33 +00:00
|
|
|
# Temporary fix to prevent the UI from bugging out on 21.08
|
2021-10-19 10:46:12 +00:00
|
|
|
mv ${target}/values.yaml ${target}/ix_values.yaml 2>/dev/null || :
|
2021-10-19 09:21:33 +00:00
|
|
|
touch ${target}/values.yaml
|
|
|
|
# mv ${target}/SCALE/ix_values.yaml ${target}/ 2>/dev/null || :
|
2021-09-07 18:37:52 +00:00
|
|
|
cp -rf ${target}/SCALE/templates/* ${target}/templates 2>/dev/null || :
|
2021-09-07 22:23:29 +00:00
|
|
|
rm -rf ${target}/SCALE 2>/dev/null || :
|
2021-09-07 18:37:52 +00:00
|
|
|
touch ${target}/values.yaml
|
2021-10-19 15:59:59 +00:00
|
|
|
# Generate item.yaml
|
2021-10-19 16:15:58 +00:00
|
|
|
cat ${target}/Chart.yaml | grep "icon" >> catalog/${train}/${chartname}/item.yaml
|
2021-10-20 08:28:44 +00:00
|
|
|
sed -i "s|^icon:|icon_url:|g" catalog/${train}/${chartname}/item.yaml
|
2021-10-19 16:31:08 +00:00
|
|
|
echo "categories:" >> catalog/${train}/${chartname}/item.yaml
|
2021-10-19 16:15:58 +00:00
|
|
|
cat ${target}/Chart.yaml | yq '.annotations."truecharts.org/catagories"' -r >> catalog/${train}/${chartname}/item.yaml
|
2021-10-19 17:00:56 +00:00
|
|
|
# Generate SCALE App description file
|
|
|
|
cat ${target}/Chart.yaml | yq .description -r >> ${target}/app-readme.md
|
|
|
|
echo "" >> ${target}/app-readme.md
|
2022-08-08 21:57:58 +00:00
|
|
|
echo "This Chart is supplied by TrueCharts, for more information please visit https://truecharts.org" >> ${target}/app-readme.md
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f patch_apps
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
copy_apps() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2022-08-08 21:57:58 +00:00
|
|
|
echo "Copying Chart to Catalog: ${2}"
|
2021-09-07 15:25:30 +00:00
|
|
|
mkdir -p catalog/${train}/${chartname}/${chartversion}
|
|
|
|
cp -Rf ${chart}/* catalog/${train}/${chartname}/${chartversion}/
|
2021-09-07 18:37:52 +00:00
|
|
|
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f copy_apps
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
validate_catalog() {
|
2021-09-07 18:37:52 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2021-09-07 15:25:30 +00:00
|
|
|
echo "Starting Catalog Validation"
|
2021-09-07 18:37:52 +00:00
|
|
|
/usr/local/bin/catalog_validate validate --path "${PWD}/catalog"
|
|
|
|
fi
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f validate_catalog
|
2021-09-07 15:25:30 +00:00
|
|
|
|
2022-03-29 19:07:40 +00:00
|
|
|
upload_catalog() {
|
2022-03-30 12:48:04 +00:00
|
|
|
echo "Uploading Catalog..."
|
2022-03-29 19:07:40 +00:00
|
|
|
cd catalog
|
|
|
|
git config user.name "TrueCharts-Bot"
|
|
|
|
git config user.email "bot@truecharts.org"
|
|
|
|
git add --all
|
2022-08-08 21:57:58 +00:00
|
|
|
git commit -sm "Commit new Chart releases for TrueCharts" || exit 0
|
2022-03-29 19:07:40 +00:00
|
|
|
git push
|
|
|
|
cd -
|
|
|
|
rm -rf catalog
|
|
|
|
}
|
|
|
|
export -f upload_catalog
|
|
|
|
|
2022-03-29 19:13:53 +00:00
|
|
|
upload_dhcatalog() {
|
2022-03-30 12:48:04 +00:00
|
|
|
echo "Uploading DH-Catalog..."
|
2022-03-29 19:07:40 +00:00
|
|
|
cd dh_catalog
|
|
|
|
git config user.name "TrueCharts-Bot"
|
|
|
|
git config user.email "bot@truecharts.org"
|
|
|
|
git add --all
|
2022-08-08 21:57:58 +00:00
|
|
|
git commit -sm "Commit new Chart releases for TrueCharts" || exit 0
|
2022-03-29 19:07:40 +00:00
|
|
|
git push
|
|
|
|
cd -
|
|
|
|
rm -rf dh_catalog
|
|
|
|
}
|
|
|
|
export -f upload_dhcatalog
|
|
|
|
|
|
|
|
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
parse_command_line() {
|
|
|
|
while :; do
|
|
|
|
case "${1:-}" in
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
--config)
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
|
|
config="$2"
|
|
|
|
shift
|
|
|
|
else
|
2021-09-07 15:52:00 +00:00
|
|
|
config=".github/cr.yaml"
|
|
|
|
shift
|
2021-09-07 15:25:30 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-v|--version)
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
|
|
version="$2"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
echo "ERROR: '-v|--version' cannot be empty." >&2
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-d|--charts-dir)
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
|
|
charts_dir="$2"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
echo "ERROR: '-d|--charts-dir' cannot be empty." >&2
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-u|--charts-repo-url)
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
|
|
charts_repo_url="$2"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
echo "ERROR: '-u|--charts-repo-url' cannot be empty." >&2
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-o|--owner)
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
|
|
owner="$2"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
echo "ERROR: '--owner' cannot be empty." >&2
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-r|--repo)
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
|
|
repo="$2"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
echo "ERROR: '--repo' cannot be empty." >&2
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-p|--production)
|
|
|
|
production="true"
|
|
|
|
;;
|
2021-09-07 18:37:52 +00:00
|
|
|
-s|--standalone)
|
|
|
|
standalone="true"
|
|
|
|
;;
|
2021-09-07 15:25:30 +00:00
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ -z "$owner" ]]; then
|
2021-09-07 15:52:00 +00:00
|
|
|
echo "No owner configured, defaulting to truecharts" >&2
|
|
|
|
owner="truecharts"
|
2021-09-07 15:25:30 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$repo" ]]; then
|
2022-08-08 21:57:58 +00:00
|
|
|
echo "No repo configured, defaulting to charts" >&2
|
|
|
|
repo="charts"
|
2021-09-07 15:25:30 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$charts_repo_url" ]]; then
|
|
|
|
charts_repo_url="https://$owner.github.io/$repo"
|
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f parse_command_line
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
lookup_latest_tag() {
|
|
|
|
git fetch --tags > /dev/null 2>&1
|
|
|
|
|
|
|
|
if ! git describe --tags --abbrev=0 2> /dev/null; then
|
|
|
|
git rev-list --max-parents=0 --first-parent HEAD
|
|
|
|
fi
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f lookup_latest_tag
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
filter_charts() {
|
|
|
|
while read -r chart; do
|
|
|
|
[[ ! -d "$chart" ]] && continue
|
2021-09-08 14:45:17 +00:00
|
|
|
if [[ $(git diff $latest_tag $chart/Chart.yaml | grep "+version") ]]; then
|
2021-09-07 15:25:30 +00:00
|
|
|
echo "$chart"
|
|
|
|
else
|
2021-09-08 14:45:17 +00:00
|
|
|
echo "Version not bumped. Skipping." 1>&2
|
2021-09-07 15:25:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f filter_charts
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
lookup_changed_charts() {
|
|
|
|
local commit="$1"
|
|
|
|
|
|
|
|
local changed_files
|
2021-09-07 18:37:52 +00:00
|
|
|
changed_files=$(git diff --find-renames --name-only "$commit" -- "$charts_dir" | grep "Chart.yaml")
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
local depth=$(( $(tr "/" "\n" <<< "$charts_dir" | sed '/^\(\.\)*$/d' | wc -l) + 1 ))
|
|
|
|
local fields="1-${depth}"
|
|
|
|
|
|
|
|
cut -d '/' -f "$fields" <<< "$changed_files" | uniq | filter_charts
|
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f lookup_changed_charts
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
package_chart() {
|
|
|
|
local chart="$1"
|
|
|
|
local args=("$chart" --package-path .cr-release-packages)
|
|
|
|
if [[ -n "$config" ]]; then
|
|
|
|
args+=(--config "$config")
|
|
|
|
fi
|
|
|
|
|
2021-09-07 18:37:52 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2021-09-07 15:25:30 +00:00
|
|
|
echo "Packaging chart '$chart'..."
|
|
|
|
cr package "${args[@]}"
|
2021-09-08 10:11:42 +00:00
|
|
|
fi
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f package_chart
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
release_charts() {
|
|
|
|
local args=(-o "$owner" -r "$repo" -c "$(git rev-parse HEAD)")
|
|
|
|
if [[ -n "$config" ]]; then
|
|
|
|
args+=(--config "$config")
|
|
|
|
fi
|
|
|
|
|
2021-09-07 18:37:52 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2021-09-07 15:25:30 +00:00
|
|
|
echo 'Releasing charts...'
|
|
|
|
cr upload "${args[@]}"
|
2021-09-07 18:37:52 +00:00
|
|
|
fi
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f release_charts
|
2021-09-07 15:25:30 +00:00
|
|
|
|
|
|
|
update_index() {
|
2022-03-29 22:29:12 +00:00
|
|
|
local args=(-o "$owner" -r "$repo" -c "$charts_repo_url")
|
2021-09-07 15:25:30 +00:00
|
|
|
if [[ -n "$config" ]]; then
|
|
|
|
args+=(--config "$config")
|
|
|
|
fi
|
|
|
|
|
2021-09-07 18:37:52 +00:00
|
|
|
if [[ -z "$standalone" ]]; then
|
2021-09-07 15:25:30 +00:00
|
|
|
echo 'Updating charts repo index...'
|
|
|
|
cr index "${args[@]}"
|
2021-09-08 10:11:42 +00:00
|
|
|
fi
|
2021-09-07 15:25:30 +00:00
|
|
|
}
|
2021-12-04 14:20:01 +00:00
|
|
|
export -f update_index
|
2021-09-07 15:25:30 +00:00
|
|
|
|
2022-03-29 22:26:25 +00:00
|
|
|
upload_index() {
|
|
|
|
cd .cr-index
|
|
|
|
git config user.name "TrueCharts-Bot"
|
|
|
|
git config user.email "bot@truecharts.org"
|
|
|
|
git add --all
|
|
|
|
git commit -sm "Commit released Helm Chart and docs for TrueCharts" || exit 0
|
|
|
|
git push
|
|
|
|
cd -
|
2022-03-29 22:33:56 +00:00
|
|
|
rm -rf .cr-index
|
2022-03-29 22:26:25 +00:00
|
|
|
}
|
|
|
|
export -f upload_index
|
|
|
|
|
2021-09-07 15:25:30 +00:00
|
|
|
main "$@"
|