From 1f89a6fd26a44296b4ffdbd4ec2d1ed27ede2c2e Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Mon, 28 Feb 2022 13:07:38 +0100 Subject: [PATCH] Simplified storage providers ENV vars --- Dockerfile | 16 ++++++++-------- app/config/variables.php | 16 ++++++++-------- app/init.php | 32 ++++++++++++++++---------------- app/workers/deletes.php | 16 ++++++++-------- docker-compose.yml | 32 ++++++++++++++++---------------- 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Dockerfile b/Dockerfile index 511621ed3d..4c605ae150 100755 --- a/Dockerfile +++ b/Dockerfile @@ -153,14 +153,14 @@ ENV _APP_SERVER=swoole \ _APP_STORAGE_ANTIVIRUS_HOST=clamav \ _APP_STORAGE_ANTIVIRUS_PORT=3310 \ _APP_STORAGE_DEVICE=Local \ - _APP_STORAGE_DEVICE_S3_ACCESS_KEY= \ - _APP_STORAGE_DEVICE_S3_SECRET= \ - _APP_STORAGE_DEVICE_S3_REGION= \ - _APP_STORAGE_DEVICE_S3_BUCKET= \ - _APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY= \ - _APP_STORAGE_DEVICE_DO_SPACES_SECRET= \ - _APP_STORAGE_DEVICE_DO_SPACES_REGION= \ - _APP_STORAGE_DEVICE_DO_SPACES_BUCKET= \ + _APP_STORAGE_S3_ACCESS_KEY= \ + _APP_STORAGE_S3_SECRET= \ + _APP_STORAGE_S3_REGION= \ + _APP_STORAGE_S3_BUCKET= \ + _APP_STORAGE_DO_SPACES_ACCESS_KEY= \ + _APP_STORAGE_DO_SPACES_SECRET= \ + _APP_STORAGE_DO_SPACES_REGION= \ + _APP_STORAGE_DO_SPACES_BUCKET= \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ diff --git a/app/config/variables.php b/app/config/variables.php index 5e0f8fb5e9..b32b3bf442 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -429,7 +429,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_S3_ACCESS_KEY', + 'name' => '_APP_STORAGE_S3_ACCESS_KEY', 'description' => 'AWS S3 storage access key. Required when the storage adapter is set to S3. You can get your access key from your AWS console', 'introduction' => '0.13.0', 'default' => '', @@ -437,7 +437,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_S3_SECRET', + 'name' => '_APP_STORAGE_S3_SECRET', 'description' => 'AWS S3 storage secret key. Required when the storage adapter is set to S3. You can get your secret key from your AWS console.', 'introduction' => '0.13.0', 'default' => '', @@ -445,7 +445,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_S3_REGION', + 'name' => '_APP_STORAGE_S3_REGION', 'description' => 'AWS S3 storage region. Required when storage adapter is set to S3. You can find your region info for your bucket from AWS console.', 'introduction' => '0.13.0', 'default' => 'us-eas-1', @@ -453,7 +453,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_S3_BUCKET', + 'name' => '_APP_STORAGE_S3_BUCKET', 'description' => 'AWS S3 storage bucket. Required when storage adapter is set to S3. You can create buckets in your AWS console.', 'introduction' => '0.13.0', 'default' => '', @@ -461,7 +461,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY', + 'name' => '_APP_STORAGE_DO_SPACES_ACCESS_KEY', 'description' => 'DigitalOcean spaces access key. Required when the storage adapter is set to DOSpaces. You can get your access key from your DigitalOcean console.', 'introduction' => '0.13.0', 'default' => '', @@ -469,7 +469,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_DO_SPACES_SECRET', + 'name' => '_APP_STORAGE_DO_SPACES_SECRET', 'description' => 'DigitalOcean spaces secret key. Required when the storage adapter is set to DOSpaces. You can get your secret key from your DigitalOcean console.', 'introduction' => '0.13.0', 'default' => '', @@ -477,7 +477,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_DO_SPACES_REGION', + 'name' => '_APP_STORAGE_DO_SPACES_REGION', 'description' => 'DigitalOcean spaces region. Required when storage adapter is set to DOSpaces. You can find your region info for your space from DigitalOcean console.', 'introduction' => '0.13.0', 'default' => 'us-eas-1', @@ -485,7 +485,7 @@ return [ 'question' => '', ], [ - 'name' => '_APP_STORAGE_DEVICE_DO_SPACES_BUCKET', + 'name' => '_APP_STORAGE_DO_SPACES_BUCKET', 'description' => 'DigitalOcean spaces bucket. Required when storage adapter is set to DOSpaces. You can create spaces in your DigitalOcean console.', 'introduction' => '0.13.0', 'default' => '', diff --git a/app/init.php b/app/init.php index 75153ce554..362bbf1efe 100644 --- a/app/init.php +++ b/app/init.php @@ -805,17 +805,17 @@ App::setResource('deviceFiles', function($project) { case Storage::DEVICE_LOCAL:default: return new Local(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_DEVICE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_DEVICE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_DEVICE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_DEVICE_S3_BUCKET', ''); + $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); + $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); + $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); + $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); $s3Acl = 'private'; return new S3(APP_STORAGE_UPLOADS . '/app-' . $project->getId(), $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_BUCKET', ''); + $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); + $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); + $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces(APP_STORAGE_UPLOADS . '/app-' . $project->getId(), $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); } @@ -826,17 +826,17 @@ App::setResource('deviceFunctions', function($project) { case Storage::DEVICE_LOCAL:default: return new Local(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()); case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_DEVICE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_DEVICE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_DEVICE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_DEVICE_S3_BUCKET', ''); + $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); + $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); + $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); + $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); $s3Acl = 'private'; return new S3(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId(), $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_BUCKET', ''); + $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); + $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); + $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; return new DOSpaces(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId(), $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); } diff --git a/app/workers/deletes.php b/app/workers/deletes.php index fd77980f0e..bc4e8ce503 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -465,18 +465,18 @@ class DeletesV1 extends Worker switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { case Storage::DEVICE_S3: - $s3AccessKey = App::getEnv('_APP_STORAGE_DEVICE_S3_ACCESS_KEY', ''); - $s3SecretKey = App::getEnv('_APP_STORAGE_DEVICE_S3_SECRET', ''); - $s3Region = App::getEnv('_APP_STORAGE_DEVICE_S3_REGION', ''); - $s3Bucket = App::getEnv('_APP_STORAGE_DEVICE_S3_BUCKET', ''); + $s3AccessKey = App::getEnv('_APP_STORAGE_S3_ACCESS_KEY', ''); + $s3SecretKey = App::getEnv('_APP_STORAGE_S3_SECRET', ''); + $s3Region = App::getEnv('_APP_STORAGE_S3_REGION', ''); + $s3Bucket = App::getEnv('_APP_STORAGE_S3_BUCKET', ''); $s3Acl = 'private'; $device = new S3(APP_STORAGE_UPLOADS . '/app-' . $projectId, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); break; case Storage::DEVICE_DO_SPACES: - $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY', ''); - $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_SECRET', ''); - $doSpacesRegion = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_REGION', ''); - $doSpacesBucket = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_BUCKET', ''); + $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DO_SPACES_SECRET', ''); + $doSpacesRegion = App::getEnv('_APP_STORAGE_DO_SPACES_REGION', ''); + $doSpacesBucket = App::getEnv('_APP_STORAGE_DO_SPACES_BUCKET', ''); $doSpacesAcl = 'private'; $device = new DOSpaces(APP_STORAGE_UPLOADS . '/app-' . $projectId, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); break; diff --git a/docker-compose.yml b/docker-compose.yml index 61bf06775f..2bee905d2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -114,14 +114,14 @@ services: - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT - _APP_STORAGE_DEVICE - - _APP_STORAGE_DEVICE_S3_ACCESS_KEY - - _APP_STORAGE_DEVICE_S3_SECRET - - _APP_STORAGE_DEVICE_S3_REGION - - _APP_STORAGE_DEVICE_S3_BUCKET - - _APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DEVICE_DO_SPACES_SECRET - - _APP_STORAGE_DEVICE_DO_SPACES_REGION - - _APP_STORAGE_DEVICE_DO_SPACES_BUCKET + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET - _APP_SMTP_HOST - _APP_SMTP_PORT - _APP_SMTP_SECURE @@ -265,14 +265,14 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_STORAGE_DEVICE - - _APP_STORAGE_DEVICE_S3_ACCESS_KEY - - _APP_STORAGE_DEVICE_S3_SECRET - - _APP_STORAGE_DEVICE_S3_REGION - - _APP_STORAGE_DEVICE_S3_BUCKET - - _APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY - - _APP_STORAGE_DEVICE_DO_SPACES_SECRET - - _APP_STORAGE_DEVICE_DO_SPACES_REGION - - _APP_STORAGE_DEVICE_DO_SPACES_BUCKET + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG