From c1a50fcdeb7fa6017c16979c4729a76f3292f7da Mon Sep 17 00:00:00 2001 From: nooras Date: Sun, 8 Oct 2023 19:33:46 +0530 Subject: [PATCH 1/2] Added Cloudian Storage Adapter --- .github/workflows/tests.yml | 2 ++ docker-compose.yml | 4 ++- src/Storage/Device/Cloudian.php | 50 +++++++++++++++++++++++++++ src/Storage/Storage.php | 2 ++ tests/Storage/Device/CloudianTest.php | 34 ++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/Storage/Device/Cloudian.php create mode 100644 tests/Storage/Device/CloudianTest.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 43d7ca7e..42475ae3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,6 +39,8 @@ jobs: WASABI_SECRET: ${{ secrets.WASABI_SECRET }} BACKBLAZE_ACCESS_KEY: ${{ secrets.BACKBLAZE_ACCESS_KEY }} BACKBLAZE_SECRET: ${{ secrets.BACKBLAZE_SECRET }} + CLOUDIAN_ACCESS_KEY: ${{ secrets.CLOUDIAN_ACCESS_KEY }} + CLOUDIAN_SECRET: ${{ secrets.CLOUDIAN_SECRET }} run: | docker compose up -d sleep 10 diff --git a/docker-compose.yml b/docker-compose.yml index 4cd5e9f7..51967c32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,4 +20,6 @@ services: - BACKBLAZE_ACCESS_KEY - BACKBLAZE_SECRET - WASABI_ACCESS_KEY - - WASABI_SECRET \ No newline at end of file + - WASABI_SECRET + - CLOUDIAN_ACCESS_KEY + - CLOUDIAN_SECRET \ No newline at end of file diff --git a/src/Storage/Device/Cloudian.php b/src/Storage/Device/Cloudian.php new file mode 100644 index 00000000..41c85586 --- /dev/null +++ b/src/Storage/Device/Cloudian.php @@ -0,0 +1,50 @@ +headers['host'] = $bucket.'.'.'s3'.'.'.$region.'.cloudian.com'; + } + + /** + * @return string + */ + public function getName(): string + { + return 'Cloudian Storage'; + } + + /** + * @return string + */ + public function getType(): string + { + return Storage::DEVICE_CLOUDIAN; + } + + /** + * @return string + */ + public function getDescription(): string + { + return 'Cloudian Storage'; + } +} diff --git a/src/Storage/Storage.php b/src/Storage/Storage.php index cabd18c8..cf4a346d 100644 --- a/src/Storage/Storage.php +++ b/src/Storage/Storage.php @@ -21,6 +21,8 @@ class Storage const DEVICE_LINODE = 'linode'; + const DEVICE_CLOUDIAN = 'cloudian'; + /** * Devices. * diff --git a/tests/Storage/Device/CloudianTest.php b/tests/Storage/Device/CloudianTest.php new file mode 100644 index 00000000..16250e48 --- /dev/null +++ b/tests/Storage/Device/CloudianTest.php @@ -0,0 +1,34 @@ +root = '/root'; + $key = $_SERVER['CLOUDIAN_ACCESS_KEY'] ?? ''; + $secret = $_SERVER['CLOUDIAN_SECRET'] ?? ''; + $bucket = 'utopia-storage-tests'; + + $this->object = new Cloudian($this->root, $key, $secret, $bucket, Cloudian::EU_CENTRAL_1, Cloudian::ACL_PRIVATE); + } + + protected function getAdapterName(): string + { + return 'Cloudian Storage'; + } + + protected function getAdapterType(): string + { + return $this->object->getType(); + } + + protected function getAdapterDescription(): string + { + return 'Cloudian Storage'; + } +} From 8637c87d200c05435bf252d79b848a1e7e68eac9 Mon Sep 17 00:00:00 2001 From: nooras Date: Thu, 19 Oct 2023 21:17:39 +0530 Subject: [PATCH 2/2] Removed unused import --- src/Storage/Device/Cloudian.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Storage/Device/Cloudian.php b/src/Storage/Device/Cloudian.php index 41c85586..ec88322f 100644 --- a/src/Storage/Device/Cloudian.php +++ b/src/Storage/Device/Cloudian.php @@ -2,8 +2,6 @@ namespace Utopia\Storage\Device; -use Exception; -use Utopia\Storage\Device; use Utopia\Storage\Storage; class Cloudian extends S3