Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Adeotek.DevOpsTools/Adeotek.DevOpsTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Product>AdeoTEK DevOps Tools</Product>
<Authors>George Benjamin-Schonberger</Authors>
<Copyright>George Benjamin-Schonberger 2024</Copyright>
<Version>0.6.0</Version>
<Version>0.6.1</Version>
<PackageId>Adeotek.DevOpsTools</PackageId>
<PackageTags>cli,devops,tools,docker,podman</PackageTags>
<PackageProjectUrl>https://adeotek.github.io/dot/</PackageProjectUrl>
Expand All @@ -21,7 +21,7 @@
<PackageIcon>PackageIcon.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>0.6.0</PackageVersion>
<PackageVersion>0.6.1</PackageVersion>
<PackAsTool>true</PackAsTool>
<ToolCommandName>dot</ToolCommandName>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>AdeoTEK Extensions Containers</Product>
<Authors>George Benjamin-Schonberger</Authors>
<Copyright>George Benjamin-Schonberger 2024</Copyright>
<Version>0.6.0</Version>
<Version>0.6.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 22 additions & 8 deletions src/Adeotek.Extensions.Containers/ContainersCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,7 @@ public int CreateVolume(string volumeName, bool dryRun = false)

public int CreateBindVolume(VolumeConfig volume, bool dryRun = false)
{
var changes = 0;
LogCommand("mkdir", volume.Source);
if (!dryRun)
{
Directory.CreateDirectory(volume.Source);
changes++;
}

var changes = CreateVolumeDirectory(volume.Source, dryRun);
if (ShellCommand.IsWindowsPlatform)
{
return changes;
Expand Down Expand Up @@ -551,6 +544,27 @@ public bool ArchiveVolume(string volumeName, string archiveFile, bool dryRun = f
throw new ContainersCliException("run", 1, $"Unable to archive volume '{volumeName}' into '{archiveFile}'!");
}

protected int CreateVolumeDirectory(string volumeSource, bool dryRun = false)
{
var missingPath = volumeSource.EndsWith(Path.DirectorySeparatorChar)
? volumeSource[..^1]
: Path.GetDirectoryName(volumeSource);

if (string.IsNullOrEmpty(missingPath) || Directory.Exists(missingPath))
{
return 0;
}

LogCommand("mkdir", missingPath);
if (dryRun)
{
return 0;
}

Directory.CreateDirectory(missingPath);
return 1;
}

protected void LogMessage(string message, string level = "info")
{
if (OnContainersCliEvent is null)
Expand Down