[WIP] Attempt to consolidate YAML files (#8965)
This is an attempt to consolidate YAML files so that: - They can remain untouched when we moving the documents around; - Contributors do not have to change the test cases each time a documentation is moved; - We can encourage referencing the existing YAMLs from different concept or task pages when possible.pull/9228/head
parent
10cd398d67
commit
99c4c54cb5
|
@ -36,12 +36,12 @@ You can run an application by creating a Kubernetes Deployment object, and you
|
|||
can describe a Deployment in a YAML file. For example, this YAML file describes
|
||||
a Deployment that runs the nginx:1.7.9 Docker image:
|
||||
|
||||
{{< code file="deployment.yaml" >}}
|
||||
{{< codenew file="application/deployment.yaml" >}}
|
||||
|
||||
|
||||
1. Create a Deployment based on the YAML file:
|
||||
|
||||
kubectl apply -f https://k8s.io/docs/tasks/run-application/deployment.yaml
|
||||
kubectl apply -f https://k8s.io/docs/artifacts/application/deployment.yaml
|
||||
|
||||
1. Display information about the Deployment:
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
{{ $p := .Page }}
|
||||
{{ $file := .Get "file" }}
|
||||
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
|
||||
{{ $fileDir := path.Split $file }}
|
||||
{{ $bundlePath := path.Join .Page.Dir $fileDir.Dir }}
|
||||
{{ $filename := printf "/content/%s/artifacts/%s" .Page.Lang $file | safeURL }}
|
||||
{{ $ghlink := printf "https://%s/blob/master%s" .Page.Site.Params.githubWebsiteRepo $filename | safeURL }}
|
||||
{{/* First assume this is a bundle and the file is inside it. */}}
|
||||
{{ $resource := $p.Resources.GetMatch (printf "%s*" $file ) }}
|
||||
{{ with $resource }}
|
||||
{{ $.Scratch.Set "content" .Content }}
|
||||
{{ else }}
|
||||
{{/* Read the file relative to the content root. */}}
|
||||
{{ $resource := readFile $filename}}
|
||||
{{ with $resource }}{{ $.Scratch.Set "content" . }}{{ end }}
|
||||
{{ end }}
|
||||
{{ if not ($.Scratch.Get "content") }}
|
||||
{{ errorf "[%s] %q not found in %q" $p.Site.Language.Lang $fileDir.File $bundlePath }}
|
||||
{{ end }}
|
||||
{{ with $.Scratch.Get "content" }}
|
||||
<table class="includecode" id="{{ $file | anchorize }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}
|
||||
<code>{{ $file }}</code>
|
||||
{{ if $ghlink }}</a>{{ end }}
|
||||
<img src="{{ "images/copycode.svg" | relURL }}" style="max-height:24px" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard">
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ highlight . $codelang "" }} </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
|
@ -440,8 +440,10 @@ func TestExampleObjectSchemas(t *testing.T) {
|
|||
"redis-pod": {&api.Pod{}},
|
||||
"redis-service": {&api.Service{}},
|
||||
},
|
||||
"docs/tasks/run-application": {
|
||||
"artifacts/application": {
|
||||
"deployment": {&extensions.Deployment{}},
|
||||
},
|
||||
"docs/tasks/run-application": {
|
||||
"deployment-patch-demo": {&extensions.Deployment{}},
|
||||
"deployment-scale": {&extensions.Deployment{}},
|
||||
"deployment-update": {&extensions.Deployment{}},
|
||||
|
|
Loading…
Reference in New Issue