Ejemplo n.º 1
0
        public static Task <List <ConsoleMessage> > ExecuteScript(string pathToScript)
        {
            var command = $"{pathToScript}";
            var process = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, "", "./", message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 2
0
        public static Task <List <ConsoleMessage> > InspectDockerContainer(string containerId, string format)
        {
            var command = "docker";
            var args    = Host + " inspect " + format + " " + containerId;
            var process = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, "./", message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 3
0
        public static Task <List <ConsoleMessage> > RemoveDockerContainer(string nameOfApplication)
        {
            var command = "docker";
            var args    = $"{Host} rm {nameOfApplication}";
            var process = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, "./", message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 4
0
        public static Task <List <ConsoleMessage> > StartDockerImage(string nameOfApplication, string port, string directoryOfDockerfile)
        {
            var process = new ProcessExecutor();
            var command = "docker";
            var args    = $"{Host} start {nameOfApplication}";

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, directoryOfDockerfile, message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 5
0
        public static Task <List <ConsoleMessage> > BuildDotnetBinary(string locationOfCode)
        {
            var command = "dotnet";
            var args    = "publish -c Release -o out";
            var process = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, locationOfCode, message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 6
0
        public static Task <List <ConsoleMessage> > RestoreDotnetPackages(string locationOfCode)
        {
            var command = "dotnet";
            var args    = "restore";
            var process = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, locationOfCode, message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 7
0
        public static Task <List <ConsoleMessage> > CopyFileToContainer(string nginxName, string hostPath, string containerPath)
        {
            Console.WriteLine($"[DEBUG]: CopyFileToContainer {nginxName} {hostPath} {containerPath}");
            var command = "docker";
            var args    = $"{Host} cp {hostPath} {nginxName}:{containerPath}";
            var process = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, "./", message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 8
0
        public static Task <List <ConsoleMessage> > ExecuteCommand(string nameOfNginxService, string command)
        {
            Console.WriteLine($"[DEBUG]: ExecuteCommand {nameOfNginxService} {command}");
            var dockerCommand = "docker";
            var args          = $"{Host} exec -d {nameOfNginxService} {command}";
            var process       = new ProcessExecutor();

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(dockerCommand, args, "./", message => t.TrySetResult(message));
                return t.Task;
            }));
        }
Ejemplo n.º 9
0
        public static Task <List <ConsoleMessage> > RunDockerImage(string nameOfApplication, string port, string directoryOfDockerfile)
        {
            var process = new ProcessExecutor();
            var command = "docker";
            var args    = "";

            if (string.IsNullOrEmpty(port))
            {
                args = $"{Host} run --name {nameOfApplication} -d -P supermitsuba/{nameOfApplication}:1";
            }
            else
            {
                args = $"{Host} run --name {nameOfApplication} -d -p {port} supermitsuba/{nameOfApplication}:1";
            }

            return(Task <List <ConsoleMessage> > .Run(() =>
            {
                var t = new TaskCompletionSource <List <ConsoleMessage> >();
                process.ExecuteCLIWithResult(command, args, directoryOfDockerfile, message => t.TrySetResult(message));
                return t.Task;
            }));
        }