-
Notifications
You must be signed in to change notification settings - Fork 88
Quack Patch enhancements #1763
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
base: master
Are you sure you want to change the base?
Quack Patch enhancements #1763
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,22 @@ | ||
| package com.blackduck.integration.detect.workflow.diagnostic; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.SortedMap; | ||
|
|
||
| import org.apache.commons.io.FileUtils; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import com.blackduck.integration.configuration.config.PropertyConfiguration; | ||
| import com.blackduck.integration.detect.configuration.DetectInfo; | ||
| import com.blackduck.integration.detect.configuration.DetectProperties; | ||
| import com.blackduck.integration.detect.workflow.DetectRunId; | ||
| import static com.blackduck.integration.detect.workflow.componentlocationanalysis.GenerateComponentLocationAnalysisOperation.QUACKPATCH_SUBDIRECTORY_NAME; | ||
| import com.blackduck.integration.detect.workflow.event.EventSystem; | ||
| import com.blackduck.integration.detect.workflow.file.DirectoryManager; | ||
|
|
||
|
|
@@ -134,9 +138,24 @@ public void appendBlackDuckServerProperties(Map<String, String> serverProperties | |
| } | ||
|
|
||
| private boolean createZip() { | ||
| // If quack patch is enabled, then add quack patch output directory to the zip | ||
| if (propertyConfiguration.getValueOrDefault(DetectProperties.DETECT_QUACK_PATCH_ENABLED)) { | ||
| String quackPatchOutputDirPath = propertyConfiguration.getValueOrDefault(DetectProperties.DETECT_QUACK_PATCH_OUTPUT); | ||
| // If quack patch output path is customized, then explicitly include it in the diagnostic zip. Otherwise, default behaviour will automatically pack it. | ||
| if (!quackPatchOutputDirPath.isEmpty()) { | ||
| quackPatchOutputDirPath = quackPatchOutputDirPath + File.separator + QUACKPATCH_SUBDIRECTORY_NAME; | ||
| logger.info("Adding quack patch output dir {} to the diagnostic zip.", quackPatchOutputDirPath); | ||
| // Copy directory quackPatchOutputDirPath to directoryManager.getRunsOutputDirectory() | ||
| try { | ||
| FileUtils.copyDirectory(new File(quackPatchOutputDirPath), new File(directoryManager.getScanOutputDirectory().getAbsolutePath() + File.separator + QUACKPATCH_SUBDIRECTORY_NAME)); | ||
| } catch (IOException e) { | ||
| logger.error("Failed to copy quack patch output directory to runs directory. Error: {}", e.getMessage()); | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+142
to
+156
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If quack patch output path is not set, output will be written to Note: Diagnostics archive process was adding the files based on its path. If the target file is outside runs dir context, compress logic is trying to add it as a relative path (e.g. |
||
| List<File> directoriesToCompress = new ArrayList<>(); | ||
| directoriesToCompress.add(directoryManager.getRunHomeDirectory()); | ||
|
|
||
| DiagnosticZipCreator zipper = new DiagnosticZipCreator(); | ||
| return zipper.createDiagnosticZip(detectRunId.getRunId(), directoryManager.getRunsOutputDirectory(), directoriesToCompress); | ||
| } | ||
|
|
||
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.
Unable to use the helper function (
getQuackPatchOutputDirectoryfromdetectConfigurationFactory) to get the quack patch output path here due to missing config context. Hence, the duplication of code.