Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Exoscale adapter #99

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
env:
DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }}
DO_SECRET: ${{ secrets.DO_SECRET }}
EXOSCALE_ACCESS_KEY: ${{ secrets.EXOSCALE_ACCESS_KEY }}
EXOSCALE_SECRET: ${{ secrets.EXOSCALE_SECRET }}
LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }}
LINODE_SECRET: ${{ secrets.LINODE_SECRET }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
Expand Down Expand Up @@ -58,7 +60,7 @@ jobs:
strategy:
fail-fast: false
matrix:
devices: [BackblazeTest, DOSpacesTest, LinodeTest, LocalTest, S3Test, WasabiTest]
devices: [BackblazeTest, DOSpacesTest, ExoscaleTest,LinodeTest, LocalTest, S3Test, WasabiTest]
Atharva1723 marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: checkout
Expand All @@ -67,6 +69,8 @@ jobs:
env:
DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }}
DO_SECRET: ${{ secrets.DO_SECRET }}
EXOSCALE_ACCESS_KEY: ${{ secrets.EXOSCALE_ACCESS_KEY }}
EXOSCALE_SECRET: ${{ secrets.EXOSCALE_SECRET }}
LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }}
LINODE_SECRET: ${{ secrets.LINODE_SECRET }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
Expand Down
66 changes: 66 additions & 0 deletions src/Storage/Device/Exoscale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Storage;

class Exoscale extends S3
{
/**
* Exoscale Regions constants
* https://community.exoscale.com/documentation/platform/exoscale-datacenter-zones/
*/
stnguyen90 marked this conversation as resolved.
Show resolved Hide resolved
const CH_GVA_2 = 'ch-gva-2';

const CH_DK_2 = 'ch-dk-2';

const DE_FRA_1 = 'de-fra-1';

const DE_MUC_1 = 'de-muc-1';

const AT_VIE_1 = 'at-vie-1';

const AT_VIE_2 = 'at-vie-2';

const BG_SOF_1 = 'bg-sof-1';

/**
* Exoscale Constructor
*
* @param string $root
* @param string $apiKey
* @param string $apiSecret
* @param string $bucket
* @param string $region
* @param string $acl
*/
public function __construct(string $root, string $apiKey, string $apiSecret, string $bucket, string $region = self::CH_GVA_2, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $apiKey, $apiSecret, $bucket, $region, $acl);
$this->headers['host'] = $bucket.'.'.$region.'.'.'exo.io';
}

/**
* @return string
*/
public function getName(): string
{
return 'Exoscale Simple Object Storage';
}

/**
* @return string
*/
public function getDescription(): string
{
return 'Exoscale Simple Object Storage';
}

/**
* @return string
*/
public function getType(): string
{
return Storage::DEVICE_EXOSCALE;
}
}
2 changes: 2 additions & 0 deletions src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Storage

const DEVICE_LINODE = 'linode';

const DEVICE_EXOSCALE = 'exoscale';

/**
* Devices.
*
Expand Down
34 changes: 34 additions & 0 deletions tests/Storage/Device/ExoscaleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Utopia\Tests\Storage\Device;

use Utopia\Storage\Device\Exoscale;
use Utopia\Tests\Storage\S3Base;

class ExoscaleTest extends S3Base
{
protected function init(): void
{
$this->root = '/root';
$apiKey = $_SERVER['EXOSCALE_ACCESS_KEY'] ?? '';
$apiSecret = $_SERVER['EXOSCALE_SECRET'] ?? '';
$bucket = 'storage-test';

$this->object = new Exoscale($this->root, $apiKey, $apiSecret, $bucket, Exoscale::CH_GVA_2, Exoscale::ACL_PRIVATE);
}

protected function getAdapterName(): string
{
return 'Exoscale Simple Object Storage';
}

protected function getAdapterType(): string
{
return $this->object->getType();
}

protected function getAdapterDescription(): string
{
return 'Exoscale Simple Object Storage';
}
}
Loading