Skip to content

Commit ea7b273

Browse files
committed
Clarify mergeOptions to toFieldPath migration logic
Signed-off-by: Jared Watts <jbw976@gmail.com>
1 parent 143d2fd commit ea7b273

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

README.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ use `crossplane beta render`.
119119
This function has a few small, intentional breaking changes compared to the
120120
native implementation.
121121

122+
### New Required fields
123+
122124
These fields are now required. This makes P&T configuration less ambiguous:
123125

124126
* `resources[i].name`
@@ -127,17 +129,41 @@ These fields are now required. This makes P&T configuration less ambiguous:
127129
* `resources[i].patches[i].transforms[i].string.type`
128130
* `resources[i].patches[i].transforms[i].math.type`
129131

132+
### `mergeOptions` replaced by `toFieldPath`
133+
130134
Also, the `resources[i].patches[i].policy.mergeOptions` field is no longer
131-
supported. The same capability can be achieved by setting
132-
`resources[i].patches[i].policy.toFieldPath` to:
133-
- `MergeObjects` - equivalent to
134-
`resources[i].patches[i].policy.mergeOptions.keepMapValues: true`
135-
- `MergeObjectsAppendArrays` - equivalent to
136-
`resources[i].patches[i].policy.mergeOptions{keepMapValues: true, appendSlice: true}`
137-
- `ForceMergeObjects` - equivalent to
138-
`resources[i].patches[i].policy.mergeOptions.keepMapValues: false`
139-
- `ForceMergeObjectsAppendArrays` - equivalent to
140-
`resources[i].patches[i].policy.mergeOptions.appendSlice: true`
135+
supported. This functionality has been replaced by the
136+
`resources[i].patches[i].policy.toFieldPath` field. The table below outlines
137+
previous behavior that was possible with `mergeOptions` and how to achieve it
138+
with the new `toFieldPath` field:
139+
140+
| # | `mergeOptions` | `appendSlice`| `keepMapValues` | `toFieldPath` |
141+
| - | ------------- | ------------ | --------------- | -------------------- |
142+
| 1 | `nil` | N/A | N/A | `nil` which defaults to `Replace` |
143+
| 2 | `non-nil` | `nil` or `false` | `true` | `MergeObjects` |
144+
| 3 | `non-nil` | `true` | `nil` or `false` | `ForceMergeObjectsAppendArrays` |
145+
| 4 | `non-nil` | `nil` or `false` | `nil` or `false` | `ForceMergeObjects` |
146+
| 5 | `non-nil` | `true` | `true` | `MergeObjectsAppendArrays` |
147+
148+
As an example, a previous configuration using the no longer supported `mergeOptions`:
149+
150+
```yaml
151+
policy:
152+
mergeOptions:
153+
appendSlice: true
154+
keepMapValues: true
155+
```
156+
157+
Should be replaced with:
158+
159+
```yaml
160+
policy:
161+
toFieldPath: MergeObjectsAppendArrays
162+
```
163+
164+
Starting with Crossplane v1.16.0, the `convert` command in the [Crossplane
165+
CLI][cli-convert] will automatically convert `mergeOptions` to `toFieldPath` for
166+
you.
141167

142168
## Developing this function
143169

@@ -168,3 +194,4 @@ $ crossplane xpkg build -f package --embed-runtime-image=runtime
168194
[go]: https://go.dev
169195
[docker]: https://www.docker.com
170196
[cli]: https://docs.crossplane.io/latest/cli
197+
[cli-convert]: https://docs.crossplane.io/latest/cli/command-reference/#beta-convert

0 commit comments

Comments
 (0)