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 2 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
47 changes: 47 additions & 0 deletions src/Storage/Device/Ceph.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Utopia\Storage\Device;

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 🧐


/**
* Ceph Constructor
*
* @param string $root
* @param string $accessKey
* @param string $secretKey
* @param string $bucket
* @param string $region
* @param string $acl
*/
public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::US_WEST_001, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl);
$this->headers['host'] = $bucket.'.'.'s3'.'.'.$region.'.ceph.io';
stnguyen90 marked this conversation as resolved.
Show resolved Hide resolved
}
/**
* @return string
*/
public function getName(): string
{
return 'Ceph Storage';
}

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

public function getType(): string
{
return Storage::DEVICE_CEPH;
}
}
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_CEPH = 'ceph';

/**
* Devices.
*
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';
}
}