Skip to content

Commit

Permalink
Closes #95 Adds docker compose cp command
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaMarkic committed Feb 19, 2022
1 parent 543b79b commit 297a98f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Including addin in cake script is easy.

**BREAKING** Starting with 0.8.0 command's setting types that haven't been composed of all words have changed to full name. i.e. DockerBuildSettings to DockerImageBuildSettings).

- [DockerComposeCp](https://docs.docker.com/engine/reference/commandline/compose_cp/) v1.1.1
- [DockerBuildXBake](https://docs.docker.com/engine/reference/commandline/buildx_bake/) v1.1.0
- [DockerBuildXBuild](https://docs.docker.com/engine/reference/commandline/buildx_build/) v1.1.0
- [DockerBuildXCreate](https://docs.docker.com/engine/reference/commandline/buildx_create/) v1.1.0
Expand Down
2 changes: 1 addition & 1 deletion args-parser-2.linq
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Query Kind="Statements" />

string path = @"BuildX\Bake";
string path = @"Compose\Cp";
string file = Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath)!, $@"src\Cake.Docker\{path}\args.txt");
//string file = @"D:\GitProjects\Righthand\Cake\Cake.Docker\src\Cake.Docker\Compose\Up\args.txt";
string[] lines = File.ReadAllLines(file);
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Docker/Cake.Docker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<IncludeSymbols>true</IncludeSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageReleaseNotes>See https://github.com/MihaMarkic/Cake.Docker/blob/master/ReleaseNotes.md</PackageReleaseNotes>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<PackageIconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/addin/cake-contrib-addin-medium.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down
47 changes: 47 additions & 0 deletions src/Cake.Docker/Compose/Cp/Docker.Aliases.ComposeCp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Cake.Core;
using Cake.Core.Annotations;
using System;

namespace Cake.Docker
{
// Contains functionality for working with docker compose cp command.
partial class DockerAliases
{
/// <summary>
/// Runs docker compose cp with default settings.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="source">Source path.</param>
/// <param name="destination">Destination path.</param>
[CakeMethodAlias]
public static void DockerComposeCp(this ICakeContext context, string source, string destination)
{
DockerComposeCp(context, source, destination, new DockerComposeCpSettings());
}
/// <summary>
/// Copy files from/to container given <paramref name="settings"/>.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="source">Source path.</param>
/// <param name="destination">Destination path.</param>
/// <param name="settings">The settings.</param>
[CakeMethodAlias]
public static void DockerComposeCp(this ICakeContext context, string source, string destination, DockerComposeCpSettings settings)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (string.IsNullOrEmpty(source))
{
throw new ArgumentNullException(nameof(source));
}
if (string.IsNullOrEmpty(destination))
{
throw new ArgumentNullException(nameof(destination));
}
var runner = new GenericDockerRunner<DockerComposeCpSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
runner.Run("compose cp", settings ?? new DockerComposeCpSettings(), new string[] { source, destination });
}
}
}
26 changes: 26 additions & 0 deletions src/Cake.Docker/Compose/Cp/DockerComposeCpSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Cake.Docker
{
/// <summary>
/// Settings for docker compose cp.
/// </summary>
public sealed class DockerComposeCpSettings : AutoToolSettings
{
/// <summary>
/// Copy to all the containers of the service.
/// </summary>
public bool All { get; set; }
/// <summary>
/// Archive mode (copy all uid/gid information)
/// </summary>
public bool Archive { get; set; }
/// <summary>
/// Always follow symbol link in SRC_PATH
/// </summary>
public bool FollowLink { get; set; }
/// <summary>
/// Index of the container if there are multiple
/// instances of a service [default: 1]. (default 1)
/// </summary>
public int? Index { get; set; }
}
}
5 changes: 5 additions & 0 deletions src/Cake.Docker/Compose/Cp/args.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
 --all Copy to all the containers of the service.
-a, --archive Archive mode (copy all uid/gid information)
-L, --follow-link Always follow symbol link in SRC_PATH
--index int Index of the container if there are multiple
instances of a service [default: 1]. (default 1)

0 comments on commit 297a98f

Please sign in to comment.