Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add S3 and Wasabi as storage providers #281

Merged

Conversation

takielias
Copy link
Contributor

Description:

This PR introduces Wasabi as a new storage provider within the Vito Deploy system. Wasabi is a cloud storage service that offers S3-compatible object storage. This addition aligns with the existing storage providers such as FTP and Dropbox, providing users with more flexible and cost-effective storage options.

Changes Made:

  • Modified Files:

    • app/Enums/StorageProvider.php: Added Wasabi as a new enum value to support selection within the system.
    • config/core.php: Updated configuration to include Wasabi, enabling it to be properly recognized and managed by the system.
  • New Files:

    • app/StorageProviders/Wasabi.php: Implements the Wasabi-specific logic for managing storage operations, utilizing Wasabi’s S3-compatible API.
    • app/SSH/Storage/Wasabi.php: Manages the interaction between the SSH layer and Wasabi, ensuring that commands are executed correctly in a remote environment.
    • app/SSH/Storage/scripts/wasabi/download.sh: Bash script for downloading files from Wasabi storage.
    • app/SSH/Storage/scripts/wasabi/upload.sh: Bash script for uploading files to Wasabi storage.
  • New Tests:

    • tests/Feature/StorageProvidersTest.php: Added test cases for Wasabi to ensure it can be correctly configured, connected, and used for file operations, similar to existing storage providers.

image

Reason for Changes:

  • To provide an additional storage option that leverages Wasabi’s S3 compatibility, offering users more flexibility in choosing a cloud storage provider.
  • To extend the functionality of the Vito Deploy system to accommodate different storage needs, particularly for users looking for a cost-effective solution.

Testing:

  • Unit Tests: Updated and added test cases in StorageProvidersTest.php to ensure that Wasabi can be correctly configured, connected, and used for file operations.
  • Integration Tests: Conducted integration testing to verify that Wasabi interacts smoothly with the existing deployment workflows.
  • Manual Testing: Performed manual checks to ensure that files can be uploaded, downloaded, and deleted from Wasabi storage without issues.

Impacted Areas:

  • Storage provider management, specifically within the enum and configuration files.
  • Script execution for file operations via SSH, tailored for Wasabi’s S3-compatible API.

Notes:

  • This change is backward compatible and does not interfere with existing storage providers.
  • Users will need to input their Wasabi credentials and specify the correct region when configuring the storage provider.

Reviewer Notes:

  • Please review the Wasabi-specific logic in both the StorageProviders and SSH layers.
  • Verify that the new scripts for Wasabi (download.sh and upload.sh) are correctly integrated and functioning as expected.
  • Review the new test cases in StorageProvidersTest.php to ensure they cover all necessary scenarios.
  • Feedback on code structure, especially in handling the S3-compatible API, would be valuable.

@saeedvaziry
Copy link
Member

Thanks for the PR @takielias.

Why not making just a S3 driver instead of wasabi wich uses S3 under the hood?

@gaetan-hexadog
Copy link

gaetan-hexadog commented Aug 25, 2024

Hi @takielias ,

thanks a lot for this PR. I don't know wasabi but I see it's a S3-compatible object storage. So why not calling this storage provider "S3 Storage" (or anything else generic) instead of Wasabi ? Your provider should work with any S3-compatible object storage provider right ?

On my side I'm not using Wasabi but Tebi.io and I'm looking forward to be able to connect my vito instance to it. So naming it with a more generic name could help to not confuse user who want to connect any S3-compatible object storage.

Best regards

@takielias
Copy link
Contributor Author

Thanks for the PR @takielias.

Why not making just a S3 driver instead of wasabi wich uses S3 under the hood?

@saeedvaziry Thank you for the feedback! I decided to start with Wasabi because I've been using it extensively for the past 4 years and am more familiar with its nuances. There were also some conditional differences in implementing the AWS CLI for Wasabi that made it a more natural starting point for me. I agree that a more generalized S3 driver would be a great addition, and I'll definitely consider working on that in the near future.

@takielias
Copy link
Contributor Author

takielias commented Aug 25, 2024

Hi @gaetan-hexadog,

Thank you for the thoughtful feedback! You're absolutely right—Wasabi is S3-compatible, and the implementation could indeed work with any S3-compatible object storage provider. I initially focused on Wasabi because it’s what I use regularly.

I'll consider refactoring the implementation to make it more universally applicable to any S3-compatible storage in near future.

Thanks again for the suggestion!

@saeedvaziry
Copy link
Member

@takielias I would still go with S3 to build the core and then will extend Wasabi from S3. I can help with the PR to cover both.

@takielias
Copy link
Contributor Author

takielias commented Aug 25, 2024

@takielias I would still go with S3 to build the core and then will extend Wasabi from S3. I can help with the PR to cover both.

Thant would be great. How can we start? Please.

@takielias
Copy link
Contributor Author

@saeedvaziry I'm working on S3. Will share the update soon.

@takielias
Copy link
Contributor Author

Hi @saeedvaziry,

I've updated the PR to incorporate a core S3 compatibility layer with the following changes:

S3AbstractStorageProvider.php and S3AbstractStorage.php: These files serve as the core for any S3-compatible service.

HasS3Storage.php: A trait added to ensure consistent file path management across S3-compatible services.

Wasabi Storage: I've refactored the Wasabi storage implementation to extend from this new S3 core, allowing for easier integration of other S3-compatible storage providers in the future.

I have also update the tests tests/Feature/StorageProvidersTest.php

image

Please take a look at the code and let me know if you have any suggestions or improvements. I'm open to feedback and eager to make this as robust and flexible as possible.

@saeedvaziry
Copy link
Member

@takielias the actions are failing

@takielias
Copy link
Contributor Author

@takielias the actions are failing

@saeedvaziry

I have fixed the tests.

…ovider' into fork/takielias/feature/add-wasabi-storage-provider
@saeedvaziry
Copy link
Member

fixes #263

@saeedvaziry saeedvaziry changed the title Add New Storage Provider: Wasabi Add New Storage Provider: S3 and Wasabi Aug 31, 2024
@saeedvaziry saeedvaziry changed the title Add New Storage Provider: S3 and Wasabi Add S3 and Wasabi as storage providers Aug 31, 2024
@saeedvaziry saeedvaziry merged commit e39e8c1 into vitodeploy:1.x Sep 6, 2024
2 checks passed
@manusiakemos
Copy link

does it support minio?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants