Search in sources :

Example 1 with DockerImageDownloader

use of com.aws.greengrass.componentmanager.plugins.docker.DockerImageDownloader in project aws-greengrass-nucleus by aws-greengrass.

the class ArtifactDownloaderFactory method getArtifactDownloader.

/**
 * Return the artifact downloader instance.
 * @param identifier componentIdentifier
 * @param artifact componentArtifact
 * @param artifactDir directory to download artifact to
 * @return Artifact downloader
 * @throws PackageLoadingException throw if URI scheme not supported
 * @throws InvalidArtifactUriException throw if s3 url not valid
 */
public ArtifactDownloader getArtifactDownloader(ComponentIdentifier identifier, ComponentArtifact artifact, Path artifactDir) throws PackageLoadingException, InvalidArtifactUriException {
    URI artifactUri = artifact.getArtifactUri();
    String scheme = artifactUri.getScheme() == null ? null : artifactUri.getScheme().toUpperCase();
    if (GREENGRASS_SCHEME.equals(scheme)) {
        return new GreengrassRepositoryDownloader(clientFactory, identifier, artifact, artifactDir, componentStore);
    }
    if (S3_SCHEME.equals(scheme)) {
        return new S3Downloader(s3ClientFactory, identifier, artifact, artifactDir);
    }
    // an artifact downloader can register itself and be discoverable here.
    if (DOCKER_SCHEME.equals(scheme)) {
        return new DockerImageDownloader(identifier, artifact, artifactDir, context);
    }
    throw new PackageLoadingException(String.format("artifact URI scheme %s is not supported yet", scheme));
}
Also used : DockerImageDownloader(com.aws.greengrass.componentmanager.plugins.docker.DockerImageDownloader) PackageLoadingException(com.aws.greengrass.componentmanager.exceptions.PackageLoadingException) URI(java.net.URI)

Aggregations

PackageLoadingException (com.aws.greengrass.componentmanager.exceptions.PackageLoadingException)1 DockerImageDownloader (com.aws.greengrass.componentmanager.plugins.docker.DockerImageDownloader)1 URI (java.net.URI)1