Closed josemariavillar closed 3 years ago
Hi @josemariavillar, thanks for reporting the issue!
I'd recommend a slightly different approach:
---
type: specs.openrewrite.org/v1beta/recipe
name: darwin.example.Migrate
displayName: Migrate Example
description: 'Migrate properties found in `application.properties` and `application.yml`.'
recipeList:
- org.openrewrite.yaml.DeleteProperty:
propertyKey: es.santander.nuar.util.security.omnichannel.OFI
coalesce: true
- org.openrewrite.yaml.ChangePropertyKey:
oldPropertyKey: es.santander.nuar.util.omnichannel
newPropertyKey: darwin.omnichannel
Using coalensce on DeleteProperty will bring es.santander.nuar.util.security.omnichannel:
up to the root and remove the target entry.
# result
es.santander.nuar.util.omnichannel:
external-channel-map.ALL.OFI:
marco-channel: OFI_W
environment: INTRANET_Z
security.filter-order: 100
parameter: "channel"
header: "X-Santander-Channel"
Then ChangePropertyKey will update the key to what you'd like:
darwin.omnichannel:
external-channel-map.ALL.OFI:
marco-channel: OFI_W
environment: INTRANET_Z
security.filter-order: 100
parameter: "channel"
header: "X-Santander-Channel"
Please let me know if you have any questions, thanks again.
Just a cool tip if you don't know, postfixing ``` with a language will enable syntax highlighting :) examples: ```java, ```yaml
@josemariavillar Thanks again for reaching out!
Good afternoon,
I am observing a strange behavior when combining different recipes, specifically DeleteProperty and ChangePropertyKey. If I set the following recipe:
on the following YAML:
the obtained result is the correct one:
But, if we set the "coalesce" property of the DeleteProperty to "true" the result, instead, is not the expected one, the property "en.santander.nuar.util.omnichannel.external-channel-map" does not change:
If now, we change the order of the recipes and the DeleteProperty recipe to put it at the end, the result is different:
In this case, as we can see, the DeleteProperty recipe is not executed and does not delete the property "en.santander.nuar.util.security.omnichannel" regardless of whether the "coalesce" is set to false or true:
Can you tell me, please, what could be happening and if I am misapplying any recipe. I have the suspicion that the problem occurs when combining recipes with properties of type "Map with values".
Thank you very much