forked from kumahq/kuma-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_generated.sh
More file actions
executable file
路81 lines (70 loc) 路 2.1 KB
/
Copy pathsync_generated.sh
File metadata and controls
executable file
路81 lines (70 loc) 路 2.1 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -e
function os_agnostic_sed() {
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}
pushd ../kuma
for remote in $(git remote); do
url=$(git remote get-url "$remote")
if [[ "$url" =~ .*kumahq/kuma.* ]]; then
kumahq="$remote"
fi
done
git fetch "$kumahq"
popd
for branch in $(jq -r '.[]' ../kuma/active-branches.json); do
echo "Copying $branch"
i="app/docs/${branch}"
if [[ "${branch}" == "master" ]]; then
i=app/docs/dev
else
i="app/docs/$(echo "${branch}" | sed 's/release-//g').x"
fi
mkdir -p "${i}"
pushd ../kuma
git checkout "$kumahq/$branch"
popd
if [[ $branch == "master" ]]; then
echo "copying versions.yml file"
cp ../kuma/versions.yml app/_data/versions.yml
fi
if [[ ! -d ../kuma/docs/generated ]]; then
echo "No generated docs, ignoring..."
continue
fi
echo "Copying generated docs"
rm -rf "${i}/generated"
cp -r ../kuma/docs/generated "${i}/generated"
if [[ -f ../kuma/pkg/config/app/kuma-cp/kuma-cp.defaults.yaml ]]; then
echo "Copying default"
echo '# Control-Plane configuration
Here are all options to configure the control-plane:
```yaml' > "${i}/generated/kuma-cp.md"
cat ../kuma/pkg/config/app/kuma-cp/kuma-cp.defaults.yaml >> "${i}/generated/kuma-cp.md"
echo '```' >> "${i}/generated/kuma-cp.md"
fi
# Modify generated docs to have a valid format for the website
# shellcheck disable=SC2044
for j in $(find "${i}/generated" -name '*.md'); do
# Make frontmatter titles
os_agnostic_sed -E '1,1 s/^##? (.*)$/---\ntitle: \1\n---/' "${j}"
if [[ "$j" =~ .*/cmd/.* ]]; then
# Fix links
path=$(dirname $j | sed -E 's|.*(/generated.*)|/docs/{{ page.version }}\1|')
os_agnostic_sed -E 's|\((.*).md\)|('"$path"'/\1)|' "${j}"
fi
done
shopt -s nullglob
for policy in ../kuma/pkg/plugins/policies/*/api/v1alpha1/schema.yaml; do
name=$(yq '.properties.type.enum[0]' "${policy}")
if [[ "${name}" == "null" ]]; then
continue
fi
yq -o json '.' "${policy}" > "${i}/generated/${name}.json"
done
shopt -u nullglob
done