Skip to content

G1.3: StructuredConfigVariablesStep — JSON-path replacement for appsettings.json

Placeholder ppxd requested to merge feat/calamari-g1-3-structured-config-vars into main

Summary

  • Implements StructuredConfigVariablesStep — for each leaf in operator-nominated JSON files (typically appsettings.json + appsettings.{Env}.json), match its computed path against every variable name and substitute the leaf value with the variable's value. Both dot-form (ConnectionStrings.Default) and colon-form (Logging:LogLevel:Default, ASP.NET Core IConfiguration idiom) lookups are tried — first match wins.
  • Type-preserving: boolean leaf stays boolean if the new value parses; numeric leaf stays numeric; otherwise falls back to string. Non-leaf path matches (object/array) are silently skipped — replacing an object with a scalar would corrupt the schema.
  • Pipeline position matches Octopus: SubstituteInFiles → ConfigurationTransforms → StructuredConfigurationVariables. JSON parsing tolerates trailing commas + comments so dev-era artefacts don't fail a deploy.
  • Closes the IIS handler's third advertised cross-cutting feature — Octopus-parity trio complete after #363 (G1.1) and #364 (G1.2).

What's in the box

Layer File
Pure JSON engine src/Squid.Calamari/Commands/StructuredConfig/JsonPathReplacer.cs
Pipeline step src/Squid.Calamari/Commands/StructuredConfig/StructuredConfigVariablesStep.cs
Pipeline wiring src/Squid.Calamari/Commands/RunScriptCommand.cs
Pure-function tests (15) tests/Squid.Calamari.Tests/Calamari/Commands/StructuredConfig/JsonPathReplacerTests.cs
Pipeline tests (10) tests/Squid.Calamari.Tests/Calamari/Commands/StructuredConfig/StructuredConfigVariablesStepTests.cs
Cross-project drift detector (4) tests/Squid.UnitTests/.../Tentacle/Handlers/IISStructuredConfigVariablesWireContractTests.cs

Operator-facing variables (mirrors IIS deploy preamble)

Variable Effect
Squid.Action.IISWebSite.StructuredConfigurationVariables.Enabled ("True"/"False") Toggle the step on/off
Squid.Action.IISWebSite.StructuredConfigurationVariables.Targets Newline-separated globs of JSON files to rewrite

Test plan

  • Unit (Squid.Calamari.Tests): 230/230 — includes 25 G1.3 cases (15 replacer + 10 step)
  • Cross-project wire contract (Squid.UnitTests): 4/4 — pins IISDeployProperties.StructuredConfigurationVariables{Enabled,Targets} against StructuredConfigVariableNames.{Enabled,Targets}
  • Full Squid.UnitTests: 5615/5615 — no collateral regressions
  • dotnet build solution-wide: 0 errors
  • Staging IIS deploy of an ASP.NET Core app with appsettings.Production.json containing both : and . variable forms — verify leaf values are rewritten in place with type preservation

Merge request reports

Loading