-
Notifications
You must be signed in to change notification settings - Fork 609
Add support for copying existing files via WithContainerFiles API #8908
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for copying existing files via the WithContainerFiles API, replacing the previous bind mount mechanism for realm imports in Keycloak.
- Updated tests to validate the new ContainerFileSystemCallbackAnnotation functionality via asynchronous execution.
- Modified the Container model to enforce that file entries use either SourcePath or Contents but not both.
- Updated the KeycloakResourceBuilderExtensions to utilize the WithContainerFiles API using new C# 12 collection patterns.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/Aspire.Hosting.Keycloak.Tests/KeycloakPublicApiTests.cs | Updated test methods to async, altered assertions to verify ContainerFileSystemCallbackAnnotation usage. |
src/Aspire.Hosting/Dcp/Model/Container.cs | Added Source assignment from SourcePath and mutual exclusion check between Contents and SourcePath. |
src/Aspire.Hosting/ApplicationModel/ContainerFileSystemCallbackAnnotation.cs | Updated documentation for ContainerFile to clarify mutual exclusion semantics between Contents and SourcePath. |
src/Aspire.Hosting/Keycloak/KeycloakResourceBuilderExtensions.cs | Switched from WithBindMount to WithContainerFiles using new collection initialization syntax. |
Comments suppressed due to low confidence (1)
tests/Aspire.Hosting.Keycloak.Tests/KeycloakPublicApiTests.cs:224
- The variable 'file' is used in the assertion but is not defined anywhere in the test. Consider defining it (e.g., var file = Path.GetFileName(filePath);) before using it in assertions.
Assert.Equal(file, realmFile.Name);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No bind mount 😍
/// </summary> | ||
public string? Contents { get; set; } | ||
|
||
/// <summary> | ||
/// The path to a file on the host system to copy into the container. This path must be absolute and point to a file on the host system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the path need to be absolute? We can use relative paths elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t explicitly check for an absolute path; it’s more of a SHOULD requirement. We can’t necessarily guarantee the orchestrator and container runtime will have the correct working directory in all scenarios, so absolute paths guarantees consistent behavior. We probably should call out the same for the bind mount annotation.
Are there any direct tests that can be added for this functionality? If we ever deleted Keycloak (unlikely) we wouldn't have any coverage. |
Description
Adds the ability to specify an existing file via
WithContainerFiles
instead of having to specify the contents of a file. Uses the same permission mechanics and slots into the existing ability to create arbitrary files and folders. Specifically, aContainerFile
type passed toWithContainerFiles
can take either aContents
property orSourcePath
property (an exception will be thrown if both are set).Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template