Skip to content

Commit

Permalink
Add awareness/support for Containerfiles #3 (#4)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jul 24, 2024
1 parent dceb376 commit cca5605
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/openrewrite/docker/trait/Dockerfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public static class Matcher extends SimpleTraitMatcher<Dockerfile> {
Object value = cursor.getValue();
if (value instanceof PlainText) {
PlainText text = (PlainText) value;
if (text.getSourcePath().toFile().getName().equals("Dockerfile")) {
String fileName = text.getSourcePath().toFile().getName();
if (fileName.equals("Dockerfile") || fileName.equals("Containerfile")) {
return new Dockerfile(cursor);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package org.openrewrite.docker;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openrewrite.DocumentExample;
import org.openrewrite.docker.search.FindDockerImageUses;
import org.openrewrite.docker.table.DockerBaseImages;
Expand All @@ -32,9 +34,10 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new FindDockerImageUses());
}

@Test
@DocumentExample
void dockerfile() {
@ParameterizedTest
@ValueSource(strings = {"Dockerfile", "Containerfile"})
void dockerfile(String path) {
rewriteRun(
text(
//language=Dockerfile
Expand All @@ -50,7 +53,7 @@ void dockerfile() {
ARG DEBIAN_FRONTEND=noninteractive
SHELL ["sh", "-lc"]
""",
spec -> spec.path("Dockerfile")
spec -> spec.path(path)
)
);
}
Expand Down

0 comments on commit cca5605

Please sign in to comment.