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 no-cache functionality into Buildx. #1717

Merged
merged 3 commits into from
Nov 9, 2023
Merged

Conversation

tadgh
Copy link
Contributor

@tadgh tadgh commented Nov 4, 2023

Heya, I noticed that running a multiplatform build (which uses buildx) ignores the configured no-cache directive. e.g. this pom.xml

						<configuration>

							<pullRegistry>docker.io</pullRegistry>
							<pushRegistry>${docker.registry}</pushRegistry>

							<images>
								<image>
									<name>blah</name>
									<build>
										<noCache>true</noCache>
										<buildx>
											<platforms>
												<platform>linux/arm64</platform>
												<platform>linux/amd64</platform>
											</platforms>
										</buildx>
										<contextDir>${project.basedir}/target/dockercontext</contextDir>
									</build>
								</image>
							</images>
						</configuration>

was not actually passing down --no-cache to the buildx command.

This PR causes the top-level build option to be passed down to buildx if buildx happens to be used. Note that the check for no-cache is copy-pasted from your existing implementation. I didn't want to do guesswork about where utility classes should live. If you'd like me to move it, please let me know where to move it to. I would truly appreciate it if this could be merged and released, as I'm using a fork at my organization at the moment 😅

Cheers,

--Gary

Signed-off-by: Gary Graham <garygrantgraham@gmail.com>
Copy link

codecov bot commented Nov 4, 2023

Codecov Report

Merging #1717 (2c48d52) into master (f228f64) will increase coverage by 0.00%.
The diff coverage is 70.00%.

❗ Current head 2c48d52 differs from pull request most recent head 5eb4594. Consider uploading reports for the commit 5eb4594 to get more accurate results

@@            Coverage Diff            @@
##             master    #1717   +/-   ##
=========================================
  Coverage     65.11%   65.11%           
- Complexity     2253     2254    +1     
=========================================
  Files           172      172           
  Lines         10109    10111    +2     
  Branches       1390     1391    +1     
=========================================
+ Hits           6582     6584    +2     
  Misses         2977     2977           
  Partials        550      550           
Files Coverage Δ
.../io/fabric8/maven/docker/service/BuildService.java 64.14% <100.00%> (+0.18%) ⬆️
...io/fabric8/maven/docker/service/BuildXService.java 75.97% <100.00%> (+0.27%) ⬆️
...a/io/fabric8/maven/docker/config/ConfigHelper.java 89.39% <57.14%> (-3.83%) ⬇️

@rhuss
Copy link
Collaborator

rhuss commented Nov 5, 2023

Thanks for the PR! It looks good to me, but as you said, we should move it to an utility method and maybe even consider to finally remove the docker.nocache option since this was deprecated since quite some time (I think it even has been already removed from the documentation).

@rohanKanojia since I'm quite disconnected from the codebase since quite some time, could you propose a proper location for a static method to this 'noCache' check ?

@rohanKanojia
Copy link
Member

Shall we try to move this method as a static method in io.fabric8.maven.docker.config.ConfigHelper? Otherwise we can also create a new class ImageConfigurationUtil or ImageConfigurationHelper for moving this method?

@tadgh
Copy link
Contributor Author

tadgh commented Nov 6, 2023

I've migrated the method and renamed it a bit, hopefully that is alright. Let me know if there's anything else I can do. Cheers

@rohanKanojia
Copy link
Member

Shall we mention nocache functionality in buildx documentation as well?

@tadgh
Copy link
Contributor Author

tadgh commented Nov 6, 2023

Shall we mention nocache functionality in buildx documentation as well?

It's documented in the <build> section, and <buildx> is a subsection. It feels to me as though the docs in the top-level build section may be enough, but maybe it's worth a specific callout? It isn't really a new option, its more that an option that previously existed wasn't being applied correctly. Happy to go either way on this, if you want to guide me on what type of docs you want written.

Also, I've added a changelog.

Copy link

sonarcloud bot commented Nov 7, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

65.0% 65.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.21) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@rohanKanojia
Copy link
Member

It isn't really a new option, its more that an option that previously existed wasn't being applied correctly.

Umm, that makes sense. As a user, I would expect existing option to work with buildx too

@tadgh
Copy link
Contributor Author

tadgh commented Nov 9, 2023

Thanks much! Excited to get this merged :)

@rohanKanojia rohanKanojia merged commit 8e0e480 into fabric8io:master Nov 9, 2023
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants