Search in sources :

Example 1 with SubStorage

use of com.artipie.asto.SubStorage in project artipie by artipie.

the class DockerProxy method delegate.

/**
 * Creates Docker proxy repository slice from configuration.
 *
 * @return Docker proxy slice.
 */
private Slice delegate() {
    final Docker proxies = new MultiReadDocker(this.cfg.proxy().remotes().stream().map(remote -> proxy(this.client, remote)).collect(Collectors.toList()));
    Docker docker = this.cfg.storageOpt().<Docker>map(storage -> {
        final AstoDocker local = new AstoDocker(new SubStorage(RegistryRoot.V2, storage));
        return new ReadWriteDocker(new MultiReadDocker(local, proxies), local);
    }).orElse(proxies);
    if (!this.standalone) {
        docker = new TrimmedDocker(docker, this.cfg.name());
    }
    Slice slice = new DockerSlice(docker, new DockerPermissions(this.perms), new BasicAuthScheme(this.auth));
    if (!this.standalone) {
        slice = new DockerRoutingSlice.Reverted(slice);
    }
    return slice;
}
Also used : SubStorage(com.artipie.asto.SubStorage) RepoConfig(com.artipie.repo.RepoConfig) BasicAuthScheme(com.artipie.http.auth.BasicAuthScheme) AstoDocker(com.artipie.docker.asto.AstoDocker) Slice(com.artipie.http.Slice) Permissions(com.artipie.http.auth.Permissions) Publisher(org.reactivestreams.Publisher) Response(com.artipie.http.Response) MultiReadDocker(com.artipie.docker.composite.MultiReadDocker) DockerSlice(com.artipie.docker.http.DockerSlice) Collectors(java.util.stream.Collectors) ByteBuffer(java.nio.ByteBuffer) AuthClientSlice(com.artipie.http.client.auth.AuthClientSlice) TrimmedDocker(com.artipie.docker.http.TrimmedDocker) RegistryRoot(com.artipie.docker.asto.RegistryRoot) CacheDocker(com.artipie.docker.cache.CacheDocker) ReadWriteDocker(com.artipie.docker.composite.ReadWriteDocker) ClientSlices(com.artipie.http.client.ClientSlices) ProxyDocker(com.artipie.docker.proxy.ProxyDocker) ProxyConfig(com.artipie.repo.ProxyConfig) Map(java.util.Map) Authentication(com.artipie.http.auth.Authentication) DockerRoutingSlice(com.artipie.http.DockerRoutingSlice) TrimmedDocker(com.artipie.docker.http.TrimmedDocker) MultiReadDocker(com.artipie.docker.composite.MultiReadDocker) SubStorage(com.artipie.asto.SubStorage) ReadWriteDocker(com.artipie.docker.composite.ReadWriteDocker) AstoDocker(com.artipie.docker.asto.AstoDocker) MultiReadDocker(com.artipie.docker.composite.MultiReadDocker) TrimmedDocker(com.artipie.docker.http.TrimmedDocker) CacheDocker(com.artipie.docker.cache.CacheDocker) ReadWriteDocker(com.artipie.docker.composite.ReadWriteDocker) ProxyDocker(com.artipie.docker.proxy.ProxyDocker) Slice(com.artipie.http.Slice) DockerSlice(com.artipie.docker.http.DockerSlice) AuthClientSlice(com.artipie.http.client.auth.AuthClientSlice) DockerRoutingSlice(com.artipie.http.DockerRoutingSlice) DockerSlice(com.artipie.docker.http.DockerSlice) BasicAuthScheme(com.artipie.http.auth.BasicAuthScheme) AstoDocker(com.artipie.docker.asto.AstoDocker) DockerRoutingSlice(com.artipie.http.DockerRoutingSlice)

Example 2 with SubStorage

use of com.artipie.asto.SubStorage in project maven-adapter by artipie.

the class AstoMaven method moveToTheRepository.

/**
 * Moves artifacts from temp location to repository.
 * @param upload Upload temp location
 * @param target Repository
 * @param artifact Artifact repository location
 * @return Completion action
 */
private CompletableFuture<Void> moveToTheRepository(final Key upload, final Storage target, final Key artifact) {
    final Storage sub = new SubStorage(new Key.From(upload, PutMetadataSlice.SUB_META), this.storage);
    final Storage subversion = new SubStorage(upload.parent().get(), this.storage);
    return sub.list(Key.ROOT).thenCompose(list -> new Copy(sub, list.stream().filter(key -> key.string().contains(AstoMaven.MAVEN_META)).collect(Collectors.toList())).copy(new SubStorage(artifact, target))).thenCompose(nothing -> subversion.list(Key.ROOT).thenCompose(list -> new Copy(subversion, list.stream().filter(key -> !key.string().contains(String.format("/%s/", PutMetadataSlice.SUB_META))).collect(Collectors.toList())).copy(new SubStorage(artifact, target))));
}
Also used : Copy(com.artipie.asto.Copy) Maven(com.artipie.maven.Maven) SubStorage(com.artipie.asto.SubStorage) XMLDocument(com.jcabi.xml.XMLDocument) Collection(java.util.Collection) KeyLastPart(com.artipie.asto.ext.KeyLastPart) Directives(org.xembly.Directives) PutMetadataSlice(com.artipie.maven.http.PutMetadataSlice) CompletableFuture(java.util.concurrent.CompletableFuture) Key(com.artipie.asto.Key) Collectors(java.util.stream.Collectors) PublisherAs(com.artipie.asto.ext.PublisherAs) CompletionStage(java.util.concurrent.CompletionStage) Storage(com.artipie.asto.Storage) MavenMetadata(com.artipie.maven.metadata.MavenMetadata) SubStorage(com.artipie.asto.SubStorage) Storage(com.artipie.asto.Storage) Copy(com.artipie.asto.Copy) SubStorage(com.artipie.asto.SubStorage) Key(com.artipie.asto.Key)

Example 3 with SubStorage

use of com.artipie.asto.SubStorage in project artipie by artipie.

the class SliceFromConfig method build.

/**
 * Find a slice implementation for config.
 *
 * @param http HTTP client
 * @param settings Artipie settings
 * @param auth Authentication
 * @param cfg Repository config
 * @param aliases Storage aliases
 * @param standalone Standalone flag
 * @return Slice completionStage
 * @checkstyle LineLengthCheck (150 lines)
 * @checkstyle ExecutableStatementCountCheck (100 lines)
 * @checkstyle JavaNCSSCheck (500 lines)
 * @checkstyle MethodLengthCheck (500 lines)
 */
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.ExcessiveMethodLength", "PMD.AvoidDuplicateLiterals", "PMD.NcssCount" })
static Slice build(final ClientSlices http, final Settings settings, final Authentication auth, final RepoConfig cfg, final StorageAliases aliases, final boolean standalone) {
    final Slice slice;
    final Permissions permissions = new LoggingPermissions(cfg.permissions().orElse(Permissions.FREE));
    switch(cfg.type()) {
        case "file":
            slice = trimIfNotStandalone(settings, standalone, new FilesSlice(cfg.storage(), permissions, auth));
            break;
        case "file-proxy":
            slice = trimIfNotStandalone(settings, standalone, new FileProxy(http, cfg));
            break;
        case "npm":
            slice = trimIfNotStandalone(settings, standalone, new NpmSlice(cfg.url(), cfg.storage(), permissions, auth));
            break;
        case "gem":
            slice = trimIfNotStandalone(settings, standalone, new GemSlice(cfg.storage()));
            break;
        case "helm":
            slice = trimIfNotStandalone(settings, standalone, new HelmSlice(cfg.storage(), cfg.path(), permissions, auth));
            break;
        case "rpm":
            slice = trimIfNotStandalone(settings, standalone, new RpmSlice(cfg.storage(), permissions, auth, new com.artipie.rpm.RepoConfig.FromYaml(cfg.settings())));
            break;
        case "php":
            slice = trimIfNotStandalone(settings, standalone, new PhpComposer(new AstoRepository(cfg.storage(), Optional.of(cfg.url().toString()))));
            break;
        case "php-proxy":
            slice = trimIfNotStandalone(settings, standalone, new ComposerProxy(http, cfg));
            break;
        case "nuget":
            slice = trimIfNotStandalone(settings, standalone, new NuGet(cfg.url(), new com.artipie.nuget.AstoRepository(cfg.storage()), permissions, auth));
            break;
        case "maven":
            slice = trimIfNotStandalone(settings, standalone, new MavenSlice(cfg.storage(), permissions, auth));
            break;
        case "maven-proxy":
            slice = trimIfNotStandalone(settings, standalone, new MavenProxy(http, cfg));
            break;
        case "maven-group":
            slice = trimIfNotStandalone(settings, standalone, new GroupSlice(cfg.settings().orElseThrow().yamlSequence("repositories").values().stream().map(node -> node.asScalar().value()).map(name -> new AsyncSlice(new RepositoriesFromStorage(http, settings.storage()).config(name).thenApply(sub -> new SliceFromConfig(http, settings, sub, aliases, standalone)))).collect(Collectors.toList())));
            break;
        case "go":
            slice = trimIfNotStandalone(settings, standalone, new GoSlice(cfg.storage(), permissions, auth));
            break;
        case "npm-proxy":
            slice = new NpmProxySlice(cfg.path(), new NpmProxy(URI.create(cfg.settings().orElseThrow().yamlMapping("remote").string("url")), cfg.storage(), http));
            break;
        case "pypi":
            slice = trimIfNotStandalone(settings, standalone, new PySlice(cfg.storage(), permissions, auth));
            break;
        case "pypi-proxy":
            slice = trimIfNotStandalone(settings, standalone, new PypiProxy(http, cfg));
            break;
        case "docker":
            final Docker docker = new AstoDocker(new SubStorage(RegistryRoot.V2, cfg.storage()));
            if (standalone) {
                slice = new DockerSlice(docker, new DockerPermissions(permissions), new BasicAuthScheme(auth));
            } else {
                slice = new DockerRoutingSlice.Reverted(new DockerSlice(new TrimmedDocker(docker, cfg.name()), new DockerPermissions(permissions), new BasicAuthScheme(auth)));
            }
            break;
        case "docker-proxy":
            slice = new DockerProxy(http, standalone, cfg, permissions, auth);
            break;
        case "deb":
            slice = trimIfNotStandalone(settings, standalone, new DebianSlice(cfg.storage(), permissions, auth, new Config.FromYaml(cfg.name(), cfg.settings(), settings.storage())));
            break;
        case "conda":
            slice = trimIfNotStandalone(settings, standalone, new CondaSlice(cfg.storage(), permissions, auth, cfg.url().toString(), new CondaConfig(cfg.settings()).authTokenTtl()));
            break;
        default:
            throw new IllegalStateException(String.format("Unsupported repository type '%s", cfg.type()));
    }
    return new ContinueSlice(cfg.contentLengthMax().<Slice>map(limit -> new ContentLengthRestriction(slice, limit)).orElse(slice));
}
Also used : Config(com.artipie.debian.Config) RepoConfig(com.artipie.repo.RepoConfig) AstoDocker(com.artipie.docker.asto.AstoDocker) Slice(com.artipie.http.Slice) Permissions(com.artipie.http.auth.Permissions) GoSlice(com.artipie.http.GoSlice) GroupSlice(com.artipie.http.group.GroupSlice) DockerSlice(com.artipie.docker.http.DockerSlice) HelmSlice(com.artipie.helm.http.HelmSlice) ComposerProxy(com.artipie.php.ComposerProxy) RegistryRoot(com.artipie.docker.asto.RegistryRoot) DockerProxy(com.artipie.docker.DockerProxy) GemSlice(com.artipie.gem.http.GemSlice) MavenProxy(com.artipie.maven.MavenProxy) DockerPermissions(com.artipie.docker.DockerPermissions) TrimPathSlice(com.artipie.http.slice.TrimPathSlice) PhpComposer(com.artipie.composer.http.PhpComposer) URI(java.net.URI) FilesSlice(com.artipie.files.FilesSlice) Authentication(com.artipie.http.auth.Authentication) DockerRoutingSlice(com.artipie.http.DockerRoutingSlice) PypiProxy(com.artipie.pypi.PypiProxy) CondaConfig(com.artipie.conda.CondaConfig) SubStorage(com.artipie.asto.SubStorage) BasicAuthScheme(com.artipie.http.auth.BasicAuthScheme) NpmSlice(com.artipie.npm.http.NpmSlice) AsyncSlice(com.artipie.http.async.AsyncSlice) NpmProxy(com.artipie.npm.proxy.NpmProxy) CondaSlice(com.artipie.conda.http.CondaSlice) Docker(com.artipie.docker.Docker) Collectors(java.util.stream.Collectors) LoggingAuth(com.artipie.auth.LoggingAuth) DebianSlice(com.artipie.debian.http.DebianSlice) PySlice(com.artipie.pypi.http.PySlice) TrimmedDocker(com.artipie.docker.http.TrimmedDocker) NuGet(com.artipie.nuget.http.NuGet) ClientSlices(com.artipie.http.client.ClientSlices) MavenSlice(com.artipie.maven.http.MavenSlice) NpmProxySlice(com.artipie.npm.proxy.http.NpmProxySlice) FileProxy(com.artipie.file.FileProxy) Optional(java.util.Optional) AstoRepository(com.artipie.composer.AstoRepository) RpmSlice(com.artipie.rpm.http.RpmSlice) FilesSlice(com.artipie.files.FilesSlice) SubStorage(com.artipie.asto.SubStorage) NpmProxy(com.artipie.npm.proxy.NpmProxy) DockerPermissions(com.artipie.docker.DockerPermissions) AstoDocker(com.artipie.docker.asto.AstoDocker) Docker(com.artipie.docker.Docker) TrimmedDocker(com.artipie.docker.http.TrimmedDocker) Permissions(com.artipie.http.auth.Permissions) DockerPermissions(com.artipie.docker.DockerPermissions) AstoRepository(com.artipie.composer.AstoRepository) FileProxy(com.artipie.file.FileProxy) BasicAuthScheme(com.artipie.http.auth.BasicAuthScheme) NpmSlice(com.artipie.npm.http.NpmSlice) RpmSlice(com.artipie.rpm.http.RpmSlice) DockerRoutingSlice(com.artipie.http.DockerRoutingSlice) DockerProxy(com.artipie.docker.DockerProxy) CondaSlice(com.artipie.conda.http.CondaSlice) GemSlice(com.artipie.gem.http.GemSlice) ComposerProxy(com.artipie.php.ComposerProxy) HelmSlice(com.artipie.helm.http.HelmSlice) MavenProxy(com.artipie.maven.MavenProxy) Slice(com.artipie.http.Slice) GoSlice(com.artipie.http.GoSlice) GroupSlice(com.artipie.http.group.GroupSlice) DockerSlice(com.artipie.docker.http.DockerSlice) HelmSlice(com.artipie.helm.http.HelmSlice) GemSlice(com.artipie.gem.http.GemSlice) TrimPathSlice(com.artipie.http.slice.TrimPathSlice) FilesSlice(com.artipie.files.FilesSlice) DockerRoutingSlice(com.artipie.http.DockerRoutingSlice) NpmSlice(com.artipie.npm.http.NpmSlice) AsyncSlice(com.artipie.http.async.AsyncSlice) CondaSlice(com.artipie.conda.http.CondaSlice) DebianSlice(com.artipie.debian.http.DebianSlice) PySlice(com.artipie.pypi.http.PySlice) MavenSlice(com.artipie.maven.http.MavenSlice) NpmProxySlice(com.artipie.npm.proxy.http.NpmProxySlice) RpmSlice(com.artipie.rpm.http.RpmSlice) DebianSlice(com.artipie.debian.http.DebianSlice) Config(com.artipie.debian.Config) RepoConfig(com.artipie.repo.RepoConfig) CondaConfig(com.artipie.conda.CondaConfig) PhpComposer(com.artipie.composer.http.PhpComposer) NpmProxySlice(com.artipie.npm.proxy.http.NpmProxySlice) PySlice(com.artipie.pypi.http.PySlice) AstoDocker(com.artipie.docker.asto.AstoDocker) GoSlice(com.artipie.http.GoSlice) TrimmedDocker(com.artipie.docker.http.TrimmedDocker) GroupSlice(com.artipie.http.group.GroupSlice) AsyncSlice(com.artipie.http.async.AsyncSlice) NuGet(com.artipie.nuget.http.NuGet) CondaConfig(com.artipie.conda.CondaConfig) RepoConfig(com.artipie.repo.RepoConfig) PypiProxy(com.artipie.pypi.PypiProxy) MavenSlice(com.artipie.maven.http.MavenSlice) DockerSlice(com.artipie.docker.http.DockerSlice)

Aggregations

SubStorage (com.artipie.asto.SubStorage)3 Collectors (java.util.stream.Collectors)3 AstoDocker (com.artipie.docker.asto.AstoDocker)2 RegistryRoot (com.artipie.docker.asto.RegistryRoot)2 DockerSlice (com.artipie.docker.http.DockerSlice)2 TrimmedDocker (com.artipie.docker.http.TrimmedDocker)2 DockerRoutingSlice (com.artipie.http.DockerRoutingSlice)2 Slice (com.artipie.http.Slice)2 Authentication (com.artipie.http.auth.Authentication)2 BasicAuthScheme (com.artipie.http.auth.BasicAuthScheme)2 Permissions (com.artipie.http.auth.Permissions)2 ClientSlices (com.artipie.http.client.ClientSlices)2 Copy (com.artipie.asto.Copy)1 Key (com.artipie.asto.Key)1 Storage (com.artipie.asto.Storage)1 KeyLastPart (com.artipie.asto.ext.KeyLastPart)1 PublisherAs (com.artipie.asto.ext.PublisherAs)1 LoggingAuth (com.artipie.auth.LoggingAuth)1 AstoRepository (com.artipie.composer.AstoRepository)1 PhpComposer (com.artipie.composer.http.PhpComposer)1