Skip to content

Commit

Permalink
Use index rather than interpolated name for yaml document variables
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-mackie committed Jul 1, 2024
1 parent 1cf26ce commit 48c99eb
Showing 1 changed file with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,37 +133,20 @@ IEnumerable<ResourceIdentifier> ApplyBatchAndReturnResourceIdentifiers(RunningDe
var yamlStream = new YamlStream();
yamlStream.Load(new StreamReader(yamlFile));

var i = 0;
foreach (var document in yamlStream.Documents)
{
if (!(document.RootNode is YamlMappingNode rootNode))
{
continue;
}

var metadata = rootNode.Children["metadata"] as YamlMappingNode ?? new YamlMappingNode();

if (!metadata.Children.TryGetValue("name", out var name))
{
name = "undefined";
}

if (!metadata.Children.TryGetValue("namespace", out var @namespace))
{
@namespace = "undefined";
}

if (!metadata.Children.TryGetValue("kind", out var kind))
{
kind = "undefined";
}

var updatedDocument = serializer.Serialize(rootNode);
// updatedDocuments.Add(updatedDocument);

log.WriteServiceMessage(new ServiceMessage(ServiceMessageNames.SetVariable.Name,
new Dictionary<string, string>
{
{ ServiceMessageNames.SetVariable.NameAttribute, $"AppliedManifests({kind}:{@namespace}:{name})" },
{ ServiceMessageNames.SetVariable.NameAttribute, $"AppliedManifests({i++})" },
{ ServiceMessageNames.SetVariable.ValueAttribute, updatedDocument }
}));
}
Expand Down

0 comments on commit 48c99eb

Please sign in to comment.