From f3fcb21b99084f898e3a7d8356d645735683f348 Mon Sep 17 00:00:00 2001 From: Atharva Date: Fri, 20 Oct 2023 12:35:57 +0530 Subject: [PATCH 01/11] Base implementation of Exoscale adapter --- src/Storage/Device/Exoscale.php | 74 +++++++++++++++++++++++++++ src/Storage/Storage.php | 2 + tests/Storage/Device/ExoscaleTest.php | 36 +++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 src/Storage/Device/Exoscale.php create mode 100644 tests/Storage/Device/ExoscaleTest.php diff --git a/src/Storage/Device/Exoscale.php b/src/Storage/Device/Exoscale.php new file mode 100644 index 00000000..f7869186 --- /dev/null +++ b/src/Storage/Device/Exoscale.php @@ -0,0 +1,74 @@ + 'https://sos-ch-gva-2.exo.io', + self::CH_DK_2 => 'https://sos-ch-dk-2.exo.io', + self::DE_FRA_1 => 'https://sos-de-fra-1.exo.io', + self::DE_MUC_1 => 'https://sos-de-muc-1.exo.io', + self::AT_VIE_1 => 'https://sos-at-vie-1.exo.io', + self::AT_VIE_2 => 'https://sos-at-vie-2.exo.io', + self::BG_SOF_1 => 'https://sos-bg-sof-1.exo.io', + ]; + + /** + * Exoscale Constructor + * + * @param string $root + * @param string $apiKey + * @param string $apiSecret + * @param string $bucket + * @param string $region + * @param string $acl + */ + public function __construct(string $root, string $apiKey, string $apiSecret, string $bucket, string $region = self::CH_GVA_2, string $acl = self::ACL_PRIVATE) + { + parent::__construct($root, $apiKey, $apiSecret, $bucket, $region, $acl); + + if (isset($this->regionEndpointMap[$region])) { + $this->headers['host'] = $this->regionEndpointMap[$region]; + } else { + throw new \InvalidArgumentException('Invalid or unsupported region'); + } + } + + /** + * @return string + */ + public function getName(): string + { + return 'Exoscale Storage'; + } + + /** + * @return string + */ + public function getDescription(): string + { + return 'Exoscale Storage'; + } + + /** + * @return string + */ + public function getType(): string + { + return Storage::DEVICE_EXOSCALE; + } +} \ No newline at end of file diff --git a/src/Storage/Storage.php b/src/Storage/Storage.php index cabd18c8..28e588f8 100644 --- a/src/Storage/Storage.php +++ b/src/Storage/Storage.php @@ -21,6 +21,8 @@ class Storage const DEVICE_LINODE = 'linode'; + const DEVICE_EXOSCALE = 'exoscale'; + /** * Devices. * diff --git a/tests/Storage/Device/ExoscaleTest.php b/tests/Storage/Device/ExoscaleTest.php new file mode 100644 index 00000000..588734f1 --- /dev/null +++ b/tests/Storage/Device/ExoscaleTest.php @@ -0,0 +1,36 @@ +root = '/root'; + $apiKey = 'YOUR_EXOSCALE_API_KEY'; + $apiSecret = 'YOUR_EXOSCALE_API_SECRET'; + $bucket = 'YOUR_EXOSCALE_BUCKET'; + $region = Exoscale::CH_GVA_2; + $acl = Exoscale::ACL_PRIVATE; + + $this->object = new Exoscale($this->root, $apiKey, $apiSecret, $bucket, $region, $acl); + } + + protected function getAdapterName(): string + { + return 'Exoscale Storage'; + } + + protected function getAdapterType(): string + { + return $this->object->getType(); + } + + protected function getAdapterDescription(): string + { + return 'Exoscale Storage'; + } +} \ No newline at end of file From 99e38bf789f8999cb46aa54c8481f82ac26c7bdb Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Wed, 1 Nov 2023 08:34:42 +0530 Subject: [PATCH 02/11] Update Exoscale.php --- src/Storage/Device/Exoscale.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Storage/Device/Exoscale.php b/src/Storage/Device/Exoscale.php index f7869186..7df38de1 100644 --- a/src/Storage/Device/Exoscale.php +++ b/src/Storage/Device/Exoscale.php @@ -6,6 +6,7 @@ class Exoscale extends S3 { + //https://community.exoscale.com/documentation/platform/exoscale-datacenter-zones/ /** * Exoscale Regions constants */ @@ -17,16 +18,6 @@ class Exoscale extends S3 const AT_VIE_2 = 'at-vie-2'; const BG_SOF_1 = 'bg-sof-1'; - private $regionEndpointMap = [ - self::CH_GVA_2 => 'https://sos-ch-gva-2.exo.io', - self::CH_DK_2 => 'https://sos-ch-dk-2.exo.io', - self::DE_FRA_1 => 'https://sos-de-fra-1.exo.io', - self::DE_MUC_1 => 'https://sos-de-muc-1.exo.io', - self::AT_VIE_1 => 'https://sos-at-vie-1.exo.io', - self::AT_VIE_2 => 'https://sos-at-vie-2.exo.io', - self::BG_SOF_1 => 'https://sos-bg-sof-1.exo.io', - ]; - /** * Exoscale Constructor * @@ -71,4 +62,4 @@ public function getType(): string { return Storage::DEVICE_EXOSCALE; } -} \ No newline at end of file +} From eeef840403e90103f2a2d263d4e7c24d97040a51 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Wed, 1 Nov 2023 15:56:33 +0530 Subject: [PATCH 03/11] Update Exoscale.php --- src/Storage/Device/Exoscale.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Storage/Device/Exoscale.php b/src/Storage/Device/Exoscale.php index 7df38de1..24d02ef1 100644 --- a/src/Storage/Device/Exoscale.php +++ b/src/Storage/Device/Exoscale.php @@ -11,11 +11,17 @@ class Exoscale extends S3 * Exoscale Regions constants */ const CH_GVA_2 = 'ch-gva-2'; + const CH_DK_2 = 'ch-dk-2'; + const DE_FRA_1 = 'de-fra-1'; + const DE_MUC_1 = 'de-muc-1'; + const AT_VIE_1 = 'at-vie-1'; + const AT_VIE_2 = 'at-vie-2'; + const BG_SOF_1 = 'bg-sof-1'; /** @@ -31,12 +37,7 @@ class Exoscale extends S3 public function __construct(string $root, string $apiKey, string $apiSecret, string $bucket, string $region = self::CH_GVA_2, string $acl = self::ACL_PRIVATE) { parent::__construct($root, $apiKey, $apiSecret, $bucket, $region, $acl); - - if (isset($this->regionEndpointMap[$region])) { - $this->headers['host'] = $this->regionEndpointMap[$region]; - } else { - throw new \InvalidArgumentException('Invalid or unsupported region'); - } + $this->headers['host'] = $bucket.'.'.$region.'.'.'exo.io'; } /** @@ -44,7 +45,7 @@ public function __construct(string $root, string $apiKey, string $apiSecret, str */ public function getName(): string { - return 'Exoscale Storage'; + return 'Exoscale Simple Object Storage'; } /** @@ -52,7 +53,7 @@ public function getName(): string */ public function getDescription(): string { - return 'Exoscale Storage'; + return 'Exoscale Simple Object Storage'; } /** From e935634e4f79eaf57c656130b66f9515315209cb Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Wed, 1 Nov 2023 15:58:03 +0530 Subject: [PATCH 04/11] Update src/Storage/Device/Exoscale.php Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/Storage/Device/Exoscale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Exoscale.php b/src/Storage/Device/Exoscale.php index 24d02ef1..004a0b02 100644 --- a/src/Storage/Device/Exoscale.php +++ b/src/Storage/Device/Exoscale.php @@ -6,9 +6,9 @@ class Exoscale extends S3 { - //https://community.exoscale.com/documentation/platform/exoscale-datacenter-zones/ /** * Exoscale Regions constants + * https://community.exoscale.com/documentation/platform/exoscale-datacenter-zones/ */ const CH_GVA_2 = 'ch-gva-2'; From 1ccc6a7d0b280c3a33cec477ad1dc9f577f19732 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Fri, 3 Nov 2023 09:08:58 +0530 Subject: [PATCH 05/11] Update tests.yml --- .github/workflows/tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 43d7ca7e..a2e93ddf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,6 +31,8 @@ jobs: env: DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} DO_SECRET: ${{ secrets.DO_SECRET }} + EXOSCALE_ACCESS_KEY: ${{ secrets.EXOSCALE_ACCESS_KEY }} + EXOSCALE_SECRET: ${{ secrets.EXOSCALE_SECRET }} LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} LINODE_SECRET: ${{ secrets.LINODE_SECRET }} S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} @@ -58,7 +60,7 @@ jobs: strategy: fail-fast: false matrix: - devices: [BackblazeTest, DOSpacesTest, LinodeTest, LocalTest, S3Test, WasabiTest] + devices: [BackblazeTest, DOSpacesTest, ExoscaleTest,LinodeTest, LocalTest, S3Test, WasabiTest] steps: - name: checkout @@ -67,6 +69,8 @@ jobs: env: DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} DO_SECRET: ${{ secrets.DO_SECRET }} + EXOSCALE_ACCESS_KEY: ${{ secrets.EXOSCALE_ACCESS_KEY }} + EXOSCALE_SECRET: ${{ secrets.EXOSCALE_SECRET }} LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} LINODE_SECRET: ${{ secrets.LINODE_SECRET }} S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} From 26a372f5747b207ef653da613bf69779c3a57b32 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Fri, 3 Nov 2023 09:33:05 +0530 Subject: [PATCH 06/11] Update ExoscaleTest.php --- tests/Storage/Device/ExoscaleTest.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/Storage/Device/ExoscaleTest.php b/tests/Storage/Device/ExoscaleTest.php index 588734f1..b69ec0e4 100644 --- a/tests/Storage/Device/ExoscaleTest.php +++ b/tests/Storage/Device/ExoscaleTest.php @@ -10,18 +10,16 @@ class ExoscaleTest extends S3Base protected function init(): void { $this->root = '/root'; - $apiKey = 'YOUR_EXOSCALE_API_KEY'; - $apiSecret = 'YOUR_EXOSCALE_API_SECRET'; - $bucket = 'YOUR_EXOSCALE_BUCKET'; - $region = Exoscale::CH_GVA_2; - $acl = Exoscale::ACL_PRIVATE; + $apiKey = $_SERVER['EXOSCALE_ACCESS_KEY'] ?? ''; + $apiSecret = $_SERVER['EXOSCALE_SECRET'] ?? ''; + $bucket = 'storage-test'; - $this->object = new Exoscale($this->root, $apiKey, $apiSecret, $bucket, $region, $acl); + $this->object = new Exoscale($this->root, $apiKey, $apiSecret, $bucket, Exoscale::CH_GVA_2, Exoscale::ACL_PRIVATE); } protected function getAdapterName(): string { - return 'Exoscale Storage'; + return 'Exoscale Simple Object Storage'; } protected function getAdapterType(): string @@ -31,6 +29,6 @@ protected function getAdapterType(): string protected function getAdapterDescription(): string { - return 'Exoscale Storage'; + return 'Exoscale Simple Object Storage'; } -} \ No newline at end of file +} From f426c9312cc917873deabcde56ed2e58f513b6a8 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Fri, 3 Nov 2023 15:21:29 +0530 Subject: [PATCH 07/11] Update .github/workflows/tests.yml Co-authored-by: Luke B. Silver <22452787+loks0n@users.noreply.github.com> --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a2e93ddf..6a3f3c5b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -60,7 +60,7 @@ jobs: strategy: fail-fast: false matrix: - devices: [BackblazeTest, DOSpacesTest, ExoscaleTest,LinodeTest, LocalTest, S3Test, WasabiTest] + devices: [BackblazeTest, DOSpacesTest, ExoscaleTest, LinodeTest, LocalTest, S3Test, WasabiTest] steps: - name: checkout From c7cb031e97367149d60b57734c455f9c57c6e595 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Tue, 14 Nov 2023 09:28:11 +0530 Subject: [PATCH 08/11] Update Exoscale.php --- src/Storage/Device/Exoscale.php | 35 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/Storage/Device/Exoscale.php b/src/Storage/Device/Exoscale.php index 004a0b02..d7fff6f8 100644 --- a/src/Storage/Device/Exoscale.php +++ b/src/Storage/Device/Exoscale.php @@ -8,21 +8,20 @@ class Exoscale extends S3 { /** * Exoscale Regions constants - * https://community.exoscale.com/documentation/platform/exoscale-datacenter-zones/ */ - const CH_GVA_2 = 'ch-gva-2'; - - const CH_DK_2 = 'ch-dk-2'; - - const DE_FRA_1 = 'de-fra-1'; - - const DE_MUC_1 = 'de-muc-1'; - - const AT_VIE_1 = 'at-vie-1'; - - const AT_VIE_2 = 'at-vie-2'; - - const BG_SOF_1 = 'bg-sof-1'; + public const CH_GVA_2 = 'ch-gva-2'; + + public const CH_DK_2 = 'ch-dk-2'; + + public const DE_FRA_1 = 'de-fra-1'; + + public const DE_MUC_1 = 'de-muc-1'; + + public const AT_VIE_1 = 'at-vie-1'; + + public const AT_VIE_2 = 'at-vie-2'; + + public const BG_SOF_1 = 'bg-sof-1'; /** * Exoscale Constructor @@ -34,9 +33,9 @@ class Exoscale extends S3 * @param string $region * @param string $acl */ - public function __construct(string $root, string $apiKey, string $apiSecret, string $bucket, string $region = self::CH_GVA_2, string $acl = self::ACL_PRIVATE) + public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::EU_CENTRAL_1, string $acl = self::ACL_PRIVATE) { - parent::__construct($root, $apiKey, $apiSecret, $bucket, $region, $acl); + parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl); $this->headers['host'] = $bucket.'.'.$region.'.'.'exo.io'; } @@ -45,7 +44,7 @@ public function __construct(string $root, string $apiKey, string $apiSecret, str */ public function getName(): string { - return 'Exoscale Simple Object Storage'; + return 'Exoscale Storage'; } /** @@ -53,7 +52,7 @@ public function getName(): string */ public function getDescription(): string { - return 'Exoscale Simple Object Storage'; + return 'Exoscale Storage'; } /** From e758d7734935ee4c511fdf8a9f8d03437b360d09 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Wed, 15 Nov 2023 14:19:03 +0530 Subject: [PATCH 09/11] Update Exoscale.php --- src/Storage/Device/Exoscale.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Storage/Device/Exoscale.php b/src/Storage/Device/Exoscale.php index d7fff6f8..068938b4 100644 --- a/src/Storage/Device/Exoscale.php +++ b/src/Storage/Device/Exoscale.php @@ -26,12 +26,12 @@ class Exoscale extends S3 /** * Exoscale Constructor * - * @param string $root - * @param string $apiKey - * @param string $apiSecret - * @param string $bucket - * @param string $region - * @param string $acl + * @param string $root + * @param string $apiKey + * @param string $apiSecret + * @param string $bucket + * @param string $region + * @param string $acl */ public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::EU_CENTRAL_1, string $acl = self::ACL_PRIVATE) { From 0ae965c538872577ec1edce3a14347e52140fb3d Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Wed, 15 Nov 2023 16:23:44 +0530 Subject: [PATCH 10/11] Delete src/Storage/Storage.php --- src/Storage/Storage.php | 126 ---------------------------------------- 1 file changed, 126 deletions(-) delete mode 100644 src/Storage/Storage.php diff --git a/src/Storage/Storage.php b/src/Storage/Storage.php deleted file mode 100644 index 28e588f8..00000000 --- a/src/Storage/Storage.php +++ /dev/null @@ -1,126 +0,0 @@ - [ - 'B', - 'KiB', - 'MiB', - 'GiB', - 'TiB', - 'PiB', - 'EiB', - 'ZiB', - 'YiB', - ], - 'metric' => [ - 'B', - 'kB', - 'MB', - 'GB', - 'TB', - 'PB', - 'EB', - 'ZB', - 'YB', - ], - ]; - - $factor = (int) floor((strlen((string) $bytes) - 1) / 3); - - return sprintf("%.{$decimals}f%s", $bytes / pow($mod, $factor), $units[$system][$factor]); - } -} From 43e790217c936b90c8ac9b8b861248f84a63fa55 Mon Sep 17 00:00:00 2001 From: Atharva Kulkarni Date: Wed, 15 Nov 2023 16:24:00 +0530 Subject: [PATCH 11/11] Add files via upload --- src/Storage/Storage.php | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/Storage/Storage.php diff --git a/src/Storage/Storage.php b/src/Storage/Storage.php new file mode 100644 index 00000000..93acc052 --- /dev/null +++ b/src/Storage/Storage.php @@ -0,0 +1,126 @@ + [ + 'B', + 'KiB', + 'MiB', + 'GiB', + 'TiB', + 'PiB', + 'EiB', + 'ZiB', + 'YiB', + ], + 'metric' => [ + 'B', + 'kB', + 'MB', + 'GB', + 'TB', + 'PB', + 'EB', + 'ZB', + 'YB', + ], + ]; + + $factor = (int) floor((strlen((string) $bytes) - 1) / 3); + + return sprintf("%.{$decimals}f%s", $bytes / pow($mod, $factor), $units[$system][$factor]); + } +}