Skip to content

Add Minio hosting/client integration #691

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

Merged
merged 18 commits into from
Jun 6, 2025

Conversation

Harold-Morgan
Copy link
Contributor

@Harold-Morgan Harold-Morgan commented May 18, 2025

**Closes #606 **

I've added maybe somewhat barebone (but working!) MiniO storage and client (based on the official https://github.com/minio/minio-dotnet library). It was a ton of fun.

I've added

SkipIfKeyedRegistrationIsNotSupported(useKey);

to ConformanceTests.cs/ConnectionInformationIsDelayValidated because this integration doesn't support keyed registrations untill minio/minio-dotnet#1147 is resolved. I hope this isn't too much, but maybe it should've been done in separate PR.

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

@ctolkien
Copy link

Would love to see this get finished off.

IResourceBuilder<ParameterResource>? rootUser = null,
IResourceBuilder<ParameterResource>? rootPassword = null,
int minioPort = 9000,
int minioConsolePort = 9001)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove, this is usually fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

This is usually fixed, and thinking too much about Minio Console should probably be out of scope for now.


namespace CommunityToolkit.Aspire.Hosting.Minio;

internal sealed class MinioHealthCheck : IHealthCheck
Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to use the built in http health check instead of the custom one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Built in http health check using .AddUrlGroup method really looks better

Thx for comment

Copy link
Contributor

Choose a reason for hiding this comment

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

Well there’s an even more built in method WithHttpHealthCheck

@davidfowl
Copy link
Contributor

This looks really good! Left a few comments.

@Harold-Morgan
Copy link
Contributor Author

I've added WithDataVolume/WithDataBindMount methods to this, because even a basic S3-compatible storage integration wihtout the way to permanently store data isn't up to my personal quality standarts

Also working on @davidfowl comments got me thinking that me "inventing" a connection string for MiniO looking like

"Endpoint=http://localhost:2000;AccessKey=minioadmin;SecretKey=p@ssw0rd1"

may not have been such a good idea (here's a link for further reference)

But currently I cannot think about any other convinient way of passing connection parameters to ApiServices in a DistributedApplication.

I'd be genuinely glad to hear any opinions on this

@davidfowl
Copy link
Contributor

may not have been such a good idea (here's a link for further reference)

It's a good idea. Just expose all of the parts of the connection string so the users can make their own connection strings, but having a default is good.

@Harold-Morgan Harold-Morgan marked this pull request as ready for review May 29, 2025 15:14
@Harold-Morgan Harold-Morgan marked this pull request as draft May 29, 2025 15:52
@Harold-Morgan
Copy link
Contributor Author

I've fixed my silly little tests that were conflicting with port randomization

Now it looks ready

@Harold-Morgan Harold-Morgan marked this pull request as ready for review May 29, 2025 19:24
@Harold-Morgan Harold-Morgan requested a review from davidfowl June 2, 2025 14:30
Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Got a few changes I've noted.

Also, the MinIO docs have the IO part in all capitals (as does the NuGet package), but there's inconsistency in the readme/doc comments - can we have that updated to match the product naming please.

Comment on lines 18 to 22
public MinioContainerResource(string name, ParameterResource user, ParameterResource password) : base(name)
{
RootUser = user;
PasswordParameter = password;
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you use a primary constructor for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it looks much cleaner now, thanks!

Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode);

var getResponse = await httpClient.GetAsync($"/buckets/{bucketName}");
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
Copy link
Member

Choose a reason for hiding this comment

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

Can we assert on the returned value, not just the status code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've expanded the test a bit, so we can actually upload a string object, then download it and check the result

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

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

@Harold-Morgan - I noticed you've added yourself to the CODEOWNERS - are you happy to be added as a contributor to the repo as the long-term owner of the integration?

@Harold-Morgan
Copy link
Contributor Author

Harold-Morgan commented Jun 4, 2025

I would definitely be more than happy to be added as a long-term owner of the integration.

I was planning on adding features and solving issues in the future myself, it is a wonderful opportunity to learn!

@aaronpowell I must note that I haven't yet addressed all the comments in this review (but definitely plan to do so), but you have approved it. Is this ok? I think that I definitely must address all of them in this PR before merging

@aaronpowell
Copy link
Member

Sorry, that was a mistake on the approval - notifications took me to only seeing some of the changes and I forgot I had more on the list outstanding so I've rolled it back to waiting approval.

@max2020204
Copy link

When it can be available from NuGet package?

@Harold-Morgan Harold-Morgan requested a review from aaronpowell June 5, 2025 15:43
@aaronpowell aaronpowell merged commit 0b672c6 into CommunityToolkit:main Jun 6, 2025
94 checks passed
@aaronpowell
Copy link
Member

When it can be available from NuGet package?

A preview package should be on NuGet soon (takes a few days to go through approval), but you can always use the Azure DevOps feed as described on the README

@ctolkien
Copy link

ctolkien commented Jun 6, 2025

@Harold-Morgan - thanks for doing this!!

@davidfowl
Copy link
Contributor

Really high quality work @Harold-Morgan !

@Harold-Morgan
Copy link
Contributor Author

Really high quality work @Harold-Morgan !

j2hkcly5xc781.png

Jokes aside, sincerely thank you and @aaronpowell for help!

I hope and plan to do more

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.

Add Minio/S3 hosting and client library
5 participants