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