Skip to content

Commit

Permalink
Fix shell script incompatibility on mac system (kurator-dev#618)
Browse files Browse the repository at this point in the history
* Fix mac system compatibility

Signed-off-by: wulianglongrd <[email protected]>

* add sleep back

Signed-off-by: wulianglongrd <[email protected]>

* fix

Signed-off-by: wulianglongrd <[email protected]>

---------

Signed-off-by: wulianglongrd <[email protected]>
  • Loading branch information
wulianglongrd authored Apr 9, 2024
1 parent 1248e6b commit 25b161f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
4 changes: 2 additions & 2 deletions hack/e2e-test/build-clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions hack/gen-chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions hack/local-dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 15 additions & 13 deletions hack/sync-crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,33 @@ AWS_PROVIDER_VERSION=${AWS_PROVIDER_VERSION:-'v2.0.0'}
# set default ca prevent deleting crd fail
CA_BUNDLE=${CA_BUNDLE:-'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ0ekNDQXN1Z0F3SUJBZ0lVQ3lxYVFvUktQM1ZtVk52Q0hTazM1UDBnQW5Vd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1hERUxNQWtHQTFVRUJoTUNlSGd4Q2pBSUJnTlZCQWdNQVhneENqQUlCZ05WQkFjTUFYZ3hDakFJQmdOVgpCQW9NQVhneENqQUlCZ05WQkFzTUFYZ3hDekFKQmdOVkJBTU1BbU5oTVJBd0RnWUpLb1pJaHZjTkFRa0JGZ0Y0Ck1CNFhEVEl5TVRFeE1qQTNORFV3TUZvWERUSTNNVEV4TVRBM05EVXdNRm93UmpFWE1CVUdBMVVFQ2hNT2MzbHoKZEdWdE9tMWhjM1JsY25NeEt6QXBCZ05WQkFNTUlpb3VhM1Z5WVhSdmNpMXplWE4wWlcwdWMzWmpMbU5zZFhOMApaWEl1Ykc5allXd3dnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDYThhYk1IVklNCkkxNFp4SDUraHc4SlIwSEVucmlxV0RPMTdTd0hoY21VRHc4emd5d1hwNGdjdTA0SDB6cUFYc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C9tWVkKTWc5VkFjMDZlcTA2dmFWY1pxZU5UbnR1TGFVY3R2KzkvL2NSTzFncS9wbEFFZ015R2V3YUxYWHptcGNlWnV1RwpmbTlzRDdXeHltSlpXaGdEaFAvUmpwZm1rcHNFaGNUcm1leHJFbTJEZ01QVDVwdWhuQmQwCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K'}

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}
9 changes: 9 additions & 0 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 25b161f

Please sign in to comment.