From 00b9769e83c8dc98a9f5d94a617aef24c8d34a82 Mon Sep 17 00:00:00 2001 From: Prom3theu5 Date: Sat, 1 Oct 2022 03:58:26 +0100 Subject: [PATCH] maybe expansion will work under bash --- src/SimCube.PulumiDeployments/GlobalUsings.cs | 1 - .../Resources/Helm/BaseHelmChartResource.cs | 27 +++++++------------ .../SimCube.PulumiDeployments.csproj | 1 - 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/SimCube.PulumiDeployments/GlobalUsings.cs b/src/SimCube.PulumiDeployments/GlobalUsings.cs index 7ae101a..84c3699 100644 --- a/src/SimCube.PulumiDeployments/GlobalUsings.cs +++ b/src/SimCube.PulumiDeployments/GlobalUsings.cs @@ -6,7 +6,6 @@ global using System.Text.Json; global using System.Text.Json.Serialization; global using Ardalis.GuardClauses; -global using CliWrap; global using FluentValidation; global using FluentValidation.Results; global using Pulumi; diff --git a/src/SimCube.PulumiDeployments/Resources/Helm/BaseHelmChartResource.cs b/src/SimCube.PulumiDeployments/Resources/Helm/BaseHelmChartResource.cs index 927df25..d63968d 100644 --- a/src/SimCube.PulumiDeployments/Resources/Helm/BaseHelmChartResource.cs +++ b/src/SimCube.PulumiDeployments/Resources/Helm/BaseHelmChartResource.cs @@ -6,9 +6,6 @@ public abstract class BaseHelmChartResource : ComponentResource { protected readonly CustomResourceOptions CustomResourceOptions; - - private const string EnvSubstituteCommand = "envsubst"; - private const string MoveCommand = "mv"; public const string HelmValuesFolder = "HelmValues"; protected BaseHelmChartResource( @@ -31,21 +28,15 @@ protected string RenderYamlValues(Dictionary environmentalVaria { var helmValuesFile = GetHelmValuesFilePath(); - Cli.Wrap(EnvSubstituteCommand) - .WithArguments($"< {helmValuesFile} > {helmValuesFile}.new") - .WithEnvironmentVariables(environmentalVariables) - .WithValidation(CommandResultValidation.ZeroExitCode) - .ExecuteAsync() - .GetAwaiter() - .GetResult(); - - Cli.Wrap(MoveCommand) - .WithArguments($"{helmValuesFile}.new {helmValuesFile}") - .WithEnvironmentVariables(environmentalVariables) - .WithValidation(CommandResultValidation.ZeroExitCode) - .ExecuteAsync() - .GetAwaiter() - .GetResult(); + foreach (var environmentalVariable in environmentalVariables) + { + Environment.SetEnvironmentVariable(environmentalVariable.Key, environmentalVariable.Value); + } + + var origin = File.ReadAllText(helmValuesFile); + var output = Environment.ExpandEnvironmentVariables(origin); + + File.WriteAllText(helmValuesFile, output); return helmValuesFile; } diff --git a/src/SimCube.PulumiDeployments/SimCube.PulumiDeployments.csproj b/src/SimCube.PulumiDeployments/SimCube.PulumiDeployments.csproj index c9425cd..213c41a 100644 --- a/src/SimCube.PulumiDeployments/SimCube.PulumiDeployments.csproj +++ b/src/SimCube.PulumiDeployments/SimCube.PulumiDeployments.csproj @@ -15,7 +15,6 @@ -