-
Notifications
You must be signed in to change notification settings - Fork 485
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
feat (jkube-kit/common) : Add CliDownloaderUtil to download cli binaries (#2454) #2476
Conversation
Eclipse JKube CI ReportStarted new GH workflow run for #2476 (2023-11-30T12:14:57Z) ⚙️ JKube E2E Tests (7046183039)
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2476 +/- ##
============================================
+ Coverage 59.36% 68.95% +9.59%
- Complexity 4586 4832 +246
============================================
Files 500 474 -26
Lines 21211 19143 -2068
Branches 2830 2492 -338
============================================
+ Hits 12591 13200 +609
+ Misses 7370 4743 -2627
+ Partials 1250 1200 -50 ☔ View full report in Codecov by Sentry. |
fa43af8
to
b3342b0
Compare
b3342b0
to
cb67e87
Compare
a75361d
to
ce9ee5d
Compare
public class CliDownloaderUtil { | ||
private CliDownloaderUtil() { } | ||
|
||
public static String downloadCli(String baseDownloadUrl, String cliBinaryPrefix, String cliArtifactName, File outputDirectory) 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.
I'm still not sure why we need to compute the final URI from different components.
Also, I don't understand why the return type is a String instead of a Path or a File.
Some Javadoc to document the method would be nice too.
import static org.apache.commons.io.FilenameUtils.removeExtension; | ||
import static org.eclipse.jkube.kit.common.archive.ArchiveDecompressor.extractArchive; | ||
|
||
public class CliDownloaderUtil { |
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.
What is Cli in this context?
Is this class suppose to help download any kind of CLI tool?
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.
Is this comment regarding naming of class or to add javadocs?
private static String getCliBinaryPathFromExtractedDir(File targetExtractionDir, String binaryPrefix) { | ||
String cliPath = null; | ||
File[] cliArtifactList = targetExtractionDir.listFiles(f -> f.getName().startsWith(binaryPrefix)); | ||
if (cliArtifactList != null && cliArtifactList.length >= 1) { | ||
cliPath = cliArtifactList[0].getAbsolutePath(); | ||
} | ||
return cliPath; | ||
} |
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.
Is this behavior consistent for any CLI we decide to download using this util 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.
Shall we check if file is executable rather than name?
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 was trying with canExecute
fileter but it doesn't seem to work. We seem to be losing permissions while decompressing archive .
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.
There is also option to select file with largest size.
9acda06
to
d925864
Compare
…ad archives (eclipse-jkube#2454) + Refactor IoUtil.download method to be able to extract response body for further consumption + Add IoUtil.downloadArchive method to download and extract archive to specified folder Signed-off-by: Rohan Kumar <rohaan@redhat.com>
d925864
to
00bc529
Compare
Kudos, SonarCloud Quality Gate passed! |
Description
Related to #2454
Add CliDownloaderUtil to download CLI binaries from remote sources.
Type of change
test, version modification, documentation, etc.)
Checklist