Skip to content

Commit 15d250c

Browse files
authored
Merge pull request #533 from KnpLabs/feature/opencloud-adapter-exceptions
[RFR] [1.x] OpenCloud adapter rewrite
2 parents eadb134 + 7c67d68 commit 15d250c

24 files changed

+1122
-693
lines changed

.env.dist

+13-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@ GCS_PROJECT_ID=
77
GCS_BUCKET_NAME=
88
GCS_JSON_KEY_FILE=/app/secrets/gaufrette-appId.json
99

10+
# OpenStack identity v3
11+
# see /doc/adapters/open-stack.md
12+
IBMCLOUD_USERID=
13+
IBMCLOUD_PASSWORD=
14+
IBMCLOUD_REGION=
15+
1016
MONGO_URI=mongodb://mongodb:27017
1117
MONGO_DBNAME=gridfs_test
1218

19+
# OpenStack identity v2
20+
# see /doc/adapters/open-stack.md
21+
RACKSPACE_USERNAME=
22+
RACKSPACE_PASSWORD=
23+
RACKSPACE_TENANT_ID=
24+
RACKSPACE_REGION=
25+
1326
SFTP_HOST=sftp
1427
SFTP_PORT=22
1528
SFTP_USER=gaufrette
@@ -25,7 +38,3 @@ FTP_BASE_DIR=/gaufrette
2538
AZURE_ACCOUNT=
2639
AZURE_KEY=
2740
AZURE_CONTAINER=
28-
29-
RACKSPACE_USER=
30-
RACKSPACE_APIKEY=
31-
RACKSPACE_CONTAINER=

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ env:
2626

2727
matrix:
2828
include:
29-
- php: '7.1'
30-
- php: '7.2'
31-
- php: '7.3'
29+
- php: '7.1.29'
30+
- php: '7.2.18'
31+
- php: '7.3.5'
3232

3333
before_install:
3434
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@ v1.0.0
33

44
## New features
55

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

13+
## Removed
14+
15+
- The [OpenCloud adapter](https://github.com/KnpLabs/Gaufrette/blob/v0.5.0/src/Gaufrette/Adapter/OpenCloud.php)
16+
has been removed.
17+
- The [ObjectStoreFactory](https://github.com/KnpLabs/Gaufrette/blob/v0.5.0/src/Gaufrette/Adapter/OpenStackCloudFiles/ObjectStoreFactory.php)
18+
has been removed.
19+
820
Thank you @nicolasmure and @PanzerLlama for your contributions !
921

1022
v0.8.3

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ your issue or pull request in a timely manner, ping us:
5656
| GridFS | @NiR- |
5757
| InMemory | |
5858
| Local | |
59-
| OpenCloud | @NiR- |
59+
| OpenStack | @nicolasmure |
6060
| PhpseclibSftp | @fabschurt |
6161
| Zip | |
6262

UPGRADE.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
1.0
22
===
33

4+
**Gaufrette\Adapter\OpenStackCloudFiles\ObjectStoreFactory:**
5+
* This factory has been removed
6+
7+
**Gaufrette\Adapter\OpenCloud:**
8+
* This adapter has been removed and is now replaced by
9+
`Gaufrette\Adapter\OpenStack`. Additionally, the
10+
[`rackspace/php-opencloud`](https://github.com/rackspace/php-opencloud) SDK
11+
was replaced by the
12+
[`php-opencloud/openstack`](https://github.com/php-opencloud/openstack) SDK.
13+
414
**Gaufrette\Adapter\SafeLocal:**
515
* This adapter has been removed and will be superseded.
616

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"require-dev": {
2525
"aws/aws-sdk-php": "^2.4.12||~3",
2626
"amazonwebservices/aws-sdk-for-php": "1.5.*",
27-
"rackspace/php-opencloud" : "^1.9.2",
2827
"google/apiclient": "~1.1.3",
2928
"phpspec/phpspec": "~5.1",
3029
"phpseclib/phpseclib": "^2.0",
@@ -37,7 +36,8 @@
3736
"microsoft/azure-storage-blob": "^1.0",
3837
"akeneo/phpspec-skip-example-extension": "^4.0",
3938
"liuggio/fastest": "^1.6",
40-
"google/cloud-storage": "~1.0"
39+
"google/cloud-storage": "~1.0",
40+
"php-opencloud/openstack": "~3.0.0"
4141
},
4242
"suggest": {
4343
"knplabs/knp-gaufrette-bundle": "to use with Symfony",
@@ -49,13 +49,13 @@
4949
"gaufrette/aws-s3-adapter": "to use AwsS3 adapter (supports SDK v2 and v3)",
5050
"gaufrette/in-memory-adapter": "to use InMemory adapter",
5151
"gaufrette/local-adapter": "to use Local adapter",
52-
"gaufrette/opencloud-adapter": "to use Opencloud adapter",
52+
"gaufrette/openstack-adapter": "to use OpenStack adapter",
5353
"gaufrette/zip-adapter": "to use Zip adapter",
5454
"gaufrette/gridfs-adapter": "to use GridFS adapter",
5555
"google/cloud-storage": "to use GoogleCloudStorage adapter",
5656
"ext-curl": "*",
5757
"ext-mbstring": "*",
58-
"ext-fileinfo": "This extension is used to automatically detect the content-type of a file in the AwsS3, OpenCloud, AzureBlogStorage and GoogleCloudStorage adapters",
58+
"ext-fileinfo": "This extension is used to automatically detect the content-type of a file in the AwsS3, OpenStack, AzureBlogStorage and GoogleCloudStorage adapters",
5959
"ext-mongodb": "*",
6060
"mongodb/mongodb": "*"
6161
},

doc/adapters/open-cloud.md

-83
This file was deleted.

doc/adapters/open-stack.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
currentMenu: open-stack
3+
---
4+
5+
# OpenStack
6+
7+
First, you will need to install the adapter:
8+
```bash
9+
composer require gaufrette/openstack-adapter
10+
```
11+
12+
To use the OpenStack adapter you will need to create a connection using the
13+
[OpenStack SDK](https://github.com/php-opencloud/openstack).
14+
15+
The OpenStack container to use with the adapter should be created on your own.
16+
You can do it manually from the admin panel of your cloud provider, or
17+
progammatically using the OpenStack SDK :
18+
19+
```php
20+
$objectStore = (new OpenStack([
21+
// connection options
22+
]))
23+
->objectStoreV1()
24+
;
25+
26+
/*
27+
* @see \OpenStack\ObjectStore\v1\Api::putContainer for the list of options
28+
*/
29+
$objectStore->createContainer([
30+
'name' => 'my-container',
31+
]);
32+
```
33+
34+
## Usage with Identity API v3
35+
36+
For services using the [OpenStack Identity API v3](https://developer.openstack.org/api-ref/identity/v3/index.html),
37+
such as [IBM Cloud](https://www.ibm.com/cloud/) :
38+
39+
```php
40+
use Gaufrette\Adapter\OpenStack as OpenStackAdapter;
41+
use Gaufrette\Filesystem;
42+
use OpenStack\OpenStack;
43+
44+
$objectStore = (new OpenStack([
45+
'user' => [
46+
'id' => 'the user ID related to the storage service',
47+
'password' => 'the user password related to the storage service',
48+
],
49+
'authUrl' => 'https://example.com/v2/identity',
50+
'region' => 'the cloud region (eg "london")',
51+
]))
52+
->objectStoreV1()
53+
;
54+
55+
$adapter = new OpenStackAdapter(
56+
$objectStore,
57+
'container-name'
58+
);
59+
60+
$filesystem = new Filesystem($adapter);
61+
```
62+
63+
To find the options to use with IBM Cloud, [create a new project](https://console.bluemix.net/developer/appservice/starter-kits)
64+
and add an ObjectStorage to the project. The storage will be configured
65+
automatically and you'll be able to see its service credentials then.
66+
67+
## Usage with Identity API v2
68+
69+
For services using the [OpenStack Identity API v2](https://developer.openstack.org/api-ref/identity/v2/),
70+
such as [rackspace.com](https://www.rackspace.com/) :
71+
72+
```php
73+
use Gaufrette\Adapter\OpenStack as OpenStackAdapter;
74+
use Gaufrette\Filesystem;
75+
use GuzzleHttp\Client;
76+
use GuzzleHttp\HandlerStack;
77+
use OpenStack\Identity\v2\Service as IdentityService;
78+
use OpenStack\OpenStack;
79+
80+
$objectStore = new (OpenStack([
81+
'username' => 'your username',
82+
'password' => 'your password',
83+
'tenantId' => 'your tenant Id (also known as account Id/number)'
84+
'authUrl' => 'https://example.com/v2/identity',
85+
'region' => 'the cloud region (eg "LON" for London)',
86+
'identityService' => IdentityService::factory(
87+
new Client([
88+
'base_uri' => 'https://example.com/v2/identity',
89+
'handler' => HandlerStack::create(),
90+
])
91+
),
92+
]))
93+
->objectStoreV1([
94+
'catalogName' => 'cloudFiles', // default to "swift", use "cloudFiles" for rackspace,
95+
// or find the catalog name of your cloud service
96+
// associated with the "object-store" catalog type
97+
])
98+
;
99+
100+
$adapter = new OpenStackAdapter(
101+
$objectStore,
102+
'container-name'
103+
);
104+
105+
$filesystem = new Filesystem($adapter);
106+
```
107+
108+
## Links
109+
110+
- Go [here](https://github.com/php-opencloud/openstack/blob/master/src/OpenStack.php)
111+
to see all OpenStack connection options.

doc/couscous.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ menu:
6868
local:
6969
text: Local
7070
relativeUrl: adapters/local.html
71-
open-cloud:
72-
text: OpenCloud
73-
relativeUrl: adapters/open-cloud.html
71+
open-stack:
72+
text: OpenStack
73+
relativeUrl: adapters/open-stack.html
7474
phpseclib-sftp:
7575
text: PhpseclibSftp
7676
relativeUrl: adapters/phpseclib-sftp.html

phpunit.xml.dist

-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
<!--<env name="AZURE_ACCOUNT" value="" />
3838
<env name="AZURE_KEY" value="" />
3939
<env name="AZURE_CONTAINER" value="" />-->
40-
41-
<!-- Configuration for OpenCloud/Rackspace adapter -->
42-
<!--<env name="RACKSPACE_USER" value="" />
43-
<env name="RACKSPACE_APIKEY" value="" />
44-
<env name="RACKSPACE_CONTAINER" value="" />-->
4540
</php>
4641

4742
<testsuites>

0 commit comments

Comments
 (0)