Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix api files deleted from origin repo #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.22

KOORD_VERSION ?= v1.1.0
KOORD_VERSION ?= v1.2.0

# Set license header files.
LICENSE_HEADER_GO ?= hack/boilerplate/boilerplate.go.txt
Expand Down
25 changes: 24 additions & 1 deletion hack/clone-api-files.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

# Define the relative path of API src and dst
API_PATHS_MAP=(
"apis/config:config"
Expand All @@ -23,8 +25,10 @@ fi

TEMP_DIR=$(mktemp -d)
cleanup() {
rv=$?
echo ">> Removing ${TEMP_DIR}"
rm -rf ${TEMP_DIR}
exit $rv
}
trap "cleanup" EXIT SIGINT

Expand All @@ -41,7 +45,6 @@ function copy_api_files() {
dst_path=$2
echo ">> copy api files from" ${src_path} "to" ${dst_path} "excludes zz_generated*.go and *_test.go"
api_files_src_path="$( find ${src_path} -type f \( -name "*.go" -and ! -name "zz_generated*.go" -and ! -name "*_test.go" \) )"
echo ${api_files_src_path}
for api_file_src_path in ${api_files_src_path};
do
file_relative_path=${api_file_src_path#${src_path}}
Expand All @@ -54,6 +57,25 @@ function copy_api_files() {
done
}

# rm api files from ${latest_path} if file not exist in ${current_path} excludes zz_generated*.go and *_test.go
# $1: latest api files full dir path: koordinator-sh/koordinator/api/slo
# $2: current api files full dir path, e.g. koordinator-sh/api/slo
function remove_outdated_api_files() {
latest_path=$1
current_path=$2
echo ">> rm api files from" ${current_path} "in not exist in" ${latest_path} "excludes zz_generated*.go and *_test.go"
api_files_current_path="$( find ${current_path} -type f \( -name "*.go" -and ! -name "zz_generated*.go" -and ! -name "*_test.go" \) )"
for api_file_current_path in ${api_files_current_path};
do
file_relative_path=${api_file_current_path#${current_path}}
latest_file_path="${latest_path}/${file_relative_path}"
if [ ! -f ${latest_file_path} ]; then
echo ">> checking api file" ${api_file_current_path} "not exist in" ${latest_path} ", will be removed"
git rm -f --ignore-unmatch "${api_file_current_path}"
fi
done
}

API_REPO_DIR=$( cd $(dirname $0)/..; pwd )

echo ">> copy apis files from" ${KOORDINATOR_REPO_DIR}
Expand All @@ -62,4 +84,5 @@ do
src_relative_path="${api_path_pair%%:*}"
dst_relative_path="${api_path_pair##*:}"
copy_api_files ${KOORDINATOR_REPO_DIR}/${src_relative_path} ${API_REPO_DIR}/${dst_relative_path}
remove_outdated_api_files ${KOORDINATOR_REPO_DIR}/${src_relative_path} ${API_REPO_DIR}/${dst_relative_path}
done
2 changes: 2 additions & 0 deletions hack/replace-import-repo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

function custom_sed(){
perl -i -pe $@
}
Expand Down