diff --git a/src/Cake.Terraform/HtmlFormatter.cs b/src/Cake.Terraform/HtmlFormatter.cs index afd4741..ba1454a 100644 --- a/src/Cake.Terraform/HtmlFormatter.cs +++ b/src/Cake.Terraform/HtmlFormatter.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; +using System.Net; namespace Cake.Terraform { @@ -73,12 +74,12 @@ public override string FormatLines(IEnumerable lines) { var match = regex.Match(line); if(match.Success) { - var styledLine = $"{match.Groups[1].Value}{match.Groups[3].Value}"; + var styledLine = $"{WebUtility.HtmlEncode(match.Groups[1].Value)}{WebUtility.HtmlEncode(match.Groups[3].Value)}"; outputBuilder.AppendLine(styledLine); } else { - outputBuilder.AppendLine(line); + outputBuilder.AppendLine(WebUtility.HtmlEncode(line)); } } diff --git a/src/Cake.Terraform/TerraformAliases.cs b/src/Cake.Terraform/TerraformAliases.cs index 9b233b9..ebf283f 100644 --- a/src/Cake.Terraform/TerraformAliases.cs +++ b/src/Cake.Terraform/TerraformAliases.cs @@ -1,4 +1,5 @@ -using Cake.Core; +using System.Collections.Generic; +using Cake.Core; using Cake.Core.Annotations; namespace Cake.Terraform @@ -50,10 +51,10 @@ public static void TerraformEnvDelete(this ICakeContext context, TerraformEnvDel } [CakeMethodAlias] - public static void TerraformEnvList(this ICakeContext context, TerraformEnvListSettings settings) + public static List TerraformEnvList(this ICakeContext context, TerraformEnvListSettings settings) { var runner = new TerraformEnvListRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools); - runner.Run(settings); + return runner.Run(settings); } [CakeMethodAlias] diff --git a/src/Cake.Terraform/TerraformEnvDeleteRunner.cs b/src/Cake.Terraform/TerraformEnvDeleteRunner.cs index 09fcb05..ff64e2a 100644 --- a/src/Cake.Terraform/TerraformEnvDeleteRunner.cs +++ b/src/Cake.Terraform/TerraformEnvDeleteRunner.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; using Cake.Core; using Cake.Core.IO; using Cake.Core.Tooling; -using Cake.Terraform; namespace Cake.Terraform { @@ -17,7 +14,7 @@ public void Run(TerraformEnvDeleteSettings settings) { var builder = new ProcessArgumentBuilder() - .Append("env"); + .Append("workspace"); builder = builder.Append("delete"); diff --git a/src/Cake.Terraform/TerraformEnvListRunner.cs b/src/Cake.Terraform/TerraformEnvListRunner.cs index a49ed7f..40019da 100644 --- a/src/Cake.Terraform/TerraformEnvListRunner.cs +++ b/src/Cake.Terraform/TerraformEnvListRunner.cs @@ -3,7 +3,6 @@ using Cake.Core; using Cake.Core.IO; using Cake.Core.Tooling; -using Cake.Terraform; namespace Cake.Terraform { @@ -18,11 +17,9 @@ public List Run(TerraformEnvListSettings settings) { var builder = new ProcessArgumentBuilder() - .Append("env") + .Append("workspace") .Append("list"); - Run(settings, builder); - var processSettings = new ProcessSettings { RedirectStandardOutput = true @@ -33,6 +30,7 @@ public List Run(TerraformEnvListSettings settings) { result = x.GetStandardOutput() .Select(env => env.Replace("*", "").Trim()) + .Where(env => !string.IsNullOrWhiteSpace(env)) .ToList(); }); diff --git a/src/Cake.Terraform/TerraformEnvNewRunner.cs b/src/Cake.Terraform/TerraformEnvNewRunner.cs index 8864636..f8ee319 100644 --- a/src/Cake.Terraform/TerraformEnvNewRunner.cs +++ b/src/Cake.Terraform/TerraformEnvNewRunner.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; using Cake.Core; using Cake.Core.IO; using Cake.Core.Tooling; -using Cake.Terraform; namespace Cake.Terraform { @@ -13,6 +11,7 @@ public TerraformEnvNewRunner(IFileSystem fileSystem, ICakeEnvironment environmen : base(fileSystem, environment, processRunner, tools) { } + public void Run(TerraformEnvNewSettings newSettings) { if (string.IsNullOrEmpty(newSettings.Environment)) @@ -22,7 +21,7 @@ public void Run(TerraformEnvNewSettings newSettings) var builder = new ProcessArgumentBuilder() - .Append("env") + .Append("workspace") .Append("new") .Append(newSettings.Environment);