コード例 #1
0
ファイル: DockerProcessWrapper.cs プロジェクト: DevTeam/flow
 public DockerProcessWrapper(
     [NotNull] IDockerArgumentsProvider dockerArgumentsProvider,
     DockerWrapperInfo wrapperInfo)
 {
     _dockerArgumentsProvider = dockerArgumentsProvider;
     _wrapperInfo             = wrapperInfo;
 }
コード例 #2
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}");
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        private IEnumerable <DockerVolume> GetVolumes(DockerWrapperInfo wrapperInfo, ProcessInfo processInfo)
        {
            var baseValues = new []
            {
                _tempDirectory,
                _workingDirectory,
                processInfo.WorkingDirectory
            };

            return(baseValues
                   .Where(i => !i.IsEmpty)
                   .Select(i => i.Value)
                   .Distinct()
                   .Select(System.IO.Path.GetFullPath)
                   .Where(i => !string.IsNullOrWhiteSpace(i))
                   .Select(i => new Path(i))
                   .Where(_fileSystem.DirectoryExists)
                   .Select(i => i.Value)
                   .Select(value => new DockerVolume(value, value))
                   .Concat(wrapperInfo.Volumes)
                   .Distinct());
        }
コード例 #5
0
ファイル: DockerWrapperService.cs プロジェクト: DevTeam/flow
 public IDisposable Using(DockerWrapperInfo info) =>
 Disposable.Create(
     _envChain.Append(_virtualEnvironment.Set(info.Platform).Set(info.Platform)),
     _processChain.Append(_dockerProcessWrapperFactory(info)),
     _processChain.Append(info.Platform == OperatingSystem.Windows ? _cmdProcessWrapper : _shProcessWrapper));
コード例 #6
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);
            }
        }