diff --git a/hack/e2e-test/build-clusters.sh b/hack/e2e-test/build-clusters.sh index cbea3a39..7f986d3b 100755 --- a/hack/e2e-test/build-clusters.sh +++ b/hack/e2e-test/build-clusters.sh @@ -38,9 +38,9 @@ util::create_cluster "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${KIND_VERSION util::create_cluster "${MEMBER_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${KIND_VERSION}" "${TEMP_PATH}" "${TEMP_PATH}"/member1.yaml util::check_clusters_ready "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" -sleep 5s +sleep 5 util::check_clusters_ready "${MEMBER_CLUSTER_KUBECONFIG}" "${MEMBER_CLUSTER_NAME}" -sleep 10s +sleep 10 # connecting networks between primary, remote clusters echo "connect primary <-> remote" diff --git a/hack/gen-chart.sh b/hack/gen-chart.sh index aec2197b..10841d86 100755 --- a/hack/gen-chart.sh +++ b/hack/gen-chart.sh @@ -8,6 +8,7 @@ REPO_ROOT=$(git rev-parse --show-toplevel) OUT_BASE_PATH=${REPO_ROOT}/out CHART_OUT_PATH=${OUT_BASE_PATH}/charts +HELM_CHART_NAME=${HELM_CHART_NAME:-} rm -rf "${OUT_BASE_PATH}"/charts mkdir -p "${OUT_BASE_PATH}"/charts @@ -18,14 +19,16 @@ HELM_CHART_VERSION=${HELM_CHART_VERSION:-"0.1.0"} IMAGE_HUB=${IMAGE_HUB:-"ghcr.io/kurator-dev"} IMAGE_TAG=${IMAGE_TAG:-"latest"} +source "$REPO_ROOT/hack/util.sh" + for c in "${HELM_CHARTS[@]}" do echo "gen chart $c" cp -r "${MAINIFESTS_CHART_PATH}/${c}" "${CHART_OUT_PATH}/${c}" - sed -i "s|hub: ghcr.io/kurator-dev|hub: ${IMAGE_HUB}|g" $(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep values.yaml) - sed -i "s|tag: latest|tag: ${IMAGE_TAG}|g" $(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep values.yaml) - sed -i "s|version: 0.1.0|version: ${HELM_CHART_VERSION}|g" $(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep Chart.yaml) - sed -i "s|appVersion: 0.1.0|appVersion: ${HELM_CHART_VERSION}|g" $(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep Chart.yaml) + util::sed_in_place "s|hub: ghcr.io/kurator-dev|hub: ${IMAGE_HUB}|g" "$(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep values.yaml)" + util::sed_in_place "s|tag: latest|tag: ${IMAGE_TAG}|g" "$(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep values.yaml)" + util::sed_in_place "s|version: 0.1.0|version: ${HELM_CHART_VERSION}|g" "$(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep Chart.yaml)" + util::sed_in_place "s|appVersion: 0.1.0|appVersion: ${HELM_CHART_VERSION}|g" "$(find ${CHART_OUT_PATH}/${HELM_CHART_NAME} -type f | grep Chart.yaml)" helm package "${CHART_OUT_PATH}/${c}" -d "${CHART_OUT_PATH}" done diff --git a/hack/local-dev-setup.sh b/hack/local-dev-setup.sh index bee5432c..4b15f8e3 100755 --- a/hack/local-dev-setup.sh +++ b/hack/local-dev-setup.sh @@ -41,11 +41,11 @@ util::create_cluster "${MEMBER_CLUSTER_1_NAME}" "${MEMBER_CLUSTER_1_KUBECONFIG}" util::create_cluster "${MEMBER_CLUSTER_2_NAME}" "${MEMBER_CLUSTER_2_KUBECONFIG}" "${KIND_VERSION}" "${TEMP_PATH}" "${TEMP_PATH}"/member2.yaml util::check_clusters_ready "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" -sleep 5s +sleep 5 util::check_clusters_ready "${MEMBER_CLUSTER_1_KUBECONFIG}" "${MEMBER_CLUSTER_1_NAME}" -sleep 5s +sleep 5 util::check_clusters_ready "${MEMBER_CLUSTER_2_KUBECONFIG}" "${MEMBER_CLUSTER_2_NAME}" -sleep 5s +sleep 5 # connecting networks between primary, remote1 and remote2 clusters echo "connect remote1 <-> remote2" diff --git a/hack/sync-crds.sh b/hack/sync-crds.sh index eea385f6..f565de04 100755 --- a/hack/sync-crds.sh +++ b/hack/sync-crds.sh @@ -12,31 +12,33 @@ AWS_PROVIDER_VERSION=${AWS_PROVIDER_VERSION:-'v2.0.0'} # set default ca prevent deleting crd fail CA_BUNDLE=${CA_BUNDLE:-'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ0ekNDQXN1Z0F3SUJBZ0lVQ3lxYVFvUktQM1ZtVk52Q0hTazM1UDBnQW5Vd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1hERUxNQWtHQTFVRUJoTUNlSGd4Q2pBSUJnTlZCQWdNQVhneENqQUlCZ05WQkFjTUFYZ3hDakFJQmdOVgpCQW9NQVhneENqQUlCZ05WQkFzTUFYZ3hDekFKQmdOVkJBTU1BbU5oTVJBd0RnWUpLb1pJaHZjTkFRa0JGZ0Y0Ck1CNFhEVEl5TVRFeE1qQTNORFV3TUZvWERUSTNNVEV4TVRBM05EVXdNRm93UmpFWE1CVUdBMVVFQ2hNT2MzbHoKZEdWdE9tMWhjM1JsY25NeEt6QXBCZ05WQkFNTUlpb3VhM1Z5WVhSdmNpMXplWE4wWlcwdWMzWmpMbU5zZFhOMApaWEl1Ykc5allXd3dnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDYThhYk1IVklNCkkxNFp4SDUraHc4SlIwSEVucmlxV0RPMTdTd0hoY21VRHc4emd5d1hwNGdjdTA0SDB6cUFYcTZvNU9hd1lJbFkKSjVsVGloMnBhaGV2K0N5VDhka0pPSURTcE5uMThaZnl2UTkvYVZDdDhiMkJCMTJQcHVwSU1PWEV0dXJ3TFpmMgpCMVlYdzBPQkNJVXVydE96MW9zSlRjZUw1dlUvdkFyNVUvQzN6YVVITFlXTUlQY2tkR2U0dk1Fb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IENFUlRJRklDQVRFLS0tLS0K'} +source "$REPO_ROOT/hack/util.sh" + # gen crds rm -rf ${HELM_CRD_BASE}/*.x-k8s.io.yaml CRD_OUTPUT_DIR=${HELM_CRD_BASE} CLUSTER_API_PROVIDER_VERSION=${CLUSTER_API_PROVIDER_VERSION} AWS_PROVIDER_VERSION=${AWS_PROVIDER_VERSION} go run cmd/crd-gen-tool/main.go # sed cert -sed -i "s|caBundle: Cg==|caBundle: ${CA_BUNDLE}|g" $(find ${HELM_CRD_BASE} -type f) +util::sed_in_place "s|caBundle: Cg==|caBundle: ${CA_BUNDLE}|g" "$(find ${HELM_CRD_BASE} -type f)" # capi -sed -i "s|capi-serving-cert|kurator-serving-cert|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capi-system|{{ .Release.Namespace }}|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capi-webhook-service|kurator-webhook-service|g" $(find ${HELM_CRD_BASE} -type f) +util::sed_in_place "s|capi-serving-cert|kurator-serving-cert|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capi-system|{{ .Release.Namespace }}|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capi-webhook-service|kurator-webhook-service|g" "$(find ${HELM_CRD_BASE} -type f)" # bootstrap -sed -i "s|capi-kubeadm-bootstrap-serving-cert|kurator-serving-cert|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capi-kubeadm-bootstrap-system|{{ .Release.Namespace }}|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capi-kubeadm-bootstrap-webhook-service|kurator-webhook-service|g" $(find ${HELM_CRD_BASE} -type f) +util::sed_in_place "s|capi-kubeadm-bootstrap-serving-cert|kurator-serving-cert|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capi-kubeadm-bootstrap-system|{{ .Release.Namespace }}|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capi-kubeadm-bootstrap-webhook-service|kurator-webhook-service|g" "$(find ${HELM_CRD_BASE} -type f)" # kubeadm-control-plane -sed -i "s|capi-kubeadm-control-plane-serving-cert|kurator-serving-cert|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capi-kubeadm-control-plane-system|{{ .Release.Namespace }}|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capi-kubeadm-control-plane-webhook-service|kurator-webhook-service|g" $(find ${HELM_CRD_BASE} -type f) +util::sed_in_place "s|capi-kubeadm-control-plane-serving-cert|kurator-serving-cert|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capi-kubeadm-control-plane-system|{{ .Release.Namespace }}|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capi-kubeadm-control-plane-webhook-service|kurator-webhook-service|g" "$(find ${HELM_CRD_BASE} -type f)" # capa -sed -i "s|capa-serving-cert|kurator-serving-cert|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capa-system|{{ .Release.Namespace }}|g" $(find ${HELM_CRD_BASE} -type f) -sed -i "s|capa-webhook-service|kurator-webhook-service|g" $(find ${HELM_CRD_BASE} -type f) +util::sed_in_place "s|capa-serving-cert|kurator-serving-cert|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capa-system|{{ .Release.Namespace }}|g" "$(find ${HELM_CRD_BASE} -type f)" +util::sed_in_place "s|capa-webhook-service|kurator-webhook-service|g" "$(find ${HELM_CRD_BASE} -type f)" mv ${HELM_CRD_BASE}/*-webhook-configuration.yaml ${WEBHOOK_BASE} \ No newline at end of file diff --git a/hack/util.sh b/hack/util.sh index bec861be..78319242 100755 --- a/hack/util.sh +++ b/hack/util.sh @@ -353,4 +353,13 @@ EOF echo 'Waiting for public IP address to be available...' sleep 3 done +} + +# https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux +function util::sed_in_place() { + local regx=${1} + local files=${2} + for f in $files; do + sed -i'.bak' "$regx" "$f" && rm -f "$f.bak" + done } \ No newline at end of file