You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/publish-resources/index.md
+17-14Lines changed: 17 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -303,20 +303,23 @@ existing" and not create an error.
303
303
304
304
#### References
305
305
306
-
A reference is a JSONPath-like expression that are evaluated on both sides of the synchronization.
307
-
You configure a single path expression (like `spec.secretName`) and the sync agent will evaluate it
308
-
in the original primary object (in kcp) and again in the copied primary object (on the service
309
-
cluster). Since the primary object has already been mutated, the `spec.secretName` is already
310
-
rewritten/adjusted to work on the service cluster (for example it was changed from `my-secret` to
311
-
`jk23h4wz47329rz2r72r92-secret`on the service cluster side). By doing it this way, admins only have
312
-
to think about mutations and rewrites once (when configuring the primary object in the
313
-
PublishedResource) and the path will yield 2 ready to use values (`my-secret` and the computed value).
314
-
315
-
The value selected by the path expression must be a string (or number, but it will be coalesced into
316
-
a string) and can then be further adjusted by applying a regular expression to it.
317
-
318
-
References can only ever select one related object. Their upside is that they are simple to understand
319
-
and easy to use, but require a "link" in the primary object that would point to the related object.
306
+
A reference is a JSONPath-like expression (more precisely, it follows the [gjson syntax](https://github.com/tidwall/gjson?tab=readme-ov-file#path-syntax))
307
+
that are evaluated on both sides of the synchronization. You configure a single path expression
308
+
(like `spec.secretName`) and the sync agent will evaluate it in the original primary object (in kcp)
309
+
and again in the copied primary object (on the service cluster). Since the primary object has already
310
+
been mutated, the `spec.secretName` is already rewritten/adjusted to work on the service cluster
311
+
(for example it was changed from `my-secret` to `jk23h4wz47329rz2r72r92-secret` on the service
312
+
cluster side). By doing it this way, admins only have to think about mutations and rewrites once
313
+
(when configuring the primary object in the PublishedResource) and the path will yield 2 ready to
314
+
use values (`my-secret` and the computed value).
315
+
316
+
References can either return a single scalar (strings or integers that will be auto-converted to a
317
+
string) (like in `spec.secretName`) or a list of strings/numbers (like `spec.users.#.name`). A
318
+
reference must return the same number of items on both the local and remote object, otherwise the
319
+
agent will not be able to map local related names to remote related names correctly.
320
+
321
+
A regular expression can be configured to be applied to each found value (i.e. if the reference returns
322
+
a list of values, the regular expression is applied to each individual value).
320
323
321
324
Here's an example on how to use references to locate the related object.
returnnil, fmt.Errorf("cannot sync related resources: found %d namespaces on the origin, but %d on the destination side", len(originNamespaces), len(destNamespaces))
0 commit comments