Skip to content

Commit

Permalink
Fix shortcodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
amwat committed Dec 13, 2019
1 parent 4c94476 commit 0f4b43f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 33 deletions.
2 changes: 1 addition & 1 deletion site/content/docs/user/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ NOTE: not all options are documented yet! We will fix this with time, PRs welco
Extra mounts can be used to pass through storage on the host to a kind node
for persisting data, mounting through code etc.

{{< codefromfile file="static/examples/config-with-mounts.yaml" lang="yaml" >}}
{{< codefromfile file="examples/config-with-mounts.yaml" lang="yaml" >}}

22 changes: 12 additions & 10 deletions site/content/docs/user/ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ Apply kind specific patches to forward the hostPorts to the
ingress controller, set taint tolerations and
schedule it to the custom labelled node.

{{< codefromfile file="assets/examples/ingress/nginx/patch.json" lang="json" >}}
{{< codefromfile file="examples/ingress/nginx/patch.json" lang="json" >}}

```shell script
{{% mdwithcopy lang="bash" %}}
kubectl patch deployments -n ingress-nginx nginx-ingress-controller -p '{{< minify file="examples/ingress/nginx/patch.json" >}}'
```
{{% /mdwithcopy %}}


Now the Ingress is all setup to be used.
Expand All @@ -76,17 +76,19 @@ Refer [Using Ingress](#using-ingress) for a basic example usage.
The following example creates simple http-echo services
and an Ingress object to route to these services.

{{< codefromfile file="static/examples/ingress/usage.yaml" lang="yaml" >}}
{{< codefromfile file="examples/ingress/usage.yaml" lang="yaml" >}}

Apply the contents

```shell script
{{% mdwithcopy lang="bash" %}}
kubectl apply -f {{< absurl "examples/ingress/nginx/example.yaml" >}}
```
{{% /mdwithcopy %}}

Now verify that the ingress works

```shell script
curl localhost/foo # should output "foo"
curl localhost/bar # should output "bar"
```
{{% mdwithcopy lang="bash" %}}
# should output "foo"
curl localhost/foo
# should output "bar"
curl localhost/bar
{{% /mdwithcopy %}}
File renamed without changes.
2 changes: 1 addition & 1 deletion site/layouts/shortcodes/codefromfile.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ $file := .Get "file" }}
{{ $file := printf "static/%s" (.Get "file") }}
{{ $lang := "" }}
{{ $suffix := findRE "(\\.[^.]+)$" $file 1 }}
{{ with $suffix }}
Expand Down
18 changes: 18 additions & 0 deletions site/layouts/shortcodes/mdwithcopy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ $code := trim .Inner "\n" }}
{{ $lang := "" }}
{{ with .Get "lang" }}{{ $lang = . }}{{ end }}
{{ $hash := md5 $code }}
<table class="includecode" id="inline-code-{{ $hash }}">
<thead>
<tr>
<th> <button
onclick='copyText("inline-code-{{ $hash }}-hidden-copy-text");'>COPY</button></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ highlight $code $lang "" }}</td>
</tr>
</tbody>
<textarea class="hidden-copy-text" id="inline-code-{{ $hash }}-hidden-copy-text">{{ $code }}</textarea>
</table>
5 changes: 4 additions & 1 deletion site/layouts/shortcodes/minify.html
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{{- (resources.Get (.Get "file") | resources.Minify).Content -}}
{{ $file := printf "static/%s" (.Get "file") }}
{{- $contents := readFile $file -}}
{{ $res := $contents | resources.FromString $file }}
{{- ($res | resources.Minify).Content -}}
42 changes: 22 additions & 20 deletions site/static/examples/ingress/usage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metadata:
app: foo
spec:
containers:
- name: foo-app
image: hashicorp/http-echo
args:
- "-text=foo"
- name: foo-app
image: hashicorp/http-echo
args:
- "-text=foo"
---
kind: Service
apiVersion: v1
Expand All @@ -19,7 +19,8 @@ spec:
selector:
app: foo
ports:
- port: 5678 # Default port used by the image
# Default port used by the image
- port: 5678
---
kind: Pod
apiVersion: v1
Expand All @@ -29,10 +30,10 @@ metadata:
app: bar
spec:
containers:
- name: bar-app
image: hashicorp/http-echo
args:
- "-text=bar"
- name: bar-app
image: hashicorp/http-echo
args:
- "-text=bar"
---
kind: Service
apiVersion: v1
Expand All @@ -42,7 +43,8 @@ spec:
selector:
app: bar
ports:
- port: 5678 # Default port used by the image
# Default port used by the image
- port: 5678
---
apiVersion: extensions/v1beta1
kind: Ingress
Expand All @@ -52,14 +54,14 @@ metadata:
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /foo
backend:
serviceName: foo-service
servicePort: 5678
- path: /bar
backend:
serviceName: bar-service
servicePort: 5678
- http:
paths:
- path: /foo
backend:
serviceName: foo-service
servicePort: 5678
- path: /bar
backend:
serviceName: bar-service
servicePort: 5678
---

0 comments on commit 0f4b43f

Please sign in to comment.