Bind mounts support for docker compose (#245)#286
Bind mounts support for docker compose (#245)#286dombrovsky wants to merge 1 commit intoprom3theu5:mainfrom
Conversation
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Thanks buddy I've merged in your other PR so you will need to rebase this one more time (Sorry) |
97949d0 to
47c9839
Compare
47c9839 to
80c9aff
Compare
Sure mate! Thanks for maintaining this awesome tool! My pleasure to contribute. |
| if (service.Volumes is not null) | ||
| { | ||
| volumes.AddRange(service.Volumes.Select(volume => new Volume { Name = volume.Split(':')[0] })); | ||
| volumes.AddRange(service.Volumes.Where(volume => !volume.Split(':')[0].Contains('/')).Select(volume => new Volume { Name = volume.Split(':')[0] })); |
There was a problem hiding this comment.
Suggestion: Add null safety checks
| volumes.AddRange(service.Volumes.Where(volume => !volume.Split(':')[0].Contains('/')).Select(volume => new Volume { Name = volume.Split(':')[0] })); | |
| volumes.AddRange(service.Volumes.Where(volume => !string.IsNullOrEmpty(volume) && volume.Contains(':') && !volume.Split(':')[0].Contains('/')).Select(volume => new Volume { Name = volume.Split(':')[0] })); |
| composeVolumes.AddRange(resourceWithVolumes.Volumes.Where(x=>!string.IsNullOrWhiteSpace(x.Name)).Select(volume => $"{volume.Name}:{volume.Target}")); | ||
| if (resource.Value is IResourceWithBindMounts resourceWithBindMounts) | ||
| { | ||
| composeVolumes.AddRange(resourceWithBindMounts.BindMounts.Select(volume => $"./{Path.GetRelativePath(outputPath, volume.Source).Replace(Path.DirectorySeparatorChar, '/')}:{volume.Target}")); |
There was a problem hiding this comment.
Suggestion: Validate bind mount paths
| composeVolumes.AddRange(resourceWithBindMounts.BindMounts.Select(volume => $"./{Path.GetRelativePath(outputPath, volume.Source).Replace(Path.DirectorySeparatorChar, '/')}:{volume.Target}")); | |
| composeVolumes.AddRange(resourceWithBindMounts.BindMounts.Where(volume => !string.IsNullOrEmpty(volume.Source) && !string.IsNullOrEmpty(volume.Target)).Select(volume => $"./{Path.GetRelativePath(outputPath, volume.Source).Replace(Path.DirectorySeparatorChar, '/')}:{volume.Target}")); |
User description
resolves #245
PR Type
Enhancement, Bug fix
Description
Added support for bind mounts in Docker Compose manifests.
Introduced
BindMountmodel and related interface for resource handling.Enhanced volume mapping logic to include bind mounts.
Fixed issue where bind mounts were ignored during manifest application.
Changes walkthrough 📝
GenerateDockerComposeManifestAction.cs
Refined volume creation logic for Docker Composesrc/Aspirate.Commands/Actions/Manifests/GenerateDockerComposeManifestAction.cs
ContainerProcessor.cs
Support bind mounts in compose entry creationsrc/Aspirate.Processors/Resources/AbstractProcessors/ContainerProcessor.cs
CreateComposeEntryto include bind mounts in volume mapping.OutputPathfor relative path resolution in bind mounts.ResourceExtensions.cs
Extend volume mapping to include bind mountssrc/Aspirate.Shared/Extensions/ResourceExtensions.cs
MapComposeVolumesto handle bind mounts.BindMount.cs
Add `BindMount` model for bind mount supportsrc/Aspirate.Shared/Models/AspireManifests/Components/V0/BindMount.cs
BindMountclass for bind mount configurations.ContainerResource.cs
Extend `ContainerResource` to support bind mountssrc/Aspirate.Shared/Models/AspireManifests/Components/V0/Container/ContainerResource.cs
BindMountsproperty toContainerResource.IResourceWithBindMountsinterface.IResourceWithBindMounts.cs
Add interface for resources with bind mountssrc/Aspirate.Shared/Models/AspireManifests/Interfaces/IResourceWithBindMounts.cs
IResourceWithBindMountsinterface.BindMountsproperty for resources.