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

adds ceph adapter file and tests #88

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/Storage/Device/Ceph.php
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';
Copy link
Contributor

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?

Copy link
Author

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';

const US_EAST_2 = 'us-east-2';

const US_WEST_1 = 'us-west-1';

const US_WEST_2 = 'us-west-2';

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?

Copy link
Contributor

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 🧐


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;
}
}
5 changes: 2 additions & 3 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_CEPH = 'ceph';

/**
* Devices.
*
Expand All @@ -36,8 +38,6 @@ class Storage
* Add device by name
*
* @param string $name
* @param Device $device
* @return void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why were these removed?

Copy link
Author

Choose a reason for hiding this comment

The 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
*/
Expand Down Expand Up @@ -83,7 +83,6 @@ public static function exists($name)
*
* Based on: https://stackoverflow.com/a/38659168/2299554
*
* @param int $bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this removed?

Copy link
Author

Choose a reason for hiding this comment

The 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
Expand Down
34 changes: 34 additions & 0 deletions tests/Storage/Device/CephTest.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\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';
}
}