Exemplo n.º 1
0
 public ProcessInfo Wrap(ProcessInfo processInfo) =>
 new ProcessInfo(
     "wsl",
     processInfo.WorkingDirectory,
     new [] { new CommandLineArgument(processInfo.Executable.Value) }.Concat(processInfo.Arguments),
     Enumerable.Empty <EnvironmentVariable>());
Exemplo n.º 2
0
 public ProcessInfo Wrap(ProcessInfo processInfo) =>
 new ProcessInfo(
     "docker",
     processInfo.WorkingDirectory,
     _dockerArgumentsProvider.GetArguments(_wrapperInfo, processInfo),
     processInfo.Variables);
Exemplo n.º 3
0
        public IEnumerable <CommandLineArgument> GetArguments(DockerWrapperInfo wrapperInfo, ProcessInfo processInfo)
        {
            yield return("run");

            yield return("-it");

            if (wrapperInfo.AutomaticallyRemove)
            {
                yield return("--rm");
            }

            yield return("--platform");

            switch (wrapperInfo.Platform)
            {
            case OperatingSystem.Windows:
                yield return("windows");

                break;

            case OperatingSystem.Unix:
                yield return("linux");

                break;

            case OperatingSystem.Mac:
                throw new NotSupportedException();

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (wrapperInfo.Pull)
            {
            case DockerPullType.Missing:
                break;

            case DockerPullType.Always:
                yield return("--pull");

                yield return("always");

                break;

            case DockerPullType.Never:
                yield return("--pull");

                yield return("never");

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (!processInfo.WorkingDirectory.IsEmpty)
            {
                yield return($"--workdir={_pathNormalizer().Normalize(processInfo.WorkingDirectory)}");
            }

            var args =
                new[] { _dockerEnvironmentArgumentsProvider, _dockerVolumesArgumentsProvider }
            .SelectMany(i => i.GetArguments(wrapperInfo, processInfo));

            foreach (var arg in args)
            {
                yield return(arg);
            }

            foreach (var argument in wrapperInfo.Arguments)
            {
                yield return(argument);
            }

            yield return(wrapperInfo.Image.Name);

            yield return(processInfo.Executable.Value);

            foreach (var arg in processInfo.Arguments)
            {
                yield return(arg);
            }
        }
Exemplo n.º 4
0
        public IEnumerable <CommandLineArgument> GetArguments(DockerWrapperInfo wrapperInfo, ProcessInfo processInfo)
        {
            if (wrapperInfo.EnvironmentVariables.Any())
            {
                _fileSystem.WriteLines(_envFilePath, wrapperInfo.EnvironmentVariables.Select(i => $"{i.Name}=\"{i.Value}\""));
                yield return("--env-file");

                yield return(_envFilePath.Value);
            }
        }
Exemplo n.º 5
0
        public IEnumerable <CommandLineArgument> GetArguments(DockerWrapperInfo wrapperInfo, ProcessInfo processInfo)
        {
            foreach (var volume in GetVolumes(wrapperInfo, processInfo))
            {
                yield return("-v");

                yield return($"{volume.HostPath.Value}:{_pathNormalizer().Normalize(volume.ContainerPath).Value}");
            }
        }