spring - How do I use wildcards with ChangeSpringPropertyKey OpenRewrite Recipe - Stack Overflow

I am trying to convert the followingme:cxf:jaxws:services:myconfig:retry:enabled: truesleuth:enabled:

I am trying to convert the following

me:
  cxf:
    jaxws:
      services:
        myconfig:
          retry:
            enabled: true
          sleuth:
            enabled: true

The problem here is this can be in properties or YAML. I need to change it to

me:
  cxf:
    jaxws:
      services:
        myconfig:
          retry:
            enabled: true
          observation:
            enabled: true

I tried

  - .openrewrite.java.spring.ChangeSpringPropertyKey:
      oldPropertyKey: me.cxf.jaxws.services.*.sleuth
      newPropertyKey: me.cxf.jaxws.services.{*}.observation

and

  - .openrewrite.java.spring.ChangeSpringPropertyKey:
      oldPropertyKey: me.cxf.jaxws.services.*.sleuth
      newPropertyKey: me.cxf.jaxws.services.*.observation

But these end up removing the myconfig

       services:
-        myconfig:
-          observation:
+          {*}.observation:
             enabled: true

So what is the correct way to use dynamic paths with the ChangeSpringPropertyKey?

I can't use ChangeKey because it only works for yaml and not .properties

update

So I was thinking about using both the ChangeKey and ChangeSpringPropertyKey but the problem seems to be based on the docs this wouldn't work for properties either. for example if I had

a.b.c.property=Something
a.f.c.otherProperty=Something

And I wanted to change it to

a.b.d.property=Something
a.f.d.otherProperty=Something

based on the docs I see here

The new name for the property key.

with no mention of glob vs the old one which does support it

The property key to rename. Supports glob

I am trying to convert the following

me:
  cxf:
    jaxws:
      services:
        myconfig:
          retry:
            enabled: true
          sleuth:
            enabled: true

The problem here is this can be in properties or YAML. I need to change it to

me:
  cxf:
    jaxws:
      services:
        myconfig:
          retry:
            enabled: true
          observation:
            enabled: true

I tried

  - .openrewrite.java.spring.ChangeSpringPropertyKey:
      oldPropertyKey: me.cxf.jaxws.services.*.sleuth
      newPropertyKey: me.cxf.jaxws.services.{*}.observation

and

  - .openrewrite.java.spring.ChangeSpringPropertyKey:
      oldPropertyKey: me.cxf.jaxws.services.*.sleuth
      newPropertyKey: me.cxf.jaxws.services.*.observation

But these end up removing the myconfig

       services:
-        myconfig:
-          observation:
+          {*}.observation:
             enabled: true

So what is the correct way to use dynamic paths with the ChangeSpringPropertyKey?

I can't use ChangeKey because it only works for yaml and not .properties

update

So I was thinking about using both the ChangeKey and ChangeSpringPropertyKey but the problem seems to be based on the docs this wouldn't work for properties either. for example if I had

a.b.c.property=Something
a.f.c.otherProperty=Something

And I wanted to change it to

a.b.d.property=Something
a.f.d.otherProperty=Something

based on the docs I see here

The new name for the property key.

with no mention of glob vs the old one which does support it

The property key to rename. Supports glob

Share Improve this question edited Nov 20, 2024 at 16:08 JGleason asked Nov 20, 2024 at 15:37 JGleasonJGleason 3,9586 gold badges29 silver badges61 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Thanks for sharing your findings! Indeed there seems to be a mismatch here: the ChangeSpringPropertyKey recipe delegates to two other recipes, which do not both support the same format. As such I've for now removed the indication that glob is supported, and we'll circle back to try to add that in.

There's some related work being done here that should make this easier to add:

  • https://github/openrewrite/rewrite/pull/4708

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742348025a4426943.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信