Skip to content

Conversation

@isaiahfrantz
Copy link

Summary

This PR restores support for comma-separated override lists while preserving JSON values that contain commas (e.g., JSON arrays). It also refactors the parsing logic into a shared helper to avoid duplication across override option classes.

What changed

Override parsing

  • --fact-override, --to-fact-override, --from-fact-override now accept:
    • STRING1[,STRING2[,...]]
  • Commas are treated as separators only when they are outside of quoted strings and JSON structures ([] / {}), so values like:
    • json_list=(json)["a","b"]
      remain intact.

DRY refactor

  • Added shared helper:
    • OctocatalogDiff::Cli::Options.split_override_list in lib/octocatalog-diff/cli/options.rb
  • Updated override option implementations to use the helper:
    • lib/octocatalog-diff/cli/options/fact_override.rb
    • lib/octocatalog-diff/cli/options/enc_override.rb

Tests

  • Added/updated specs to cover:
    • comma-separated override lists
    • mixed lists with JSON values containing commas
  • Specs:
    • spec/octocatalog-diff/tests/cli/options/fact_override_spec.rb
    • spec/octocatalog-diff/tests/cli/options/enc_override_spec.rb

Docs

  • Updated facts override docs to describe comma-separated list support + JSON-safe behavior:
    • doc/advanced-override-facts.md
  • Updated CLI options reference for fact overrides:
    • doc/optionsref.md

Why

Previously, comma-separated lists were disabled to avoid breaking JSON values (since JSON arrays/objects contain commas). This PR enables both:

  • convenience: foo=bar,baz=buzz
  • correctness: json_list=(json)["a","b","c"]

Testing

bundle exec rspec \
  spec/octocatalog-diff/tests/cli/options/fact_override_spec.rb \
  spec/octocatalog-diff/tests/cli/options/enc_override_spec.rb

Isaiah Frantz added 2 commits January 27, 2026 12:31
Replace option_globally_or_per_branch with explicit parser.on handlers to avoid automatic Array parsing that splits on commas, allowing JSON fact overrides containing commas to remain intact.
Add split_override_list method to parse comma-separated override values while preserving commas inside JSON arrays and objects. Update fact-override and enc-override options to accept comma-separated lists using explicit parser.on handlers. Add tests for comma-separated parsing and JSON value preservation. Update documentation to describe comma-separated list support.
@isaiahfrantz
Copy link
Author

@ngrundy can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant