Skip to content

Commit bc68162

Browse files
authored
Merge pull request #69 from kcp-dev/fix-docs
fix docs
2 parents 7d49e3d + 3f0ea03 commit bc68162

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

docs/content/publish-resources/index.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ conventions of whatever tooling ultimately processes the resources locally.
139139

140140
This snippet shows the implicit default configuration:
141141

142+
{% raw %}
142143
```yaml
143144
apiVersion: syncagent.kcp.io/v1alpha1
144145
kind: PublishedResource
@@ -150,6 +151,7 @@ spec:
150151
namespace: '{{ .ClusterName }}'
151152
name: '{{ .Object.metadata.namespace | sha3short }}-{{ .Object.metadata.name | sha3short }}'
152153
```
154+
{% endraw %}
153155

154156
This configuration ensures that no collisions will happen: Each workspace in
155157
kcp will create a namespace on the local cluster, with a combination of namespace and name hashes
@@ -185,13 +187,15 @@ PublishedResources over to Go templates.
185187

186188
The following table shows the available variables and their modern replacements:
187189

190+
{% raw %}
188191
| Deprecated Variable | Go Template | Description |
189192
| ---------------------- | ----------------------------------------------- | ----------- |
190193
| `$remoteClusterName` | `{{ .ClusterName }}` | the workspace's cluster name (e.g. "1084s8ceexsehjm2") |
191194
| `$remoteNamespace` | `{{ .Object.metadata.namespace }}` | the original namespace used by the consumer inside the workspace |
192195
| `$remoteNamespaceHash` | `{{ .Object.metadata.namespace \| shortHash }}` | first 20 hex characters of the SHA-1 hash of `$remoteNamespace` |
193196
| `$remoteName` | `{{ .Object.metadata.name }}` | the original name of the object inside the workspace (rarely used to construct local namespace names) |
194197
| `$remoteNameHash` | `{{ .Object.metadata.name \| shortHash }}` | first 20 hex characters of the SHA-1 hash of `$remoteName` |
198+
{% endraw %}
195199

196200
Note that `ClusterPath` was never available in `$variable` form.
197201

@@ -316,6 +320,7 @@ and easy to use, but require a "link" in the primary object that would point to
316320

317321
Here's an example on how to use references to locate the related object.
318322

323+
{% raw %}
319324
```yaml
320325
apiVersion: syncagent.kcp.io/v1alpha1
321326
kind: PublishedResource
@@ -367,6 +372,7 @@ spec:
367372
# pattern: '...'
368373
# replacement: '...'
369374
```
375+
{% endraw %}
370376

371377
#### Templates
372378

@@ -403,11 +409,12 @@ type localObjectNamingContext struct {
403409
In the simplest form, a template can replace a reference:
404410

405411
* reference: `.spec.secretName`
406-
* Go template: `{{ .Object.spec.secretName }}`
412+
* Go template: {% raw %}`{{ .Object.spec.secretName }}`{% endraw %}
407413

408414
Just like with references, the configured template is evaluated twice, once for each side of the
409415
synchronization. You can use the `Side` variable to allow for fully customized names on each side:
410416

417+
{% raw %}
411418
```yaml
412419
spec:
413420
...
@@ -418,6 +425,7 @@ spec:
418425
template:
419426
template: `{{ if eq .Side "kcp" }}name-in-kcp{{ else }}name-on-service-cluster{{ end }}`
420427
```
428+
{% endraw %}
421429

422430
See [Templating](templating.md) for more information on how to use templates in PublishedResources.
423431

@@ -455,6 +463,7 @@ how peculiar the underlying operators on the service clusters are.
455463

456464
Here is an example on how to use label selectors:
457465

466+
{% raw %}
458467
```yaml
459468
apiVersion: syncagent.kcp.io/v1alpha1
460469
kind: PublishedResource
@@ -509,10 +518,8 @@ spec:
509518
replacement: "bar-\\1"
510519

511520
# or
512-
{% raw %}
513521
template:
514522
template: "{{ .Name }}-foo"
515-
{% endraw %}
516523

517524
# Like with references, the namespace can (or must) be configured explicitly.
518525
# You do not need to also use label selectors here, you can mix and match
@@ -524,6 +531,7 @@ spec:
524531
# pattern: '...'
525532
# replacement: '...'
526533
```
534+
{% endraw %}
527535

528536
There are two possible usages of Go templates when using label selectors. See [Templating](templating.md)
529537
for more information on how to use templates in PublishedResources in general.
@@ -620,6 +628,7 @@ metadata:
620628
spec: {}
621629
```
622630
631+
{% raw %}
623632
```yaml
624633
apiVersion: syncagent.kcp.io/v1alpha1
625634
kind: PublishedResource
@@ -652,3 +661,4 @@ spec:
652661
template:
653662
template: '{{ .Object.spec.secretName }}'
654663
```
664+
{% endraw %}

docs/content/publish-resources/templating.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Templating
22

3+
{% raw %}
34
`PublishedResources` allow to use [Go templates](https://pkg.go.dev/text/template) in a number of
45
places. A simple template could look like `{{ .Object.spec.secretName | sha3sum }}`.
6+
{% endraw %}
57

68
## General Usage
79

0 commit comments

Comments
 (0)