mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
fake realpath, and standardize treatment of trailing / of dirs in gendoc
This commit is contained in:
parent
f635c9984c
commit
055115a109
@ -18,6 +18,12 @@ kube::util::sortable_date() {
|
|||||||
date "+%Y%m%d-%H%M%S"
|
date "+%Y%m%d-%H%M%S"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# this mimics the behavior of linux realpath which is not shipped by default with
|
||||||
|
# mac OS X
|
||||||
|
kube::util::realpath() {
|
||||||
|
[[ $1 = /* ]] && echo "$1" | sed 's/\/$//' || echo "$PWD/${1#./}" | sed 's/\/$//'
|
||||||
|
}
|
||||||
|
|
||||||
kube::util::wait_for_url() {
|
kube::util::wait_for_url() {
|
||||||
local url=$1
|
local url=$1
|
||||||
local prefix=${2:-}
|
local prefix=${2:-}
|
||||||
@ -123,9 +129,9 @@ kube::util::wait-for-jobs() {
|
|||||||
# that match $3, copy is skipped.
|
# that match $3, copy is skipped.
|
||||||
kube::util::gen-doc() {
|
kube::util::gen-doc() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
local base_dest="$(realpath $2)/"
|
local base_dest="$(kube::util::realpath $2)"
|
||||||
local relative_doc_dest="$3"
|
local relative_doc_dest="$(echo $3 | sed 's/\/$//')"
|
||||||
local dest="${base_dest}${relative_doc_dest}"
|
local dest="${base_dest}/${relative_doc_dest}"
|
||||||
local skipprefix="${4:-}"
|
local skipprefix="${4:-}"
|
||||||
|
|
||||||
# We do this in a tmpdir in case the dest has other non-autogenned files
|
# We do this in a tmpdir in case the dest has other non-autogenned files
|
||||||
@ -141,7 +147,7 @@ kube::util::gen-doc() {
|
|||||||
# Add analytics link to generated .md files
|
# Add analytics link to generated .md files
|
||||||
if [[ "${file}" == *.md ]]; then
|
if [[ "${file}" == *.md ]]; then
|
||||||
local link path
|
local link path
|
||||||
path="$relative_doc_dest$file"
|
path="${relative_doc_dest}/${file}"
|
||||||
link=$(kube::util::analytics-link "${path}")
|
link=$(kube::util::analytics-link "${path}")
|
||||||
echo -e "\n${link}" >> "${tmpdir}/${file}"
|
echo -e "\n${link}" >> "${tmpdir}/${file}"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user