openrewrite / openrewrite/rewrite-spring

Support Dynamic newKey values when using glob in ChangeSpringPropertyKey/Value

Open
#636 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
403
Forks
149
Avg merge
2h 33m
Merged PRs (30d)
10

Description

What problem are you trying to solve?

More information here

Basically I have a property that can be given a client name something like

spring:
  datasource:
    source-a:
      url: ...
    source-b:
      url: ...

This could also be in properties like

spring.datasource.source-a.url: ...
spring.datasource.source-b.url: ...

I would like to change the url key to newurl

However ChangeSpringPropertyKey and ChangeSpringPropertyValue only support globs for the oldKey not the newKey. This becomes a problem as there is 2 sources and the names can be defined by the app developer

Describe the solution you'd like

In a perfect world the newKey/newValue would be able to support globs as well as the old one.

Have you considered any alternatives or workarounds?

Currently we just use the YAML ChangeKey and warn properties users they may need to manually fix the files.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java at the linked newKey handling, then inspect the corresponding ChangeSpringPropertyValue implementation. Reproduce the YAML and properties examples from the issue and determine how completion should cover glob patterns in both newKey and newValue; no test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.