From d048015876e0770b25e13b9d4d539d977e3edcae Mon Sep 17 00:00:00 2001 From: Robert E Date: Mon, 18 Nov 2024 12:02:04 +1000 Subject: [PATCH] POC indicating bug in helm values parsing --- .../Helm/HelmTemplateValueSourcesCreatorFixture.cs | 3 ++- .../Kubernetes/Helm/HelmTemplateValueSourcesParser.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/Calamari.Tests/KubernetesFixtures/Helm/HelmTemplateValueSourcesCreatorFixture.cs b/source/Calamari.Tests/KubernetesFixtures/Helm/HelmTemplateValueSourcesCreatorFixture.cs index cee746962..0b6af071b 100644 --- a/source/Calamari.Tests/KubernetesFixtures/Helm/HelmTemplateValueSourcesCreatorFixture.cs +++ b/source/Calamari.Tests/KubernetesFixtures/Helm/HelmTemplateValueSourcesCreatorFixture.cs @@ -279,7 +279,7 @@ public void ParseTemplateValuesFilesFromDependencies_ChartGitRepositoryAndInline }, new HelmTemplateValueSourcesParser.InlineYamlTemplateValuesSource { - Value = @"yes: '1234'" + Value = @"#{Service.HelmYaml}" }, new HelmTemplateValueSourcesParser.KeyValuesTemplateValuesSource { @@ -293,6 +293,7 @@ public void ParseTemplateValuesFilesFromDependencies_ChartGitRepositoryAndInline var variables = new CalamariVariables { + ["Service.HelmYaml"] = @"{""Foo"": [""SOMETHING""]}", [SpecialVariables.Helm.TemplateValuesSources] = templateValuesSourcesJson, [KnownVariables.OriginalPackageDirectoryPath] = RootDir, [ScriptVariables.ScriptSource] = ScriptVariables.ScriptSourceOptions.GitRepository, diff --git a/source/Calamari/Kubernetes/Helm/HelmTemplateValueSourcesParser.cs b/source/Calamari/Kubernetes/Helm/HelmTemplateValueSourcesParser.cs index 401f88307..cc0b81cf2 100644 --- a/source/Calamari/Kubernetes/Helm/HelmTemplateValueSourcesParser.cs +++ b/source/Calamari/Kubernetes/Helm/HelmTemplateValueSourcesParser.cs @@ -34,7 +34,7 @@ public IEnumerable ParseAndWriteTemplateValuesFilesFromAllSources(Runnin public IEnumerable ParseTemplateValuesFilesFromDependencies(RunningDeployment deployment, bool logIncludedFiles = true) { - var templateValueSources = deployment.Variables.Get(SpecialVariables.Helm.TemplateValuesSources); + var templateValueSources = deployment.Variables.GetRaw(SpecialVariables.Helm.TemplateValuesSources); if (string.IsNullOrWhiteSpace(templateValueSources)) return Enumerable.Empty(); @@ -115,7 +115,9 @@ List ParseFilenamesFromTemplateValuesArray(RunningDeployment deployment, case TemplateValuesSourceType.InlineYaml: var inlineYamlTvs = json.ToObject(); - var inlineYamlFilename = InlineYamlValuesFileWriter.WriteToFile(deployment, fileSystem, inlineYamlTvs.Value, index); + + var val = deployment.Variables.Evaluate(inlineYamlTvs.Value); + var inlineYamlFilename = InlineYamlValuesFileWriter.WriteToFile(deployment, fileSystem, val, index); AddIfNotNull(filenames, inlineYamlFilename); break;