Skip to content

Commit

Permalink
Add masOS compatibility for 'sed' usage in scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Schmid <philip.schmid@isovalent.com>
  • Loading branch information
PhilipSchmid authored and mtardy committed Jan 10, 2024
1 parent 7f5f7cc commit a7ec419
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
18 changes: 11 additions & 7 deletions api/export-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ cp v1/README.md $TMP_FILE

# cleanup the generated documentation for the website
# remove the link to the top of the page
sed -i '/<p align="right"><a href="#top">Top<\/a><\/p>/d' $TMP_FILE
sed -i '/<a name="top"><\/a>/d' $TMP_FILE
sed -i'' -e '/<p align="right"><a href="#top">Top<\/a><\/p>/d' $TMP_FILE
sed -i'' -e '/<a name="top"><\/a>/d' $TMP_FILE
# remove title
sed -i '/^# Protocol Documentation/d' $TMP_FILE
sed -i'' -e '/^# Protocol Documentation/d' $TMP_FILE
# remove table of content
sed -i -e '/## Table of Contents/,/##/{//!d}' $TMP_FILE
sed -i '/^## Table of Contents/d' $TMP_FILE
sed -i'' -e '/## Table of Contents/,/##/{//!d;}' $TMP_FILE
sed -i'' -e '/^## Table of Contents/d' $TMP_FILE
# cleanup unecessary consecutive whitelines
sed -i '/^[[:space:]]*$/N;/^[[:space:]]*\n[[:space:]]*$/D' $TMP_FILE
sed -i'' -e '/^[[:space:]]*$/N;/^[[:space:]]*\n[[:space:]]*$/D' $TMP_FILE
# remove empty line at the end of the file (required for macOS, doesn't harm on Linux)
sed -i'' -e '${/^$/d;}' $TMP_FILE

# Cleanup backup file that might be created by macOS sed:
rm ${TMP_FILE}-e 2>/dev/null || true

# add a frontmatter and a small introduction
echo '---
Expand All @@ -43,4 +48,3 @@ The Tetragon API is an independant Go module that can be found in the Tetragon
repository under [api](https://github.com/cilium/tetragon/tree/main/api). The
version 1 of this API is defined in
[github.com/cilium/tetragon/api/v1/tetragon](https://github.com/cilium/tetragon/tree/main/api/v1/tetragon).' | cat - $TMP_FILE > $1

1 change: 0 additions & 1 deletion docs/content/en/docs/reference/grpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -992,4 +992,3 @@ Determins the behaviour of a field filter
| <a name="bool" /> bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass |
| <a name="string" /> string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
| <a name="bytes" /> bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |

3 changes: 1 addition & 2 deletions docs/content/en/docs/reference/helm-chart.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions install/kubernetes/export-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ cp "$TETRAGON_CHART/README.md" $TMP_FILE

# cleanup the generated documentation for the website
# remove the title
sed -i '/^# tetragon$/d' $TMP_FILE
sed -i'' -e '/^# tetragon$/d' $TMP_FILE
# remove the badges
sed -i '/^\!\[Version:/d' $TMP_FILE
sed -i'' -e '/^\!\[Version:/d' $TMP_FILE
# remove the "Helm chart for Tetragon mention"
sed -i '/^Helm chart for Tetragon$/d' $TMP_FILE
sed -i'' -e '/^Helm chart for Tetragon$/d' $TMP_FILE
# remove unnecessary line
sed -i '/^----------------------------------------------$/d' $TMP_FILE
sed -i'' -e '/^----------------------------------------------$/d' $TMP_FILE
# remove autogenerated copyright
sed -i '/^Autogenerated from chart metadata using \[helm-docs /d' $TMP_FILE
sed -i'' -e '/^Autogenerated from chart metadata using \[helm-docs /d' $TMP_FILE
# cleanup unecessary consecutive whitelines
sed -i '/^[[:space:]]*$/N;/^[[:space:]]*\n[[:space:]]*$/D' $TMP_FILE
sed -i'' -e '/^[[:space:]]*$/N;/^[[:space:]]*\n[[:space:]]*$/D' $TMP_FILE
# remove empty line at the end of the file (required for macOS, doesn't harm on Linux)
sed -i'' -e '${/^$/d;}' $TMP_FILE

# Cleanup backup file that might be created by macOS sed:
rm ${TMP_FILE}-e 2>/dev/null || true

# add a frontmatter and a small introduction
echo '---
Expand All @@ -43,7 +47,7 @@ This page was generated with github.io/cilium/tetragon/install/kubernetes/tetrag
please do not edit directly.
{{< /comment >}}
The Tetragon Helm chart source is available under
The Tetragon Helm chart source is available under
[github.io/cilium/tetragon/install/kubernetes/tetragon](https://github.com/cilium/tetragon/tree/main/install/kubernetes/tetragon)
and is distributed from the Cilium helm charts repository [helm.cilium.io](https://helm.cilium.io).
Expand Down

0 comments on commit a7ec419

Please sign in to comment.