crossplane / crossplane/docs

Misleading statements in mergeOptions

Open
#655 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
SCSS
Stars
60
Forks
163
Avg merge
15h 20m
Merged PRs (30d)
9

Description

### URL

https://docs.crossplane.io/latest/concepts/patch-and-transform/#merge-options

### What's Wrong?

According to the documentation:

> With an object, use keepMapValues: true to leave existing object keys in tact. The patch updates any matching keys between the input and destination data.

The second sentence suggests that a patch changing existing keys (or updating them!) will update them, while apparently that's not the case as discussed with Upbound support.

Given this param for a composition:

```
spec:
params:
clusterName: main
tags:
component: cluster
country: us
foo: baz
```

An MR containing:

```
spec:
forProvider:
tags:
foo: bar
```

and being applied a patch like:

```
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.clusterName
toFieldPath: spec.forProvider.tags.cluster-name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.tags
toFieldPath: spec.forProvider.tags
policy:
mergeOptions:
keepMapValues: true
```

will update the tags for the MR and get:

```
tags:
cluster-name: main
component: eks
country: us
foo: bar
```

which is correct, according to documentation.

*However* updating the parameters to:

```
spec:
params:
clusterName: main
tags:
component: network # updated
country: es # updated
foo: baz
```

does not reflect into any changes in the MR, while according to the documentation:

> [...] The patch updates any matching keys between the input and destination data.

and the following was expected in the MR:

```
tags:
cluster-name: main
component: network
country: es
foo: bar
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.