Skip to content

Commit

Permalink
Merge branch 'main' into api
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Oct 11, 2023
2 parents 95dae7e + 31a46b4 commit 0a791c9
Show file tree
Hide file tree
Showing 17 changed files with 238 additions and 785 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "API",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": [
"serve"
]
}
]
}
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ codegen-mkdocs: codegen-docs ## Generate mkdocs website
@rm -rf ./website/docs/jp && mkdir -p ./website/docs/jp && cp docs/user/jp/* ./website/docs/jp
@mkdocs build -f ./website/mkdocs.yaml


.PHONY: codegen-schema-openapi
codegen-schema-openapi: $(KIND) $(HELM) ## Generate openapi schemas (v2 and v3)
@echo Generate openapi schema... >&2
Expand All @@ -194,15 +193,15 @@ codegen-schema-json: codegen-schema-openapi ## Generate json schemas
.PHONY: codegen-schema-all
codegen-schema-all: codegen-schema-openapi codegen-schema-json ## Generate openapi and json schemas

.PHONY: codegen-all
codegen-all: codegen-crds codegen-deepcopy codegen-register codegen-docs codegen-mkdocs codegen-schema-all ## Rebuild all generated code and docs
.PHONY: codegen
codegen: codegen-crds codegen-deepcopy codegen-register codegen-docs codegen-mkdocs codegen-schema-all ## Rebuild all generated code and docs

.PHONY: verify-codegen
verify-codegen: codegen-all ## Verify all generated code and docs are up to date
verify-codegen: codegen ## Verify all generated code and docs are up to date
@echo Checking codegen is up to date... >&2
@git --no-pager diff -- .
@echo 'If this test fails, it is because the git diff is non-empty after running "make codegen-all".' >&2
@echo 'To correct this, locally run "make codegen-all", commit the changes, and re-run tests.' >&2
@echo 'If this test fails, it is because the git diff is non-empty after running "make codegen".' >&2
@echo 'To correct this, locally run "make codegen", commit the changes, and re-run tests.' >&2
@git diff --quiet --exit-code -- .

########
Expand Down
34 changes: 34 additions & 0 deletions docs/user/apis/_config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
hiddenMemberFields:
- "TypeMeta"

externalPackages:
- match: ^k8s\.io/apimachinery/pkg/apis/meta/v1\.Duration$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration
- match: ^k8s\.io/apimachinery/pkg/apis/meta/v1\.GroupVersionKind$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#GroupVersionKind
- match: ^k8s\.io/apimachinery/pkg/apis/meta/v1\.GroupVersionResource$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#GroupVersionResource
- match: ^k8s\.io/apimachinery/pkg/types\.UID$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/types#UID
- match: ^k8s\.io/apimachinery/pkg/runtime\.RawExtension$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/runtime/#RawExtension
- match: ^k8s\.io/apimachinery/pkg/api/resource\.QuantityValue$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#QuantityValue
- match: ^k8s\.io/apimachinery/pkg/api/resource\.Quantity$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity
- match: ^k8s\.io/apimachinery/pkg/runtime\.Unknown$
target: https://pkg.go.dev/k8s.io/apimachinery/pkg/runtime#Unknown
- match: ^time\.Duration$
target: https://pkg.go.dev/time#Duration
- match: ^io.Writer$
target: https://pkg.go.dev/io#Writer
- match: ^k8s\.io/(api|apimachinery/pkg/apis)/
target: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#{{- lower .TypeIdentifier -}}-{{- arrIndex .PackageSegments -1 -}}-{{- arrIndex .PackageSegments -2 -}}

stripPrefix:
- k8s.io/api/
- k8s.io/apimachinery/pkg/apis/
- github.com/tengqm/kubeconfig/config/kubeadm/v1beta2.
- github.com/tengqm/kubeconfig/config/kubeadm/v1beta3.
- github.com/tengqm/kubeconfig/config/bootstraptoken/v1.

markdownDisabled: false

apis:
Expand Down
66 changes: 36 additions & 30 deletions docs/user/apis/_config/markdown/members.tpl
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
{{ define "members" }}
{{/* . is a apiType */}}
{{- range .GetMembers -}}
{{/* . is a apiMember */}}
{{- if not .Hidden }}
<tr><td><code>{{ .FieldName }}</code>
{{- if not .IsOptional }} <B>[Required]</B>{{- end -}}
<br/>
{{/* Link for type reference */}}
{{- with .GetType -}}
{{- if .Link -}}
<a href="{{ .Link }}"><code>{{ .DisplayName }}</code></a>
{{- define "comment" -}}
{{- $comment := "" -}}
{{- range . -}}
{{- if . -}}
{{- if not (eq (index . 0) '+') -}}
{{- if $comment -}}
{{- $comment = print $comment " " . -}}
{{- else -}}
<code>{{ .DisplayName }}</code>
{{- $comment = . -}}
{{- end -}}
{{- end }}
</td>
<td>
{{- if .IsInline -}}
(Members of <code>{{ .FieldName }}</code> are embedded into this type.)
{{- end }}
{{ if .GetComment -}}
{{ .GetComment }}
{{- else -}}
<span class="text-muted">No description provided.</span>
{{- end }}
{{- if and (eq (.GetType.Name.Name) "ObjectMeta") -}}
Refer to the Kubernetes API documentation for the fields of the <code>metadata</code> field.
{{- end -}}
</td>
</tr>
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $comment -}}
<p>{{ $comment }}</p>
{{- else -}}
*No description provided.*
{{- end -}}
{{- end -}}

{{- define "typ" -}}
{{- if .Link -}}
[`{{ .DisplayName }}`]({{ .Link }})
{{- else -}}
`{{ .DisplayName }}`
{{- end -}}
{{- end -}}

{{- define "members" }}
{{- range .GetMembers }}
{{- if not .Hidden }}
{{- $name := .FieldName }}
{{- $optional := .IsOptional }}
{{- $type := .GetType }}
{{- $inline := .IsInline }}
{{- $comment := .GetComment }}
| `{{ $name }}` | {{ template "typ" $type }} | {{ if not $optional }}:white_check_mark:{{ end }} | {{ template "comment" .CommentLines }} |
{{- end }}
{{- end }}
{{ end }}
{{- end }}
52 changes: 24 additions & 28 deletions docs/user/apis/_config/markdown/type.tpl
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
{{ define "type" }}

{{- define "type" }}
## `{{ .Name.Name }}` {#{{ .Anchor }}}

{{ if eq .Kind "Alias" -}}
(Alias of `{{ .Underlying }}`)
{{ end }}
{{- if eq .Kind "Alias" }}

(Alias of `{{ .Underlying }}`)
{{- end }}
{{- with .References }}

**Appears in:**
{{ range . }}
{{ if or .Referenced .IsExported -}}
{{ range . }}
{{- if or .Referenced .IsExported }}
- [{{ .DisplayName }}]({{ .Link }})
{{ end -}}
{{- end -}}
{{- end }}
{{- end }}
{{- end }}
{{- if .GetComment }}

{{ if .GetComment -}}
{{ .GetComment }}
{{ end }}
{{ if .GetMembers -}}
<table class="table">
<thead><tr><th width="30%">Field</th><th>Description</th></tr></thead>
<tbody>
{{/* . is a apiType */}}
{{- if .IsExported -}}
{{/* Add apiVersion and kind rows if deemed necessary */}}
<tr><td><code>apiVersion</code><br/>string</td><td><code>{{- .APIGroup -}}</code></td></tr>
<tr><td><code>kind</code><br/>string</td><td><code>{{- .Name.Name -}}</code></td></tr>
{{ end -}}
{{- end }}
{{- if .GetMembers }}

{{/* The actual list of members is in the following template */}}
{{- template "members" . -}}
</tbody>
</table>
{{- end -}}
{{- end -}}
| Field | Type | Required | Description |
|---|---|---|---|
{{- /* . is a apiType */}}
{{- if .IsExported }}
{{- /* Add apiVersion and kind rows if deemed necessary */}}
| `apiVersion` | `string` | :white_check_mark: | `{{- .APIGroup -}}` |
| `kind` | `string` | :white_check_mark: | `{{- .Name.Name -}}` |
{{- end }}
{{- /* The actual list of members is in the following template */}}
{{- template "members" . }}
{{- end }}
{{ end }}
Loading

0 comments on commit 0a791c9

Please sign in to comment.