Skip to content
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

Add awareness/support for Containerfiles #3

Closed
DovOps opened this issue Jul 23, 2024 · 2 comments · Fixed by #4
Closed

Add awareness/support for Containerfiles #3

DovOps opened this issue Jul 23, 2024 · 2 comments · Fixed by #4
Assignees
Labels
enhancement New feature or request

Comments

@DovOps
Copy link
Contributor

DovOps commented Jul 23, 2024

What problem are you trying to solve?

Dockerfiles are the more popular container build manifest, but Containerfiles are also used with tools such as buildah and podman.

The rewrite-docker tool should be Containerfile-aware as well. As for whether the package needs renaming to be more inclusive of OCI containers (e.g. 'rewrite-container' or 'rewrite-container-images') can always be visited at a future time.

Describe the solution you'd like

Add Containerfile support in this project. Practically, whatever this can do to Dockerfiles, it can do to Containerfiles. We can either modify the filename recognition to recognize both names, or create two separate classes in the assumption that their specification/adherence may diverge.

The OCI specification is listed here: https://github.com/opencontainers/image-spec/blob/main/spec.md

Docker has a 2017 blog article around the earlier emergence of the spec: https://www.docker.com/blog/demystifying-open-container-initiative-oci-specifications/

Have you considered any alternatives or workarounds?

Additional context

Are you interested in contributing this feature to OpenRewrite?

I'm looking to contribute this change to OpenREwrite.

@DovOps DovOps added the enhancement New feature or request label Jul 23, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Jul 23, 2024
@timtebeek
Copy link
Contributor

Thanks for logging this improvement! From looking at the code we'd only have to change this matcher when starting out:

if (text.getSourcePath().toFile().getName().equals("Dockerfile")) {

From the types of changes we're making here for now I think we're fine to treat Dockerfiles and Containerfiles as if they were the same. Once those diverge we can reevaluate, and indeed potentially rename or clone recipes as needed. It's well possible this will look different in the future if we are to add a proper parser.

We'll likely want to make matching changes to our OSS plugins and Moderne CLI to parse Container files as plain text too.

  1. https://github.com/openrewrite/rewrite-maven-plugin/blob/1d2d8aa4ac246e7b0d47d3b4762c96379cb7ee92/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java#L125
  2. https://github.com/openrewrite/rewrite-gradle-plugin/blob/5632d165c0c0660912d4fadad996d8dfc12a70e2/plugin/src/main/java/org/openrewrite/gradle/RewriteExtension.java#L312

Note how each of those use "**/Dockerfile*"; would we want to extend that optional suffix matcher for container files here too?

@DovOps
Copy link
Contributor Author

DovOps commented Jul 23, 2024

@timtebeek this was my thinking as well, and I was planning on submitting that (Along with unit tests which test that containerfile is recognized).

Note how each of those use "**/Dockerfile*"; would we want to extend that optional suffix matcher for container files here too?

I'd think we'd want to find Containerfiles wherever we find Dockerfiles, so I'd say yes.

I'll submit a PR for the simple change.

@timtebeek timtebeek moved this from Backlog to In Progress in OpenRewrite Jul 23, 2024
DovOps pushed a commit to DovOps/rewrite-docker that referenced this issue Jul 23, 2024
@timtebeek timtebeek linked a pull request Jul 24, 2024 that will close this issue
3 tasks
timtebeek added a commit that referenced this issue Jul 24, 2024
* Add awareness/support for Containerfiles #3

* Use parameterized test; apply formatter

---------

Co-authored-by: Jonathan Schneider <[email protected]>
Co-authored-by: Tim te Beek <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants