Mantain mirror (#795)
This commit is contained in:
parent
45aee54e98
commit
b20b9daf42
|
@ -33,7 +33,16 @@ jobs:
|
||||||
gh pr comment "${{ github.event.pull_request.number }}" --body '请运行 `./hack/fmt.sh domain.txt` 对内容进行排序'
|
gh pr comment "${{ github.event.pull_request.number }}" --body '请运行 `./hack/fmt.sh domain.txt` 对内容进行排序'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
- name: Verify mirror.txt
|
|
||||||
|
- name: Verify mirror.txt image
|
||||||
|
run: |
|
||||||
|
./hack/verify-fmt-image.sh mirror.txt || {
|
||||||
|
echo "Please run './hack/fmt-image.sh mirror.txt'"
|
||||||
|
gh pr comment "${{ github.event.pull_request.number }}" --body '请运行 `./hack/fmt-image.sh mirror.txt` 对内容进行格式化'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Verify mirror.txt sort
|
||||||
run: |
|
run: |
|
||||||
./hack/verify-fmt.sh mirror.txt || {
|
./hack/verify-fmt.sh mirror.txt || {
|
||||||
echo "Please run './hack/fmt.sh mirror.txt'"
|
echo "Please run './hack/fmt.sh mirror.txt'"
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function filter_docker_library() {
|
||||||
|
while read -r line; do
|
||||||
|
if [[ $line =~ ^docker\.io/[^/]*$ ]]; then
|
||||||
|
echo "docker.io/library/${line#docker.io/}"
|
||||||
|
else
|
||||||
|
echo "${line}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function filter_k8s_old() {
|
||||||
|
while read -r line; do
|
||||||
|
if [[ $line =~ ^k8s\.gcr\.io/.*$ ]]; then
|
||||||
|
echo "registry.k8s.io/${line#k8s.gcr.io/}"
|
||||||
|
else
|
||||||
|
echo "${line}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
cat $1 |
|
||||||
|
filter_docker_library |
|
||||||
|
filter_k8s_old >$1.tmp && mv $1.tmp $1
|
20
hack/fmt.sh
20
hack/fmt.sh
|
@ -2,26 +2,6 @@
|
||||||
|
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
|
||||||
function filter_docker_library() {
|
|
||||||
while read -r line; do
|
|
||||||
if [[ $line =~ ^docker\.io/[^/]*$ ]]; then
|
|
||||||
echo "docker.io/library/${line#docker.io/}"
|
|
||||||
else
|
|
||||||
echo "${line}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function filter_k8s_old() {
|
|
||||||
while read -r line; do
|
|
||||||
if [[ $line =~ ^k8s\.gcr\.io/.*$ ]]; then
|
|
||||||
echo "registry.k8s.io/${line#k8s.gcr.io/}"
|
|
||||||
else
|
|
||||||
echo "${line}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
cat $1 |
|
cat $1 |
|
||||||
filter_docker_library |
|
filter_docker_library |
|
||||||
filter_k8s_old |
|
filter_k8s_old |
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
base_list="${1}"
|
||||||
|
used_list="${2}"
|
||||||
|
used_top="${3:-100}"
|
||||||
|
|
||||||
|
function used_top() {
|
||||||
|
cat "${used_list}" | head -n "${used_top}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function intersection_used() {
|
||||||
|
sort "${base_list}" "${used_list}" | uniq -d
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixed_docker() {
|
||||||
|
grep "^docker\.io/library/" "${base_list}"
|
||||||
|
grep "^docker\.io/library/" "${used_list}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixed_k8s() {
|
||||||
|
grep "^registry\.k8s\.io/" "${base_list}"
|
||||||
|
grep "^registry\.k8s\.io/" "${used_list}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixed_istio() {
|
||||||
|
grep "^docker\.io/istio/" "${base_list}"
|
||||||
|
grep "^docker\.io/istio/" "${used_list}"
|
||||||
|
}
|
||||||
|
|
||||||
|
cat <(used_top) \
|
||||||
|
<(intersection_used) \
|
||||||
|
<(fixed_docker) \
|
||||||
|
<(fixed_k8s) | sort | uniq -u
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
|
cp $1 $1.bak
|
||||||
|
|
||||||
|
$(dirname "${BASH_SOURCE}")/fmt-image.sh $1.bak
|
||||||
|
|
||||||
|
diff -c $1 $1.bak && rm $1.bak
|
Loading…
Reference in New Issue