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 all 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
1 change: 1 addition & 0 deletions php-ext-brotli
Submodule php-ext-brotli added at 58c0c9
32 changes: 32 additions & 0 deletions src/Storage/Device/Ceph.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Storage;

class Ceph extends S3
{
/**
* Ceph Constructor
*/
public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $cephHost, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $accessKey, $secretKey, $bucket, $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;
}
}
6 changes: 4 additions & 2 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,7 +38,7 @@ class Storage
* Add device by name
*
* @param string $name
* @param Device $device
* @param Device $device
* @return void
*
* @throws Exception
Expand Down Expand Up @@ -83,7 +85,7 @@ 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 $bytes
* @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 CephTest 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';
}
}