Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/BuildGraph/Tasks/DockerComposeUpTask.cs
josh engebretson d888e00d6d Horde: Change to --ansi never in compose up and down as well
#rnx
#jira none

#ROBOMERGE-AUTHOR: josh.engebretson
#ROBOMERGE-SOURCE: CL 17791440 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v881-17767770)

[CL 17794357 by josh engebretson in ue5-release-engine-test branch]
2021-10-12 21:46:48 -04:00

106 lines
2.9 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using AutomationTool;
using UnrealBuildBase;
namespace BuildGraph.Tasks
{
/// <summary>
/// Parameters for a Docker-Compose task
/// </summary>
public class DockerComposeUpTaskParameters
{
/// <summary>
/// Path to the docker-compose file
/// </summary>
[TaskParameter]
public string File;
/// <summary>
/// Arguments for the command
/// </summary>
[TaskParameter(Optional = true)]
public string Arguments;
}
/// <summary>
/// Spawns Docker and waits for it to complete.
/// </summary>
[TaskElement("Docker-Compose-Up", typeof(DockerComposeUpTaskParameters))]
public class DockerComposeUpTask : SpawnTaskBase
{
/// <summary>
/// Parameters for this task
/// </summary>
DockerComposeUpTaskParameters Parameters;
/// <summary>
/// Construct a Docker-Compose task
/// </summary>
/// <param name="InParameters">Parameters for the task</param>
public DockerComposeUpTask(DockerComposeUpTaskParameters InParameters)
{
Parameters = InParameters;
}
/// <summary>
/// Execute the task.
/// </summary>
/// <param name="Job">Information about the current job</param>
/// <param name="BuildProducts">Set of build products produced by this node.</param>
/// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
public override void Execute(JobContext Job, HashSet<FileReference> BuildProducts, Dictionary<string, HashSet<FileReference>> TagNameToFileSet)
{
StringBuilder Arguments = new StringBuilder("--ansi never ");
if (!String.IsNullOrEmpty(Parameters.File))
{
Arguments.Append($"--file {Parameters.File.QuoteArgument()} ");
}
Arguments.Append("up --detach");
if (!String.IsNullOrEmpty(Parameters.Arguments))
{
Arguments.Append($" {Parameters.Arguments}");
}
Log.TraceInformation("Running docker compose {0}", Arguments.ToString());
using (LogIndentScope Scope = new LogIndentScope(" "))
{
SpawnTaskBase.Execute("docker-compose", Arguments.ToString());
}
}
/// <summary>
/// Output this task out to an XML writer.
/// </summary>
public override void Write(XmlWriter Writer)
{
Write(Writer, Parameters);
}
/// <summary>
/// Find all the tags which are used as inputs to this task
/// </summary>
/// <returns>The tag names which are read by this task</returns>
public override IEnumerable<string> FindConsumedTagNames()
{
return Enumerable.Empty<string>();
}
/// <summary>
/// Find all the tags which are modified by this task
/// </summary>
/// <returns>The tag names which are modified by this task</returns>
public override IEnumerable<string> FindProducedTagNames()
{
return Enumerable.Empty<string>();
}
}
}