Skip to content

Commit

Permalink
Quote generated AgentConfiguration yaml values
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingrobot committed Nov 21, 2024
1 parent 8bf3e3f commit e315b75
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
enabled: false
foo:
bar: "foobar"
special: "%specialyaml"
initContainer:
securityContext:
runAsUser: 499
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ClusterAgentConfigurationSyncingHandler(IStateContainer state,
foreach (var yamlKey in desiredResource.YamlKeys)
{
// Hard code the new line for Linux.
builder.Append(yamlKey.Key).Append(": ").Append(yamlKey.Value).Append('\n');
builder.Append(yamlKey.Key).Append(": '").Append(yamlKey.Value).Append("'\n");
}

var yaml = builder.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ public async Task When_injected_then_pod_should_use_generated_configuration()
}
}

[Fact]
public async Task When_injected_then_pod_should_use_generated_valid_configuration()
{
var client = await _context.GetClient();

// Act
var result = await client.GetInjectedPodByPrefix(ScenarioName);

// Assert
using (new AssertionScope())
{
var container = result.Spec.Containers.Single();

//Test that the namespaced AgentConfiguration contains valid yaml (% unquoted in yaml means its a directive line)
container.Env.Should().Contain(x => x.Name == "CONTRAST__SPECIAL").Which.Value.Should().Be("%specialyaml");
}
}

[Fact]
public async Task When_init_container_overrides_exist_then_the_overrides_should_be_merged_and_applied()
{
Expand Down

0 comments on commit e315b75

Please sign in to comment.