public static Result <List <DeploymentInfo>, Error> GetDeploymentInfo(IReadOnlyList <string> stdout, string projectName) { if (stdout.Count == 0) { throw new ArgumentException("Cannot parse deployment list from empty stdout."); } try { // We expect the first line to have all the JSON. var deserialized = Json.Deserialize(stdout[0]); var deployments = (List <object>)deserialized["Deployments"]; return(Result <List <DeploymentInfo>, Error> .Ok(deployments.Select(depl => { var json = (Dictionary <string, object>)depl; return DeploymentInfo.FromJson(projectName, json); }).ToList())); } catch (InvalidCastException e) { return(Result <List <DeploymentInfo>, Error> .Error(new Error { Code = ErrorCode.CannotParseOutput, Message = $"Unable to parse the standard output. Raw exception: {e}\nRaw standard output: {string.Join("\n", stdout)}" })); } catch (KeyNotFoundException e) { return(Result <List <DeploymentInfo>, Error> .Error(new Error { Code = ErrorCode.CannotParseOutput, Message = $"Unable to parse the standard output. Raw exception: {e}\nRaw standard output: {string.Join("\n", stdout)}" })); } }
public void Stop(DeploymentInfo info, QueueMode mode = QueueMode.Enqueue) { AddTask(mode, () => Deployment.StopAsync(info)); }