-
Notifications
You must be signed in to change notification settings - Fork 62
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
adds ceph adapter file and tests #88
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Utopia\Storage\Device; | ||
|
||
use Utopia\Storage\Storage; | ||
|
||
class Ceph extends S3 | ||
{ | ||
/** | ||
* Regions constants | ||
*/ | ||
const US_EAST_1 = 'us-east-1'; | ||
|
||
const US_EAST_2 = 'us-east-2'; | ||
|
||
const US_WEST_1 = 'us-west-1'; | ||
|
||
const US_WEST_2 = 'us-west-2'; | ||
|
||
/** | ||
* Ceph Constructor | ||
*/ | ||
public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $cephHost, string $region = self::US_WEST_001, string $acl = self::ACL_PRIVATE) | ||
{ | ||
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl); | ||
$this->headers['host'] = $cephHost; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'Ceph Storage'; | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return 'Ceph Storage'; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return Storage::DEVICE_CEPH; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ class Storage | |
|
||
const DEVICE_LINODE = 'linode'; | ||
|
||
const DEVICE_CEPH = 'ceph'; | ||
|
||
/** | ||
* Devices. | ||
* | ||
|
@@ -36,8 +38,6 @@ class Storage | |
* Add device by name | ||
* | ||
* @param string $name | ||
* @param Device $device | ||
* @return void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why were these removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I'm running composer lint these changes are automatically being made. Should I undo it? Because then the tests will fail right? |
||
* | ||
* @throws Exception | ||
*/ | ||
|
@@ -83,7 +83,6 @@ public static function exists($name) | |
* | ||
* Based on: https://stackoverflow.com/a/38659168/2299554 | ||
* | ||
* @param int $bytes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I'm running composer lint these changes are automatically being made. Should I undo it? Because then the tests will fail right? |
||
* @param int $decimals | ||
* @param string $system | ||
* @return string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Utopia\Tests\Storage\Device; | ||
|
||
use Utopia\Storage\Device\Ceph; | ||
use Utopia\Tests\Storage\S3Base; | ||
|
||
class BackblazeTest extends S3Base | ||
{ | ||
protected function init(): void | ||
{ | ||
$this->root = '/root'; | ||
$key = $_SERVER['CEPH_ACCESS_KEY'] ?? ''; | ||
$secret = $_SERVER['CEPH_SECRET'] ?? ''; | ||
$bucket = 'utopia-storage-test'; | ||
|
||
$this->object = new Ceph($this->root, $key, $secret, $bucket, Ceph::US_EAST_1, Ceph::ACL_PRIVATE); | ||
} | ||
|
||
protected function getAdapterName(): string | ||
{ | ||
return 'Ceph Storage'; | ||
} | ||
|
||
protected function getAdapterType(): string | ||
{ | ||
return $this->object->getType(); | ||
} | ||
|
||
protected function getAdapterDescription(): string | ||
{ | ||
return 'Ceph Storage'; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there more regions than these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked docs but couldn't find any specfied regions, I've added the most commonly accepted ones
const US_EAST_1 = 'us-east-1';
I checked in blackblaze adpater and it clearly shows where it is hosted but it not the case with Ceph. I assume all regions would work here which present in S3.php file. Should I add all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So they don't have any regions? Maybe we shouldn't add any in here then 🧐