forked from kubernetes/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-tomstone-to-markdown-files.sh
executable file
·65 lines (51 loc) · 1.97 KB
/
add-tomstone-to-markdown-files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Mark all existing Markdown files with a deprecation notice and redirect link.
# This is also known as a "tombstone".
set -euo pipefail
SCRIPT_ROOT="$(cd "$(dirname "$0")" && pwd)"
declare -a FILES_TO_MARK=()
# Find all files to mark. These are all *.md files under the "prow/"
# directory in kubernetes/test-infra.
function identify_files_to_mark() {
find "${SCRIPT_ROOT}"/../prow -type f -name \*.md | sort
}
function mark_files() {
local notice_tmp
local file_contents
local file_path_prefix
local file_path_rest
file_path_prefix="${SCRIPT_ROOT}/../prow"
for file in "${FILES_TO_MARK[@]}"; do
file_contents="$(cat "${file}")"
file_path_rest="${file#${file_path_prefix}/}"
# Add deprecation notice at the beginning of each file.
cat <<EOF > "${file}"
DOCUMENTATION DEPRECATION NOTICE: This file is deprecated. Please refer to the
[new migrated
location](https://github.com/kubernetes-sigs/prow/tree/main/site/content/en/docs/Legacy%20Snapshot/prow/${file_path_rest}).
Please do not edit this file; instead, make changes to the new location!
The new location is served on the web at
https://docs.prow.k8s.io/docs/legacy-snapshot/.
This file will be deleted on 2022-11-30.
EOF
done
echo "Finished adding tombstone to files."
}
function main() {
mapfile -t FILES_TO_MARK < <(identify_files_to_mark)
mark_files
}
main "$@"