use of org.jfrog.build.client.DownloadResponse in project build-info by JFrogDev.
the class RemoteDistributionManagerTest method distributeWithMappingTest.
@Test
public void distributeWithMappingTest() throws IOException {
// Create a release bundle with path mapping
String fileName = uploadFile();
FileSpec fileSpec = new FileSpec();
FilesGroup filesGroup = new FilesGroup().setPattern(localRepo1 + "/data/(*)").setTarget(localRepo2 + "/data2/{1}");
fileSpec.addFilesGroup(filesGroup);
CreateReleaseBundleRequest request = new CreateReleaseBundleRequest.Builder(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION).spec(fileSpec).signImmediately(true).build();
distributionManager.createReleaseBundle(request);
// Distribute the release bundle
distributionManager.distributeReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, true, createDistributionRequest());
// Download the file from the new path
DownloadResponse downloadResponse = artifactoryManager.download(localRepo2 + "/data2/" + fileName);
assertTrue(StringUtils.isNotBlank(downloadResponse.getContent()));
// Delete release bundle
distributionManager.deleteReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, true, createDeletionRequest());
}
use of org.jfrog.build.client.DownloadResponse in project build-info by JFrogDev.
the class DockerImage method checkAndSetManifestAndImagePathCandidates.
/**
* Check if the provided manifestPath is correct by comparing the SHA256 of the image or of the manifest.
* Set the manifest and imagePath in case of the correct manifest.
* Also, if manifestSha256 is provided, set the actual imageId in case of the correct manifest.
*/
private void checkAndSetManifestAndImagePathCandidates(String candidateManifestPath, ArtifactoryManager artifactoryManager, Log logger) throws IOException {
Pair<DownloadResponse, String> candidateDetails = getManifestFromArtifactory(artifactoryManager, candidateManifestPath, logger);
DownloadResponse downloadResponse = candidateDetails.getLeft();
String manifestContent = downloadResponse.getContent();
String manifestPath = candidateDetails.getRight();
if (StringUtils.isNotBlank(manifestSha256)) {
// This scenario is used for Kaniko and JIB.
if (!checkDownloadedManifest(downloadResponse, manifestPath)) {
// The downloaded manifest is not the expected one.
return;
}
// Extract the image ID from the downloaded manifest.
imageId = DockerUtils.getConfigDigest(manifestContent);
} else if (!DockerUtils.getConfigDigest(manifestContent).equals(imageId)) {
// The downloaded manifest does not contain the expected image SHA256
return;
}
manifest = manifestContent;
imagePath = manifestPath;
loadLayers(manifestPath);
}
Aggregations