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 #4

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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