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

fix: Add optional S3 endpoint to upload arguments #110

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

kidneyweakx
Copy link
Contributor

@kidneyweakx kidneyweakx commented Dec 16, 2024

Description

Add an optional endpoint field in the S3UploadArgs struct. Users can now specify a custom AWS S3-compatible endpoint, enhancing the deployment function's flexibility for working with different S3-compatible services.

The changes include:

  1. Modifying the S3UploadArgs struct to include an endpoint field.
  2. Updating the deployment logic to use the provided endpoint if specified.
  3. Defaulting to the standard S3 URL format when the endpoint field is not provided.
  4. Updating the AmazonS3Builder configuration to incorporate the custom endpoint.

Testing

  • Case 1: Without endpoint field
    Input:

      bonsol deploy --deploy-type <DEPLOY_TYPE> --bucket <BUCKET> --access-key <ACCESS_KEY> --secret-key <SECRET_KEY> --region <REGION> --url <URL> --manifest-path <MANIFEST_PATH> <--create|--storage-account <STORAGE_ACCOUNT>>

    Expected: URL defaults to https://example-bucket.s3.us-west-1.amazonaws.com/....

  • Case 2: With endpoint field
    Input:

     bonsol deploy --deploy-type <DEPLOY_TYPE> --bucket <BUCKET> --access-key <ACCESS_KEY> --secret-key <SECRET_KEY> --region <REGION> --url <URL> --manifest-path <MANIFEST_PATH> <--create|--storage-account <STORAGE_ACCOUNT>> --endpoint https://custom-s3-endpoint.com/...

    Expected: URL uses the custom endpoint https://custom-s3-endpoint.com/....


Checklist

  • Added endpoint field to S3UploadArgs.
  • Updated AmazonS3Builder logic for custom endpoint.
  • Tested with and without the endpoint field.

Related Issues

References

This update introduces an optional `endpoint` field to the `S3UploadArgs` struct, allowing users to specify a custom AWS S3 compatibility endpoint. The deployment function has been modified to utilize this new endpoint if provided, otherwise defaulting to the standard S3 URL format. This enhances flexibility for users working with different S3-compatible services.
Copy link

vercel bot commented Dec 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bonsol ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 11:05am

@eureka-cpu
Copy link
Contributor

Nice one, looks good to me. Happy to approve once the CI checks pass. Also just a heads up, I'm working on a refactor for the CLI so it should be a bit more clear which args you actually need for what command etc. 🙂

@eureka-cpu eureka-cpu added the bug Something isn't working label Dec 16, 2024
object_store::path::Path::from(format!("{}-{}", manifest.name, manifest.image_id));

let url = if let Some(endpoint) = endpoint {
format!("{}", endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since endpoint is already a String here I believe you can just return that instead of creating a new String with the format! macro

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For even more style points you could try (didn't test it but should be close):

let url = endpoint.unwrap_or(format!("https://{}.s3.{}.amazonaws.com/{}", bucket, region, dest));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I’ve updated the code to return the existing endpoint directly instead of using format!. Thanks for pointing it out!

Copy link
Contributor

@eureka-cpu eureka-cpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this @kidneyweakx 🙂

@eureka-cpu eureka-cpu changed the title feat: Add optional S3 endpoint to upload arguments fix: Add optional S3 endpoint to upload arguments Dec 16, 2024
@eureka-cpu eureka-cpu merged commit 5b3873b into anagrambuild:main Dec 16, 2024
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error deploying bonsol manifest.json with Cloudflare R2: Binary mismatch issue
2 participants