Search in sources :

Example 1 with DownloadResponse

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());
}
Also used : FileSpec(org.jfrog.filespecs.FileSpec) DownloadResponse(org.jfrog.build.client.DownloadResponse) JsonUtils.toJsonString(org.jfrog.build.extractor.clientConfiguration.util.JsonUtils.toJsonString) FilesGroup(org.jfrog.filespecs.entities.FilesGroup) CreateReleaseBundleRequest(org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest) Test(org.testng.annotations.Test)

Example 2 with DownloadResponse

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);
}
Also used : DownloadResponse(org.jfrog.build.client.DownloadResponse)

Aggregations

DownloadResponse (org.jfrog.build.client.DownloadResponse)2 CreateReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.CreateReleaseBundleRequest)1 JsonUtils.toJsonString (org.jfrog.build.extractor.clientConfiguration.util.JsonUtils.toJsonString)1 FileSpec (org.jfrog.filespecs.FileSpec)1 FilesGroup (org.jfrog.filespecs.entities.FilesGroup)1 Test (org.testng.annotations.Test)1