Skip to main content

Module apply

Module apply 

Source
Expand description

braze-sync apply — push local intent to Braze.

v0.1.0 supports Catalog Schema only (field add / field delete). The other resource kinds emit a “not yet implemented” warning.

§Safety chain

Apply is the only command that mutates remote state, so it goes through a strict order of checks. Each check fails closed:

  1. Recompute the diff (= the apply plan) using the same code path as the super::diff command. They cannot disagree about what would be applied.
  2. Print the plan. The header line goes to stderr so the JSON output on stdout stays parseable for CI consumers.
  3. If summary.changed_count() == 0 → “No changes” → exit 0.
  4. If --confirm is not set → “DRY RUN” → exit 0. Zero write calls reach Braze in this branch. Verified by integration tests that mount a method("POST") mock with .expect(0).
  5. If summary.destructive_count() > 0 && !args.allow_destructive → return Error::DestructiveBlocked which cli::exit_code_for maps to exit code 6 per IMPLEMENTATION.md §7.1.
  6. Pre-validate the plan against v0.1.0’s known unsupported operations (top-level catalog Added / Removed, field-level Modified). This runs before any API call so we can never leave Braze half-applied.
  7. Apply each change. The loop uses ?, so the first failure aborts the rest — partial-apply is bad-by-default. Each call is logged via tracing::info! with structured fields per §2.3 #4.

Structs§

ApplyArgs

Functions§

run