-
Notifications
You must be signed in to change notification settings - Fork 542
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
refactor (jkube-kit) : Move Dockerfile opinionated ImageConfig logic from ConfigHelper.initImageConfiguration
to a dedicated generator
#2802
Conversation
Eclipse JKube CI ReportStarted new GH workflow run for #2802 (2024-04-11T11:41:57Z) ⚙️ JKube E2E Tests (8645730604)
|
5d14f29
to
451c7e2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2802 +/- ##
=============================================
+ Coverage 59.36% 70.63% +11.27%
- Complexity 4586 5030 +444
=============================================
Files 500 488 -12
Lines 21211 19504 -1707
Branches 2830 2512 -318
=============================================
+ Hits 12591 13776 +1185
+ Misses 7370 4497 -2873
+ Partials 1250 1231 -19 ☔ View full report in Codecov by Sentry. |
451c7e2
to
76fb24c
Compare
ce63991
to
637543e
Compare
57a6e31
to
e5b283f
Compare
e5b283f
to
b3ff84a
Compare
I recall we might have discussed this a few weeks ago. |
@manusa : I had added a test in SimpleDockerFileGeneratorTest to verify that generator doesn't modify existing ImageConfiguration when they have been altered by any other generator. Shall I add an additional test to assert the order of generators in the default profile? |
b3ff84a
to
b5d9de6
Compare
I've added tests verifying the generators execution order in the default profile in b5d9de6 . Please check if it's in line with your expectations. |
…from `ConfigHelper.initImageConfiguration` to a dedicated generator + ConfigHelper modifies the provided set of ImageConfigurations when it detects a `Dockerfile` in project root directory. This is actually a feature called Simple Dockerfile Mode. However, this mutation of ImageConfiguration from within `initImageConfiguration` does not look appropriate. It can be moved to a dedicated generator that will get activated when `Dockerfile` is present in project base directory. + Add a new generator SimpleDockerfileGenerator, it adds a simple ImageConfiguration with Dockerfile configured in build and adds it to existing set of ImageConfigurations. + Remove check from BaseGenerator to skip generation if it's simple Dockerfile mode Move it to SimpleDockerfileGenerator.isApplicable instead Signed-off-by: Rohan Kumar <rohaan@redhat.com>
b5d9de6
to
e4e0d12
Compare
...e/src/main/java/org/eclipse/jkube/generator/dockerfile/simple/SimpleDockerfileGenerator.java
Show resolved
Hide resolved
d7e629e
to
7832a28
Compare
List<Generator> generatorList = createUsableGeneratorList(generatorContext); | ||
|
||
// Then | ||
Assertions.assertThat(generatorList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for readability purpose, could you make Assertions.assertThat statically imported ?
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the scope declaration consistent:
- either you don't declare them and assume it is coming from the dependencyManagement
- either you declare them everywhere (also for org.assertj)
...n-plugin/plugin/src/test/java/org/eclipse/jkube/maven/plugin/mojo/develop/WatchMojoTest.java
Show resolved
Hide resolved
7832a28
to
7d5736b
Compare
// Then | ||
assertThat(generatorList) | ||
.hasSize(12) | ||
.satisfies(g -> Assertions.assertThat(g.get(0)).isInstanceOf(SimpleDockerfileGenerator.class)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, would be nice to have static imports for Assertions.assertThat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, let me fix it.
c58247b
to
5e7a97c
Compare
This works, however is extremely brittle and hard to maintain (which probably defeats the purpose). The idea is to create a test that ensures the behavior (not sure how since I haven't dug into the code), test should fail in the event of a modification in the generator order (default profile). |
@manusa There is a Shall I try adding log verifications for this instead? |
If the check consists in checking the generator print order, then that's mostly the same of what we have now. |
Signed-off-by: Rohan Kumar <rohaan@redhat.com>
5e7a97c
to
4b3172c
Compare
|
||
@Test | ||
@DisplayName("when Dockerfile present in project base directory, then generate opinionated ImageConfiguration for Dockerfile") | ||
void simpleDockerfileModeWorksAsExpected(@TempDir File temporaryFolder) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests (task + Mojo) work, but they aren't exactly where they should actually be.
I'll try to give take it for a spin and see if we can make this easier.
df1b6e2
to
9e037e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx!
Signed-off-by: Marc Nuri <marc@marcnuri.com>
9e037e5
to
8aca467
Compare
|
Description
Dockerfile
in project root directory. This is actually a feature called Simple Dockerfile Mode. However, this mutation of ImageConfiguration from withininitImageConfiguration
does not look appropriate. It can be moved to a dedicated generator that will get activated whenDockerfile
is present in project base directory.We also need to adjust the documentation for adding this new generator. I'll do that in a follow up PR.
Type of change
test, version modification, documentation, etc.)
Checklist