Search in sources :

Example 1 with EtcdStorage

use of com.artipie.asto.etcd.EtcdStorage in project front by artipie.

the class YamlStorage method storage.

/**
 * Provides a storage.
 *
 * @return Storage instance.
 */
public Storage storage() {
    @SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
    final String type = strict.string("type");
    final Storage storage;
    if ("fs".equals(type)) {
        storage = new FileStorage(Path.of(strict.string("path")));
    } else if ("s3".equals(type)) {
        storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
    } else if ("etcd".equals(type)) {
        storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
    } else {
        throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
    }
    return storage;
}
Also used : StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) S3Storage(com.artipie.asto.s3.S3Storage) FileStorage(com.artipie.asto.fs.FileStorage) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) S3Storage(com.artipie.asto.s3.S3Storage)

Example 2 with EtcdStorage

use of com.artipie.asto.etcd.EtcdStorage in project artipie by artipie.

the class YamlStorage method storage.

/**
 * Provides a storage.
 *
 * @return Storage instance.
 */
public Storage storage() {
    @SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
    final String type = strict.string("type");
    final Storage storage;
    if ("fs".equals(type)) {
        storage = new FileStorage(Path.of(strict.string("path")));
    } else if ("s3".equals(type)) {
        storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
    } else if ("etcd".equals(type)) {
        storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
    } else {
        throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
    }
    return storage;
}
Also used : StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) S3Storage(com.artipie.asto.s3.S3Storage) FileStorage(com.artipie.asto.fs.FileStorage) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) S3Storage(com.artipie.asto.s3.S3Storage)

Aggregations

StrictYamlMapping (com.amihaiemil.eoyaml.StrictYamlMapping)2 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)2 Storage (com.artipie.asto.Storage)2 EtcdStorage (com.artipie.asto.etcd.EtcdStorage)2 FileStorage (com.artipie.asto.fs.FileStorage)2 S3Storage (com.artipie.asto.s3.S3Storage)2