public static string DockerCreate(this ICakeContext context, DockerContainerCreateSettings settings, string image, string command, params string[] args) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(image)) { throw new ArgumentNullException("image"); } var runner = new GenericDockerRunner <DockerContainerCreateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); List <string> arguments = new List <string> { image }; if (!string.IsNullOrEmpty(command)) { arguments.Add(command); if (args.Length > 0) { arguments.AddRange(args); } } return(runner.RunWithResult("create", settings ?? new DockerContainerCreateSettings(), r => r.ToArray(), arguments.ToArray()) .FirstOrDefault()); }
public static IEnumerable <string> DockerCustomCommand(this ICakeContext context, DockerCustomCommandSettings settings, string command) { if (context == null) { throw new ArgumentNullException("context"); } if (settings == null) { throw new ArgumentNullException("settings"); } if (string.IsNullOrEmpty(command)) { throw new ArgumentNullException("command"); } var runner = new GenericDockerRunner <DockerCustomCommandSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); string commandName = command; string commandArguments = ""; var space = command.IndexOf(" "); if (space > -1) { commandName = command.Substring(0, space); commandArguments = command.Substring(space); } return(runner.RunWithResult(commandName, settings, r => r.ToArray(), new[] { commandArguments })); }
public static void DockerBuild(this ICakeContext context, DockerImageBuildSettings settings, string path) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } var runner = new GenericDockerRunner <DockerImageBuildSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); // quote path if not already quoted string quotedPath; if (!string.IsNullOrEmpty(path)) { string trimmed = path.Trim(); if (trimmed.Length > 1 && trimmed.StartsWith("\"") && trimmed.EndsWith("\"")) { quotedPath = path; } else { quotedPath = $"\"{path}\""; } } else { quotedPath = path; } runner.Run("build", settings ?? new DockerImageBuildSettings(), new string[] { quotedPath }); }
public static void DockerRun(this ICakeContext context, DockerRunSettings settings, string image, string command, params string[] args) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(image)) { throw new ArgumentNullException("image"); } var runner = new GenericDockerRunner <DockerRunSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber); List <string> arguments = new List <string> { image }; if (!string.IsNullOrEmpty(command)) { arguments.Add(command); if (args.Length > 0) { arguments.AddRange(args); } } runner.Run("run", settings ?? new DockerRunSettings(), arguments.ToArray()); }
public static void DockerNetworkConnect(this ICakeContext context, DockerNetworkConnectSettings settings, string network, string container, params string[] args) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(network)) { throw new ArgumentNullException("network"); } if (string.IsNullOrEmpty(container)) { throw new ArgumentNullException("container"); } var runner = new GenericDockerRunner <DockerNetworkConnectSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); List <string> arguments = new List <string> { network, container }; if (args.Length > 0) { arguments.AddRange(args); } runner.Run("network connect", settings ?? new DockerNetworkConnectSettings(), arguments.ToArray()); }
public static IEnumerable <string> DockerImageLs(this ICakeContext context, DockerImageLsSettings settings) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var runner = new GenericDockerRunner <DockerImageLsSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); return(runner.RunWithResult("image ls", settings ?? new DockerImageLsSettings(), r => r.ToArray())); }
public static void DockerBuildXBuild(this ICakeContext context, DockerBuildXBuildSettings settings, string target) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerBuildXBuildSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("buildx build", settings ?? new DockerBuildXBuildSettings(), new[] { target }); }
public static void DockerBuildXStop(this ICakeContext context, DockerBuildXStopSettings settings = null, string name = null) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var runner = new GenericDockerRunner <DockerBuildXStopSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("buildx stop", new DockerBuildXStopSettings(), new string[] { name }); }
public static void DockerBuildXImageToolsCreate(this ICakeContext context, DockerBuildXImageToolsCreateSettings settings, IEnumerable <string> target = null) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerBuildXImageToolsCreateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("buildx imagetools create", settings ?? new DockerBuildXImageToolsCreateSettings(), target?.ToArray() ?? Array.Empty <string>()); }
public static void DockerLoad(this ICakeContext context, DockerLoadSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerLoadSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber); runner.Run("load", settings ?? new DockerLoadSettings(), new string[0]); }
public static void DockerBuildXCreate(this ICakeContext context, DockerBuildXCreateSettings settings, string target = null) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerBuildXCreateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("buildx create", settings ?? new DockerBuildXCreateSettings(), target != null ? new[] { target }: Array.Empty <string>()); }
public static DockerPsResult[] DockerPs(this ICakeContext context, DockerPsSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerPsSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber); return(runner.RunWithResult("ps", settings ?? new DockerPsSettings(), Processor)); }
public static void DockerBuildXInstall(this ICakeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var runner = new GenericDockerRunner <DockerBuildXInstallSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("buildx install", new DockerBuildXInstallSettings(), Array.Empty <string>()); }
public static void DockerVolumeCreate(this ICakeContext context, DockerVolumeCreateSettings settings, string volume) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerVolumeCreateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("volume create", settings ?? new DockerVolumeCreateSettings(), new string[] { volume }); }
public static string DockerPs(this ICakeContext context, DockerContainerPsSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerContainerPsSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); var result = runner.RunWithResult("ps", settings ?? new DockerContainerPsSettings(), r => r.ToArray()); return(string.Join("\n", result)); }
public static void DockerManifestAnnotate(this ICakeContext context, DockerManifestAnnotateSettings settings, string manifestList, string manifest) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var runner = new GenericDockerRunner <DockerManifestAnnotateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); List <string> arguments = new List <string> { manifestList, manifest }; runner.Run("manifest annotate", settings ?? new DockerManifestAnnotateSettings(), arguments.ToArray()); }
public static void DockerVolumeRm(this ICakeContext context, DockerVolumeRmSettings settings, string[] volumes) { if (context == null) { throw new ArgumentNullException("context"); } if (volumes?.Length < 1) { throw new ArgumentNullException(nameof(volumes), "At least one volume is required"); } var runner = new GenericDockerRunner <DockerVolumeRmSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("volume rm", settings ?? new DockerVolumeRmSettings(), volumes); }
public static IEnumerable <string> DockerBuildXImageToolsInspect(this ICakeContext context, DockerBuildXImageToolsInspectSettings settings, string name) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (name.Length < 1) { throw new ArgumentNullException(nameof(name), "Name is required"); } var runner = new GenericDockerRunner <DockerBuildXImageToolsInspectSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); return(runner.RunWithResult("buildx imagetools inspect", settings ?? new DockerBuildXImageToolsInspectSettings(), r => r.ToArray(), name)); }
public static IEnumerable <string> DockerVolumeInspect(this ICakeContext context, DockerVolumeInspectSettings settings, string[] volumes) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (volumes?.Length < 1) { throw new ArgumentNullException(nameof(volumes), "At least one volume is required"); } var runner = new GenericDockerRunner <DockerVolumeInspectSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); return(runner.RunWithResult("volume inspect", settings ?? new DockerVolumeInspectSettings(), r => r.ToArray(), volumes)); }
public static void DockerLogs(this ICakeContext context, DockerContainerLogsSettings settings, string container) { if (context == null) { throw new ArgumentNullException("context"); } if (container == null) { throw new ArgumentNullException("container"); } var runner = new GenericDockerRunner <DockerContainerLogsSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("start", settings ?? new DockerContainerLogsSettings(), new string[] { container }); }
public static void DockerSave(this ICakeContext context, DockerSaveSettings settings, params string[] images) { if (context == null) { throw new ArgumentNullException("context"); } if (images == null || images.Length == 0) { throw new ArgumentNullException("images"); } var runner = new GenericDockerRunner <DockerSaveSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("save", settings ?? new DockerSaveSettings(), images); }
public static IEnumerable <string> DockerLogs(this ICakeContext context, DockerContainerLogsSettings settings, string container) { if (context == null) { throw new ArgumentNullException("context"); } if (container == null) { throw new ArgumentNullException("container"); } var runner = new GenericDockerRunner <DockerContainerLogsSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); return(runner.RunWithResult("logs", settings ?? new DockerContainerLogsSettings(), r => r.ToArray(), new string[] { container })); }
public static void DockerStop(this ICakeContext context, DockerStopSettings settings, params string[] containers) { if (context == null) { throw new ArgumentNullException("context"); } if (containers == null || containers.Length == 0) { throw new ArgumentNullException("containers"); } var runner = new GenericDockerRunner <DockerStopSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber); runner.Run("stop", settings ?? new DockerStopSettings(), containers); }
public static void DockerBuild(this ICakeContext context, DockerBuildSettings settings, string path) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } var runner = new GenericDockerRunner <DockerBuildSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("build", settings ?? new DockerBuildSettings(), new string[] { path }); }
public static void DockerPull(this ICakeContext context, DockerImagePullSettings settings, string imageReference) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(imageReference)) { throw new ArgumentNullException("imageReference"); } var runner = new GenericDockerRunner <DockerImagePullSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("pull", settings ?? new DockerImagePullSettings(), new [] { imageReference }); }
public static void DockerLogin(this ICakeContext context, DockerRegistryLoginSettings settings, string server = null) { if (context == null) { throw new ArgumentNullException("context"); } if (settings == null) { throw new ArgumentNullException("settings"); } var runner = new GenericDockerRunner <DockerRegistryLoginSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("login", settings, server != null ? new[] { server } : new string[] { }); }
public static void DockerSwarmUpdate(this ICakeContext context, DockerSwarmUpdateSettings settings, params string[] args) { if (context == null) { throw new ArgumentNullException("context"); } var runner = new GenericDockerRunner <DockerSwarmUpdateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber); List <string> arguments = new List <string> (); if (args.Length > 0) { arguments.AddRange(args); } runner.Run("swarm update", settings ?? new DockerSwarmUpdateSettings(), arguments.ToArray()); }
public static void DockerManifestCreate(this ICakeContext context, DockerManifestCreateSettings settings, string manifestList, string manifest, params string[] manifests) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var runner = new GenericDockerRunner <DockerManifestCreateSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); List <string> arguments = new List <string> { manifestList, manifest }; if (manifests?.Length > 0) { arguments.AddRange(manifests); } runner.Run("manifest create", settings ?? new DockerManifestCreateSettings(), arguments.ToArray()); }
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 }); }
public static void DockerCp(this ICakeContext context, string from, string to, DockerCpSettings settings) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(from)) { throw new ArgumentNullException("path"); } if (string.IsNullOrEmpty(to)) { throw new ArgumentNullException("to"); } var runner = new GenericDockerRunner <DockerCpSettings>(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); runner.Run("cp", settings ?? new DockerCpSettings(), new string[] { from, to }); }