public DockerBinariesResolver(SudoMechanism sudo, string password, params string[] paths) { Binaries = ResolveFromPaths(sudo, password, paths).ToArray(); MainDockerClient = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.DockerClient); MainDockerCompose = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.Compose); MainDockerMachine = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.Machine); MainDockerCli = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.Cli); HasToolbox = Binaries.Any(x => x.IsToolbox); if (null == MainDockerClient) { Logger.Log("Failed to find docker client binary - please add it to your path"); throw new FluentDockerException("Failed to find docker client binary - please add it to your path"); } if (null == MainDockerCompose) { Logger.Log("Failed to find docker-compose client binary - please add it to your path"); } if (null == MainDockerMachine) { Logger.Log( "Failed to find docker-machine client binary - " + "please add it to your path. If you're running docker " + "2.2.0 or later you have to install it using " + "https://github.com/docker/machine/releases"); } }
public DockerBinariesResolver(params string [] paths) { Binaries = ResolveFromPaths(paths).ToArray(); MainDockerClient = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.DockerClient); MainDockerCompose = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.Compose); MainDockerMachine = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.Machine); MainDockerCli = Binaries.FirstOrDefault(x => !x.IsToolbox && x.Type == DockerBinaryType.Cli); HasToolbox = Binaries.Any(x => x.IsToolbox); if (null == MainDockerClient) { Logger.Log("Failed to find docker client binary - please add it to your path"); throw new FluentDockerException("Failed to find docker client binary - please add it to your path"); } if (null == MainDockerCompose) { Logger.Log("Failed to find docker-compose client binary - please add it to your path"); } if (null == MainDockerMachine) { Logger.Log("Failed to find docker-machine client binary - please add it to your path"); } }
public Dictionary <char, int> GetOrder() { if (Binaries.Any()) { var first = Binaries.First(); var order = new[] { first.Res, first.Left, first.Right }.Distinct().ToIndexed().ToDictionary(i => i.value, i => i.index); return(order); } else if (Unaries.Any()) { var first = Unaries.First(); var order = new[] { first.Res, first.Right }.ToIndexed().ToDictionary(i => i.value, i => i.index); return(order); } else { return(new Dictionary <char, int>()); } }
internal static FlashPlan GetPlan(BinarySet set, IReadOnlyCollection <ISetTool> tools) { (ISetTool tool, Binaries handled, Binaries remaining)? GetNextTool(string?targetPlatform, Binaries binaries) => tools.Select(tool => { var(handled, remaining) = tool.CanHandle(targetPlatform, binaries); return(tool, handled, remaining); }).SkipWhile(t => !t.handled.Any()) .Take(1) .Cast <(ISetTool, Binaries, Binaries)?>() .FirstOrDefault(); List <(ISetTool, Binaries)> output = new(); Binaries remaining = set.Binaries; while (remaining.Any()) { if (GetNextTool(set.TargetPlatform, remaining) is (ISetTool, Binaries, Binaries)value && value.handled.Any()) { output.Add((value.tool, value.handled)); remaining = value.remaining; }