Skip to content

Commit

Permalink
opencloud to openstack adapter rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasmure committed Jun 28, 2019
1 parent eadb134 commit 7c67d68
Show file tree
Hide file tree
Showing 24 changed files with 1,122 additions and 693 deletions.
17 changes: 13 additions & 4 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ GCS_PROJECT_ID=
GCS_BUCKET_NAME=
GCS_JSON_KEY_FILE=/app/secrets/gaufrette-appId.json

# OpenStack identity v3
# see /doc/adapters/open-stack.md
IBMCLOUD_USERID=
IBMCLOUD_PASSWORD=
IBMCLOUD_REGION=

MONGO_URI=mongodb://mongodb:27017
MONGO_DBNAME=gridfs_test

# OpenStack identity v2
# see /doc/adapters/open-stack.md
RACKSPACE_USERNAME=
RACKSPACE_PASSWORD=
RACKSPACE_TENANT_ID=
RACKSPACE_REGION=

SFTP_HOST=sftp
SFTP_PORT=22
SFTP_USER=gaufrette
Expand All @@ -25,7 +38,3 @@ FTP_BASE_DIR=/gaufrette
AZURE_ACCOUNT=
AZURE_KEY=
AZURE_CONTAINER=

RACKSPACE_USER=
RACKSPACE_APIKEY=
RACKSPACE_CONTAINER=
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ env:

matrix:
include:
- php: '7.1'
- php: '7.2'
- php: '7.3'
- php: '7.1.29'
- php: '7.2.18'
- php: '7.3.5'

before_install:
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ v1.0.0

## New features

- The [OpenCloud adapter](https://github.com/KnpLabs/Gaufrette/blob/v0.5.0/src/Gaufrette/Adapter/OpenCloud.php)
has been replaced by the [OpenStack adapter](/src/Gaufrette/Adapter/OpenStack.php).
The new adapter now uses the https://github.com/php-opencloud/openstack SDK
which is the latest supported version of the SDK for OpenStack instead of
https://github.com/rackspace/php-opencloud (#533).
- Google Cloud Storage Adapter (#557)

## Removed

- The [OpenCloud adapter](https://github.com/KnpLabs/Gaufrette/blob/v0.5.0/src/Gaufrette/Adapter/OpenCloud.php)
has been removed.
- The [ObjectStoreFactory](https://github.com/KnpLabs/Gaufrette/blob/v0.5.0/src/Gaufrette/Adapter/OpenStackCloudFiles/ObjectStoreFactory.php)
has been removed.

Thank you @nicolasmure and @PanzerLlama for your contributions !

v0.8.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ your issue or pull request in a timely manner, ping us:
| GridFS | @NiR- |
| InMemory | |
| Local | |
| OpenCloud | @NiR- |
| OpenStack | @nicolasmure |
| PhpseclibSftp | @fabschurt |
| Zip | |

Expand Down
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
1.0
===

**Gaufrette\Adapter\OpenStackCloudFiles\ObjectStoreFactory:**
* This factory has been removed

**Gaufrette\Adapter\OpenCloud:**
* This adapter has been removed and is now replaced by
`Gaufrette\Adapter\OpenStack`. Additionally, the
[`rackspace/php-opencloud`](https://github.com/rackspace/php-opencloud) SDK
was replaced by the
[`php-opencloud/openstack`](https://github.com/php-opencloud/openstack) SDK.

**Gaufrette\Adapter\SafeLocal:**
* This adapter has been removed and will be superseded.

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"require-dev": {
"aws/aws-sdk-php": "^2.4.12||~3",
"amazonwebservices/aws-sdk-for-php": "1.5.*",
"rackspace/php-opencloud" : "^1.9.2",
"google/apiclient": "~1.1.3",
"phpspec/phpspec": "~5.1",
"phpseclib/phpseclib": "^2.0",
Expand All @@ -37,7 +36,8 @@
"microsoft/azure-storage-blob": "^1.0",
"akeneo/phpspec-skip-example-extension": "^4.0",
"liuggio/fastest": "^1.6",
"google/cloud-storage": "~1.0"
"google/cloud-storage": "~1.0",
"php-opencloud/openstack": "~3.0.0"
},
"suggest": {
"knplabs/knp-gaufrette-bundle": "to use with Symfony",
Expand All @@ -49,13 +49,13 @@
"gaufrette/aws-s3-adapter": "to use AwsS3 adapter (supports SDK v2 and v3)",
"gaufrette/in-memory-adapter": "to use InMemory adapter",
"gaufrette/local-adapter": "to use Local adapter",
"gaufrette/opencloud-adapter": "to use Opencloud adapter",
"gaufrette/openstack-adapter": "to use OpenStack adapter",
"gaufrette/zip-adapter": "to use Zip adapter",
"gaufrette/gridfs-adapter": "to use GridFS adapter",
"google/cloud-storage": "to use GoogleCloudStorage adapter",
"ext-curl": "*",
"ext-mbstring": "*",
"ext-fileinfo": "This extension is used to automatically detect the content-type of a file in the AwsS3, OpenCloud, AzureBlogStorage and GoogleCloudStorage adapters",
"ext-fileinfo": "This extension is used to automatically detect the content-type of a file in the AwsS3, OpenStack, AzureBlogStorage and GoogleCloudStorage adapters",
"ext-mongodb": "*",
"mongodb/mongodb": "*"
},
Expand Down
83 changes: 0 additions & 83 deletions doc/adapters/open-cloud.md

This file was deleted.

111 changes: 111 additions & 0 deletions doc/adapters/open-stack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
currentMenu: open-stack
---

# OpenStack

First, you will need to install the adapter:
```bash
composer require gaufrette/openstack-adapter
```

To use the OpenStack adapter you will need to create a connection using the
[OpenStack SDK](https://github.com/php-opencloud/openstack).

The OpenStack container to use with the adapter should be created on your own.
You can do it manually from the admin panel of your cloud provider, or
progammatically using the OpenStack SDK :

```php
$objectStore = (new OpenStack([
// connection options
]))
->objectStoreV1()
;

/*
* @see \OpenStack\ObjectStore\v1\Api::putContainer for the list of options
*/
$objectStore->createContainer([
'name' => 'my-container',
]);
```

## Usage with Identity API v3

For services using the [OpenStack Identity API v3](https://developer.openstack.org/api-ref/identity/v3/index.html),
such as [IBM Cloud](https://www.ibm.com/cloud/) :

```php
use Gaufrette\Adapter\OpenStack as OpenStackAdapter;
use Gaufrette\Filesystem;
use OpenStack\OpenStack;

$objectStore = (new OpenStack([
'user' => [
'id' => 'the user ID related to the storage service',
'password' => 'the user password related to the storage service',
],
'authUrl' => 'https://example.com/v2/identity',
'region' => 'the cloud region (eg "london")',
]))
->objectStoreV1()
;

$adapter = new OpenStackAdapter(
$objectStore,
'container-name'
);

$filesystem = new Filesystem($adapter);
```

To find the options to use with IBM Cloud, [create a new project](https://console.bluemix.net/developer/appservice/starter-kits)
and add an ObjectStorage to the project. The storage will be configured
automatically and you'll be able to see its service credentials then.

## Usage with Identity API v2

For services using the [OpenStack Identity API v2](https://developer.openstack.org/api-ref/identity/v2/),
such as [rackspace.com](https://www.rackspace.com/) :

```php
use Gaufrette\Adapter\OpenStack as OpenStackAdapter;
use Gaufrette\Filesystem;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use OpenStack\Identity\v2\Service as IdentityService;
use OpenStack\OpenStack;

$objectStore = new (OpenStack([
'username' => 'your username',
'password' => 'your password',
'tenantId' => 'your tenant Id (also known as account Id/number)'
'authUrl' => 'https://example.com/v2/identity',
'region' => 'the cloud region (eg "LON" for London)',
'identityService' => IdentityService::factory(
new Client([
'base_uri' => 'https://example.com/v2/identity',
'handler' => HandlerStack::create(),
])
),
]))
->objectStoreV1([
'catalogName' => 'cloudFiles', // default to "swift", use "cloudFiles" for rackspace,
// or find the catalog name of your cloud service
// associated with the "object-store" catalog type
])
;

$adapter = new OpenStackAdapter(
$objectStore,
'container-name'
);

$filesystem = new Filesystem($adapter);
```

## Links

- Go [here](https://github.com/php-opencloud/openstack/blob/master/src/OpenStack.php)
to see all OpenStack connection options.
6 changes: 3 additions & 3 deletions doc/couscous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ menu:
local:
text: Local
relativeUrl: adapters/local.html
open-cloud:
text: OpenCloud
relativeUrl: adapters/open-cloud.html
open-stack:
text: OpenStack
relativeUrl: adapters/open-stack.html
phpseclib-sftp:
text: PhpseclibSftp
relativeUrl: adapters/phpseclib-sftp.html
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
<!--<env name="AZURE_ACCOUNT" value="" />
<env name="AZURE_KEY" value="" />
<env name="AZURE_CONTAINER" value="" />-->

<!-- Configuration for OpenCloud/Rackspace adapter -->
<!--<env name="RACKSPACE_USER" value="" />
<env name="RACKSPACE_APIKEY" value="" />
<env name="RACKSPACE_CONTAINER" value="" />-->
</php>

<testsuites>
Expand Down
Loading

0 comments on commit 7c67d68

Please sign in to comment.