-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom YAML filenames in YamlParser #4062
Comments
Hi! Thanks for the detailed description of what you're looking for; did you already come across this open pull request? |
Also; if you'd want to get involved with openrewrite/rewrite-openapi we'd love to have you, or anyone you think might be a good fit. |
@timtebeek That other PR looks fantastic. I had searched specifically for issues/PRs related to YAML which is why I missed it. I think my issue can be closed out, or listed as a 'fixes' item on the open PR. I wasn't aware of rewrite-openapi. I'll take a look at it, although I've admittedly not been active in the OpenAPI space for a few years. |
All good, then let's track progress on that other PR and close this suggestion for an alternative implementation. I do appreciate the amount of detail you put into your suggestion here, and providing the context of why it's needed. Hope we'll see more of you in the community. :) |
What problem are you trying to solve?
My company has an internally built CI/CD pipeline which is configured by extensionless YAML files. It's not uncommon for use to have tests with an extension of the full filename. For example, we may have the following YAML documents
The yaml extensions are hard-coded in the parser. See:
rewrite/rewrite-yaml/src/main/java/org/openrewrite/yaml/YamlParser.java
Line 425 in cf38d64
This causes plugins to not accept our files as YAML. See: https://github.com/openrewrite/rewrite-maven-plugin/blob/ca7c52a91cbe15ef55a4825f0cde2bbc04588164/src/main/java/org/openrewrite/maven/ResourceParser.java#L174
Describe the solution you'd like
I'd like to see a system property exposed which allows defining specific file patterns. Something like this, as an example:
Have you considered any alternatives or workarounds?
As a work around, we've had to extend YamlParser and pass our custom filenames at Maven CLI invocation via
plainTextMasks
. Any recipe which intends to act upon one of our custom filenames must first invoke some internal recipe which parses via our extended parser and exposes the result asYaml.Documents
. This isn't very efficient, and can lead to confusion as users at the company begin using OpenRewrite more.Additional context
I couldn't find any good examples of extending internals via system properties, but I think the proposed behavior above aligns with how properties are used in the Maven and Gradle plugins.
For example, the Maven plugin has user-facing properties defined like this:
And the Gradle plugin has user-facing properties like this:
However, there are some settings-specific properties which use a fqn property like these
rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/MavenSettings.java:
rewrite/rewrite-core/src/main/java/org/openrewrite/internal/TreeVisitorAdapterClassLoader.java:
rewrite-gradle-plugin/plugin/src/test/kotlin/org/openrewrite/gradle/RewritePluginTest.kt:
I think these are really configuring other tools (Maven, testing, and Gradle respectively), so I don't think the fqn property name would make sense in an exposed yaml option.
Are you interested in contributing this feature to OpenRewrite?
Yes, I can open a PR with some tests.
The text was updated successfully, but these errors were encountered: