Read an argument and an image name without rewrite-docker internals - #1220
Merged
Conversation
openrewrite/rewrite#8636 reverts `rewrite-docker` to its state before #8583, taking `org.openrewrite.docker.internal.ArgumentContents` and `org.openrewrite.docker.trait.ImageName` with it. This recipe imports both, so main stops compiling the moment a snapshot carrying that revert lands. Both were thin. `text`, `textWithVariables` and `containsVariable` walk an argument's contents, and only `getPath()` and `getRegistry()` of `ImageName` were ever read, so they move here as private helpers, registry detection rule and all. Nothing else the recipe reaches for moves in the revert: the tree types, `Docker.File.getGlobalArgs()` and `DockerFrom`'s `getImageName`, `getTag`, `withImageReference` and `withTag` all predate #8583. That also finishes what #1216 started. The recipe now links against no `internal` package and no trait helper, so the Moderne CLI classloader split that #1215 came from has nothing left to split on. Two things the reverted grammar no longer does needed answering: An `ARG` default value's quotes sit inside the text of its literal rather than in the literal's quote style, so `ARG JAVA_VERSION="11"` read back as `"11"` and matched no version. They are taken off on read and put back on write, both no-ops against a version that models the quotes, so this holds either way. `FROM eclipse-temurin:` no longer round-trips, printing as `FROM eclipse-temurin` and failing the parser's own idempotency check. That is upstream and unrelated to this recipe, so the case leaves the no-change rows. Verified against openrewrite/rewrite at 63b15b0b07 built and published locally: all 78 tests of `UpgradeDockerImageVersionTest` pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docker: revert rewrite-docker to its state before #8583 rewrite#8636 reverts
rewrite-dockerto its state before #8583, takingorg.openrewrite.docker.internal.ArgumentContentsandorg.openrewrite.docker.trait.ImageNamewith it.UpgradeDockerImageVersionimports both, so main stops compiling the moment a snapshot carrying that revert lands. It merged this morning as 63b15b0b07, and this recipe is the only thing in this repository that touchesrewrite-docker.Both classes were thin.
text,textWithVariablesandcontainsVariablewalk an argument's contents, and onlygetPath()andgetRegistry()ofImageNamewere ever read, so they move into the recipe as private helpers, registry detection rule and all. Nothing else the recipe reaches for moves in the revert: the tree types,Docker.File.getGlobalArgs()andDockerFrom'sgetImageName,getTag,withImageReferenceandwithTagall predate #8583.That also finishes what Upgrade
ARGdefault values used in DockerFROMinstructions (hold for rewrite release) #1216 started. The recipe now links against nointernalpackage and no trait helper, so the Moderne CLI classloader split that Revert "UpgradeARGdefault values used in DockerFROMinstructions" #1215 came from has nothing left to split on.Two things the reverted grammar no longer does needed answering:
ARGdefault value's quotes sit inside the text of its literal rather than in the literal's quote style, soARG JAVA_VERSION="11"read back as"11"and matched no version. They are taken off on read and put back on write, both no-ops against a version that models the quotes, so this holds either way.FROM eclipse-temurin:no longer round-trips, printing asFROM eclipse-temurinand failing the parser's own idempotency check. That is upstream and unrelated to this recipe, so the case leaves the no-change rows.Verified against openrewrite/rewrite at 63b15b0b07, built and published locally: all 78 tests of
UpgradeDockerImageVersionTestpass.Reverting this
ArgumentContentsand the image reference traits the revert took out. TheARGquote handling stays correct against that tree rather than merely harmless, so the only thing genuinely waiting on #8637 is theFROM eclipse-temurin:no-change row.