-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade altinity-clickhouse-operator
- Loading branch information
Showing
17 changed files
with
1,233 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
665 changes: 438 additions & 227 deletions
665
...erator/crds/CustomResourceDefinition-clickhouseinstallations.clickhouse.altinity.com.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
665 changes: 438 additions & 227 deletions
665
...rds/CustomResourceDefinition-clickhouseinstallationtemplates.clickhouse.altinity.com.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,58 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Script downloads manifest from altinity repo, splits it to separate files | ||
# and puts to the corresponding folders | ||
# NOTE: yq ( https://mikefarah.gitbook.io/yq/ ) > v4.14.x is required | ||
# | ||
# Usage: ./sync.sh | ||
# | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
CHART_PATH=../ | ||
BUILD_PATH="${CHART_PATH}/../../build" | ||
|
||
APP_VERSION=$(cat "${CHART_PATH}/Chart.yaml" | grep appVersion | cut -d : -f 2 | xargs) | ||
|
||
if [ "${APP_VERSION}" = "latest" ]; then | ||
APP_VERSION="master" | ||
fi | ||
|
||
REPO_URL="https://raw.githubusercontent.com/Altinity/clickhouse-operator/${APP_VERSION}/deploy/operator" | ||
|
||
function extract_resources() { | ||
local url=$1 | ||
local dest=$2 | ||
readonly repo_url="https://raw.githubusercontent.com/Altinity/clickhouse-operator" | ||
readonly crds_dir="../crds" | ||
readonly templates_dir="../templates/generated" | ||
readonly manifest_path="deploy/operator/clickhouse-operator-install-bundle.yaml" | ||
readonly chart_def="../Chart.yaml" | ||
|
||
local resources | ||
resources=$(curl -s "${url}" | yq e -j -N | jq . -c) | ||
function main() { | ||
readonly manifest_url="${repo_url}/$(detect_version)/${manifest_path}" | ||
local tmpdir | ||
tmpdir=$(mktemp -d) | ||
|
||
OLDIFS=$IFS | ||
IFS=$'\n' | ||
for r in ${resources}; do | ||
local kind | ||
kind=$(echo "${r}" | jq .kind -r) | ||
# shellcheck disable=SC2016 | ||
(cd "${tmpdir}" && curl -s "${manifest_url}" 2>&1 | yq e --no-doc -s '$index') | ||
|
||
local name | ||
name=$(echo "${r}" | jq .metadata.name -r) | ||
|
||
echo "${r}" | yq e -P - >"${dest}/${kind}-${name}.yaml" | ||
for f in "${tmpdir}"/*.yml; do | ||
process "${f}" | ||
done | ||
IFS=$OLDIFS | ||
} | ||
|
||
rm -rf "${CHART_PATH}/crds" "${CHART_PATH}/templates/generated" | ||
mkdir "${CHART_PATH}/crds" "${CHART_PATH}/templates/generated" | ||
function process() { | ||
local file="${1}" | ||
|
||
extract_resources "${REPO_URL}/clickhouse-operator-install-crd.yaml" "${CHART_PATH}/crds" | ||
extract_resources "${REPO_URL}/clickhouse-operator-install-deployment.yaml" "${CHART_PATH}/templates/generated" | ||
extract_resources "${REPO_URL}/clickhouse-operator-install-service.yaml" "${CHART_PATH}/templates/generated" | ||
local kind | ||
kind=$(yq e '.kind' "${file}") | ||
|
||
exit 1 | ||
local name | ||
name=$(yq e '.metadata.name' "${file}") | ||
|
||
wget -O ${BUILD_PATH}/repo.zip ${REPO_URL} | ||
unzip -n "${BUILD_PATH}/repo.zip" -d ${BUILD_PATH} | ||
rm "${BUILD_PATH}/repo.zip" | ||
local processed_file="${kind}-${name}.yaml" | ||
|
||
REPO_PATH="${BUILD_PATH}/external-secrets-operator-${APP_VERSION}" | ||
if [[ "${kind}" == "CustomResourceDefinition" ]]; then | ||
processed_file="${crds_dir}/${processed_file}" | ||
else | ||
processed_file="${templates_dir}/${processed_file}" | ||
fi | ||
|
||
cp -R "${REPO_PATH}/config/samples/" "${CHART_PATH}/examples/" | ||
mv "${file}" "${processed_file}" | ||
} | ||
|
||
rm -rf xx* && csplit -s -k ${REPO_PATH}/k8s/k8s.yaml '/^---/' '{99}' || true | ||
function detect_version() { | ||
yq e '.appVersion' ${chart_def} | ||
} | ||
|
||
for f in xx*; do | ||
name="$(yq r "${f}" 'kind' | tr '[:upper:]' '[:lower:]')-$(yq r "${f}" 'metadata.name' | tr '[:upper:]' '[:lower:]')" | ||
if [[ "${name}" == "namespace"* ]]; then | ||
rm "${f}" | ||
continue | ||
fi | ||
mv "${f}" "${CHART_PATH}/templates/${name}.yaml" | ||
done | ||
main |
Oops, something went wrong.