-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow that builds K8S api spec (#509)
- Loading branch information
1 parent
4224727
commit 57b239f
Showing
3 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: k8s_apis_sync | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release: | ||
type: string | ||
required: true | ||
description: '' | ||
|
||
jobs: | ||
k8s_apis_sync: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v3 | ||
|
||
- name: 'Install crdoc' | ||
run: |- | ||
curl -LO https://github.com/fybrik/crdoc/releases/download/v0.6.3/crdoc_Linux_x86_64.tar.gz | ||
tar -xvzf crdoc_Linux_x86_64.tar.gz | ||
sudo mv crdoc /bin/crdoc | ||
- name: 'Fetch release' | ||
run: |- | ||
RELEASE="${{ github.event.inputs.release }}" | ||
aws s3 cp s3://redislabs-k8s/${RELEASE}/ --no-sign-request . --recursive --region us-east-1 | ||
tar xf redis-enterprise-operator-*.tar.gz | ||
- name: 'Generate READMEs' | ||
run: |- | ||
mkdir artifacts | ||
mkdir templates | ||
cp content/operate/kubernetes/reference/kubernetes-api-reference-template.tmpl templates/template.tmpl | ||
crdoc --resources crds/reaadb_crd.yaml --output artifacts/redis_enterprise_active_active_database_api.md --template templates/template.tmpl | ||
sed -E -i 's/^### RedisEnterpriseActiveActiveDatabase\./### /g' artifacts/redis_enterprise_active_active_database_api.md | ||
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterpriseactiveactivedatabase/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_active_active_database_api.md | ||
sed -E -i 's/<td><b><a href="#redisenterpriseactiveactivedatabase/<td><b><a href="#/' artifacts/redis_enterprise_active_active_database_api.md | ||
crdoc --resources crds/rec_crd.yaml --output artifacts/redis_enterprise_cluster_api.md --template templates/template.tmpl | ||
sed -E -i 's/^### RedisEnterpriseCluster\./### /g' artifacts/redis_enterprise_cluster_api.md | ||
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterprisecluster/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_cluster_api.md | ||
sed -E -i 's/<td><b><a href="#redisenterprisecluster/<td><b><a href="#/' artifacts/redis_enterprise_cluster_api.md | ||
crdoc --resources crds/redb_crd.yaml --output artifacts/redis_enterprise_database_api.md --template templates/template.tmpl | ||
sed -E -i 's/^### RedisEnterpriseDatabase\./### /g' artifacts/redis_enterprise_database_api.md | ||
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterprisedatabase/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_database_api.md | ||
sed -E -i 's/<td><b><a href="#redisenterprisedatabase/<td><b><a href="#/' artifacts/redis_enterprise_database_api.md | ||
crdoc --resources crds/rerc_crd.yaml --output artifacts/redis_enterprise_remote_cluster.md --template templates/template.tmpl | ||
sed -E -i 's/^### RedisEnterpriseRemoteCluster\./### /g' artifacts/redis_enterprise_remote_cluster.md | ||
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterpriseremotecluster/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_remote_cluster.md | ||
sed -E -i 's/<td><b><a href="#redisenterpriseremotecluster/<td><b><a href="#/' artifacts/redis_enterprise_remote_cluster.md | ||
- name: 'Send pull request' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: |- | ||
RELEASE="${{ github.event.inputs.release }}" | ||
BRANCH="k8s_apis_docs_${RELEASE}" | ||
# Setup git email and username | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config user.name "github-actions[bot]" | ||
git config --global "url.https://${GH_TOKEN}@github.com/.insteadOf" https://github.com/ | ||
git checkout -b "${BRANCH}" | ||
cp artifacts/redis_enterprise_active_active_database_api.md content/operate/kubernetes/reference/ | ||
cp artifacts/redis_enterprise_cluster_api.md content/operate/kubernetes/reference/ | ||
cp artifacts/redis_enterprise_database_api.md content/operate/kubernetes/reference/ | ||
cp artifacts/redis_enterprise_remote_cluster.md content/operate/kubernetes/reference/ | ||
git apply content/operate/kubernetes/reference/kubernetes-api-reference-frontmatter.patch | ||
git add content/operate/kubernetes/reference/ | ||
git commit -m "k8s api docs ${RELEASE}" | ||
git push origin "${BRANCH}" | ||
gh pr create \ | ||
--body "k8s api docs ${RELEASE}" \ | ||
--title "k8s api docs ${RELEASE}" \ | ||
--head "$BRANCH" \ | ||
--base "main" |
56 changes: 56 additions & 0 deletions
56
content/operate/kubernetes/reference/kubernetes-api-reference-frontmatter.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
diff --git a/content/operate/kubernetes/reference/redis_enterprise_active_active_database_api.md b/content/operate/kubernetes/reference/redis_enterprise_active_active_database_api.md | ||
index 01e82b1b..cacaa46c 100644 | ||
--- a/content/operate/kubernetes/reference/redis_enterprise_active_active_database_api.md | ||
+++ b/content/operate/kubernetes/reference/redis_enterprise_active_active_database_api.md | ||
@@ -5,7 +5,7 @@ categories: | ||
- docs | ||
- operate | ||
- kubernetes | ||
-linkTitle: RedisEnterpriseActiveActiveDatabase API Reference | ||
+linkTitle: REAADB API | ||
weight: 30 | ||
--- | ||
|
||
diff --git a/content/operate/kubernetes/reference/redis_enterprise_cluster_api.md b/content/operate/kubernetes/reference/redis_enterprise_cluster_api.md | ||
index 970ba528..6afe4c50 100644 | ||
--- a/content/operate/kubernetes/reference/redis_enterprise_cluster_api.md | ||
+++ b/content/operate/kubernetes/reference/redis_enterprise_cluster_api.md | ||
@@ -5,8 +5,9 @@ categories: | ||
- docs | ||
- operate | ||
- kubernetes | ||
-linkTitle: RedisEnterpriseCluster API Reference | ||
+linkTitle: REC API | ||
weight: 30 | ||
+aliases: [ /operate/kubernetes/reference/cluster-options, ] | ||
--- | ||
|
||
Packages: | ||
diff --git a/content/operate/kubernetes/reference/redis_enterprise_database_api.md b/content/operate/kubernetes/reference/redis_enterprise_database_api.md | ||
index f925ce44..ea21766e 100644 | ||
--- a/content/operate/kubernetes/reference/redis_enterprise_database_api.md | ||
+++ b/content/operate/kubernetes/reference/redis_enterprise_database_api.md | ||
@@ -5,8 +5,9 @@ categories: | ||
- docs | ||
- operate | ||
- kubernetes | ||
-linkTitle: RedisEnterpriseDatabase API Reference | ||
+linkTitle: REDB API | ||
weight: 30 | ||
+aliases: [ /operate/kubernetes/reference/db-options, ] | ||
--- | ||
|
||
Packages: | ||
diff --git a/content/operate/kubernetes/reference/redis_enterprise_remote_cluster.md b/content/operate/kubernetes/reference/redis_enterprise_remote_cluster.md | ||
index 7d37a6dc..a9a313cf 100644 | ||
--- a/content/operate/kubernetes/reference/redis_enterprise_remote_cluster.md | ||
+++ b/content/operate/kubernetes/reference/redis_enterprise_remote_cluster.md | ||
@@ -5,7 +5,7 @@ categories: | ||
- docs | ||
- operate | ||
- kubernetes | ||
-linkTitle: RedisEnterpriseRemoteCluster API Reference | ||
+linkTitle: RERC API | ||
weight: 30 | ||
--- | ||
|
104 changes: 104 additions & 0 deletions
104
content/operate/kubernetes/reference/kubernetes-api-reference-template.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{{- $group:= index .Groups 0 -}} | ||
{{- $kinds:= index $group.Kinds 0 -}} | ||
{{- $resource := $kinds.Name -}} | ||
{{- $title:= printf "%s %s" $kinds.Name "API Reference" -}} | ||
--- | ||
title: {{ $title }} | ||
alwaysopen: false | ||
categories: | ||
- docs | ||
- operate | ||
- kubernetes | ||
linkTitle: {{ $title }} | ||
weight: 30 | ||
--- | ||
|
||
Packages: | ||
{{ $group:= index .Groups 0 }} | ||
|
||
- [{{$group.Group}}/{{$group.Version}}](#{{ anchorize (printf "%s/%s" $group.Group $group.Version) }}) | ||
|
||
|
||
{{ $group:= index .Groups 0 }} | ||
|
||
# {{$group.Group}}/{{$group.Version}} | ||
|
||
{{range $group.Kinds}} | ||
{{- $kind := . -}} | ||
{{range .Types}} | ||
|
||
{{if not .IsTopLevel}} | ||
### {{.Name}} | ||
{{if .ParentKey}}<sup><sup>[↩ Parent](#{{.ParentKey}})</sup></sup>{{end}} | ||
{{end}} | ||
{{.Description}} | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Description</th> | ||
<th>Required</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{- if .IsTopLevel -}} | ||
<tr> | ||
<td><b>apiVersion</b></td> | ||
<td>string</td> | ||
<td>{{$group.Group}}/{{$group.Version}}</td> | ||
<td>true</td> | ||
</tr> | ||
<tr> | ||
<td><b>kind</b></td> | ||
<td>string</td> | ||
<td>{{$kind.Name}}</td> | ||
<td>true</td> | ||
</tr> | ||
<tr> | ||
<td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta">metadata</a></b></td> | ||
<td>object</td> | ||
<td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td> | ||
<td>true</td> | ||
</tr> | ||
{{- end -}} | ||
{{- range .Fields -}} | ||
<tr> | ||
<td><b>{{if .TypeKey}}<a href="#{{.TypeKey}}">{{.Name}}</a>{{else}}{{.Name}}{{end}}</b></td> | ||
<td>{{.Type}}</td> | ||
<td> | ||
{{.Description}}<br/> | ||
{{- if or .Schema.XValidations .Schema.Format .Schema.Enum .Schema.Default .Schema.Minimum .Schema.Maximum }} | ||
<br/> | ||
{{- end}} | ||
{{- if .Schema.XValidations }} | ||
<i>Validations</i>: | ||
{{- range .Schema.XValidations -}} | ||
<li>{{ .Rule }}: {{ .Message }}</li> | ||
{{- end -}} | ||
{{- end }} | ||
{{- if .Schema.Format }} | ||
<i>Format</i>: {{ .Schema.Format }}<br/> | ||
{{- end }} | ||
{{- if .Schema.Enum }} | ||
<i>Enum</i>: {{ .Schema.Enum | toStrings | join ", " }}<br/> | ||
{{- end }} | ||
{{- if .Schema.Default }} | ||
<i>Default</i>: {{ .Schema.Default }}<br/> | ||
{{- end }} | ||
{{- if .Schema.Minimum }} | ||
<i>Minimum</i>: {{ .Schema.Minimum }}<br/> | ||
{{- end }} | ||
{{- if .Schema.Maximum }} | ||
<i>Maximum</i>: {{ .Schema.Maximum }}<br/> | ||
{{- end }} | ||
</td> | ||
<td>{{.Required}}</td> | ||
</tr> | ||
{{- end -}} | ||
</tbody> | ||
</table> | ||
|
||
{{- end}}{{/* range .Types */}} | ||
{{- end}}{{/* range .Kinds */}} |