Skip to content

Commit 8c19c56

Browse files
Merge pull request #169 from open-runtimes/pla-3088
fix: add s3 endpoint var in adapter
2 parents 69a159b + 14a6eeb commit 8c19c56

File tree

3 files changed

+57
-64
lines changed

3 files changed

+57
-64
lines changed

app/controllers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function (
372372
Console::warning('Unable to send log message');
373373
}
374374

375-
$version = System::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN');
375+
$version = Http::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN');
376376
$message = $error->getMessage();
377377
$file = $error->getFile();
378378
$line = $error->getLine();

composer.lock

Lines changed: 46 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Executor/Runner/Adapter.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Utopia\Storage\Device\S3;
1818
use Utopia\Storage\Device\Wasabi;
1919
use Utopia\Storage\Storage;
20-
use Utopia\System\System;
2120

2221
abstract class Adapter
2322
{
@@ -135,7 +134,7 @@ protected function getStorageDevice(
135134
string $root,
136135
string $region = ''
137136
): Device {
138-
$connections = System::getEnv('OPR_EXECUTOR_CONNECTION_STORAGE', '') ?? '';
137+
$connections = Http::getEnv('OPR_EXECUTOR_CONNECTION_STORAGE', '') ?? '';
139138

140139
if (\preg_match('/^\w+=/', $connections)) {
141140
// Multi region
@@ -170,13 +169,16 @@ protected function getStorageDevice(
170169
$bucket = $dsn->getPath() ?? '';
171170
$region = $dsn->getParam('region');
172171
$insecure = $dsn->getParam('insecure', 'false') === 'true';
172+
$url = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_ENDPOINT', '');
173173
} catch (\Exception $e) {
174174
Console::warning($e->getMessage() . 'Invalid DSN. Defaulting to Local device.');
175175
}
176176

177177
switch ($device) {
178178
case Storage::DEVICE_S3:
179-
if (!empty($host)) {
179+
if (!empty($url)) {
180+
return new S3($root, $accessKey, $accessSecret, $url, $region, $acl);
181+
} elseif (!empty($host)) {
180182
$host = $insecure ? 'http://' . $host : $host;
181183
return new S3(root: $root, accessKey: $accessKey, secretKey: $accessSecret, host: $host, region: $region, acl: $acl);
182184
} else {
@@ -207,7 +209,11 @@ protected function getStorageDevice(
207209
$s3Region = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_REGION', '') ?? '';
208210
$s3Bucket = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_BUCKET', '') ?? '';
209211
$s3Acl = 'private';
210-
if (!empty($s3Host)) {
212+
$s3EndpointUrl = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_ENDPOINT', '');
213+
if (!empty($s3EndpointUrl)) {
214+
$bucketRoot = (!empty($s3Bucket) ? $s3Bucket . '/' : '') . \ltrim($root, '/');
215+
return new S3($bucketRoot, $s3AccessKey, $s3SecretKey, $s3EndpointUrl, $s3Region, $s3Acl);
216+
} elseif (!empty($s3Host)) {
211217
return new S3(root: $root, accessKey: $s3AccessKey, secretKey: $s3SecretKey, host: $s3Host, region: $s3Region, acl: $s3Acl);
212218
} else {
213219
return new AWS(root: $root, accessKey: $s3AccessKey, secretKey: $s3SecretKey, bucket: $s3Bucket, region: $s3Region, acl: $s3Acl);

0 commit comments

Comments
 (0)