Skip to content

feat(certificate-authority): declarative Weekly schedule variant (fixes #185 via SDK bump)#187

Open
spbsoluble wants to merge 4 commits into
fix/ca-optional-computed-auditfrom
feat/ca-weekly-schedule
Open

feat(certificate-authority): declarative Weekly schedule variant (fixes #185 via SDK bump)#187
spbsoluble wants to merge 4 commits into
fix/ca-optional-computed-auditfrom
feat/ca-weekly-schedule

Conversation

@spbsoluble

Copy link
Copy Markdown
Collaborator

Stacked on #186 (which stacks on #184); merge those first — this diff is only the last four commits. Closes #185.

What

keyfactor_certificate_authority's three schedules (full_scan, incremental_scan, threshold_check) can now be managed declaratively as a Weekly schedule, alongside the existing interval and daily variants:

full_scan_weekly_days = ["Monday", "Friday"]
full_scan_weekly_time = "07:00:00"
  • Day names are canonical and case-sensitive (SundaySaturday), validated at plan time; the time uses the same "HH:MM:SS" UTC format as the daily variant.
  • The two weekly attributes are co-required; declaring attributes from more than one variant for the same schedule is a plan-time error.
  • weekly_days = [] + weekly_time = "" is the declarative clear sentinel, consistent with the 0/"" sentinels for the other variants; the omit=unmanaged/GET-before-PUT preservation contract is unchanged, and switching variants nulls the old variant truthfully instead of resurrecting it.

Fixes #185

Reading any CA whose schedule Command had stored as Weekly failed outright — Command (observed on v25.5) serializes Weekly.Days as day-name strings (["Monday"]) and the SDK only accepted integers, so every Read/Update of such a CA errored. This PR bumps keyfactor-go-client-sdk/v24 to v24.1.2-rc.0 (Keyfactor/keyfactor-go-client-sdk#36), which accepts both wire forms. A wire-level regression test locks in the exact string-days payload; it was verified failing against v24.1.1 before the bump.

The RC pin should be repinned to the GA tag once Keyfactor/keyfactor-go-client-sdk#36 merges, same as the go-client v3.6.0 repin already planned for this release.

Verification

  • New unit tests: certificate_authority: SDK cannot deserialize Weekly-shaped CA schedules (SystemDayOfWeek expects int, Command returns day-name strings) #185 wire-level regression, config→request→response→state round-trip, sentinel clear (framework-realistic Update test), drift visibility over the sentinel, all four Weekly↔Interval / Weekly↔Daily switch directions (no resurrection, truthful diffs), and 9 ValidateConfig cases (multi-variant conflicts, days-without-time, time-without-days, invalid/lowercase day names).
  • The generalized group plan modifier (pair → N-way) has its own new generic tests, including that declaring the second-listed sibling (not just the first) supersedes correctly.
  • Red→green verified for both the SDK regression (fails on v24.1.1) and the provider feature (compile/vet failure with the feature commits stashed).
  • Full unit suite green (0 failures, 3 known skips), run three times during development.

Live-lab lifecycle validation (plan→apply→import→drift→destroy, plus the out-of-band Weekly repro from #185) is the next step and will be reported on this PR.

SystemDayOfWeek.UnmarshalJSON now accepts a day-name string (e.g.
"Monday") in addition to the original integer form. Command v25.5
sends a Weekly schedule's Days as day-name strings, which the
previously-vendored SDK failed to deserialize at all, causing Read to
fail outright on any CA with a live Weekly schedule (#185).
Extends full_scan/incremental_scan/threshold_check schedules with a
third mutually-exclusive variant alongside the existing Interval and
Daily representations: *_weekly_days (a list of exact, case-sensitive
day names) and *_weekly_time (the same UTC "HH:MM:SS" format as
*_daily_time). The two are co-required -- declaring one without the
other is rejected at plan time -- and declaring any one of
Interval/Daily/Weekly for a schedule implicitly clears the others.

- pairedVariantModifier (attribute_contract.go) generalizes from a
  fixed sibling to a variadic list of sibling attribute names, so a
  variant made of more than one attribute (weekly's days+time) can
  list every OTHER variant's attribute(s) as its siblings without
  including its own co-attribute.
- buildSchedule/scheduleToState now build and parse the Weekly wire
  shape (Days []SystemDayOfWeek, Time), sorting Days by enum value on
  read for stable, deterministic ordering.
- validateCAScheduleAttributes enforces the three-way exclusivity, the
  weekly co-required pair, valid day names, and the weekly clear
  sentinel ([] + "").
- preserveCAUpdateFields, applyUndeclaredScheduleFallback, and
  keepScheduleSentinels extend to treat the weekly pair the same as
  the existing interval/daily attributes for preservation, read-modify-
  write fallback, and sentinel stability.
- TestUnitCAWeeklyScheduleDayNameStringsDeserialize: wire-level
  regression for #185 -- a GET response with Days as day-name strings
  (exactly as Command v25.5 sends) failed to even deserialize before
  the SDK bump; verified red against keyfactor-go-client-sdk v24.1.1
  and green against v24.1.2-rc.0.
- Round trip, sentinel clear/build, and mismatched-pair coverage for
  buildSchedule/scheduleToState.
- Variant-switch coverage for all four Weekly<->Interval/Daily
  combinations, mirroring the existing Interval<->Daily regression
  test shape.
- Framework-realistic Update() test for the weekly clear sentinel and
  a Read-path drift-over-sentinel test.
- ValidateConfig coverage: co-required pair, invalid/lowercase day
  names, mismatched sentinel pair, three-way conflicts with Interval
  and Daily, and the valid weekly-alone/clear-sentinel cases.
- Two generic attribute_contract_test.go cases proving pairedWith's
  three-way generalization (declaring the second-listed sibling in a
  group, not just the first, plans this attribute Null).

Also update the existing preserveCAUpdateFields/allNull test fixtures
to spell out the new weekly attributes as explicit Null (a Go
zero-value types.List{}/types.String{} is a known non-null empty
value, not Null, and would otherwise spuriously look "declared").
- Regenerate docs/resources/certificate_authority.md via
  `tfplugindocs generate` (run from a terraform-provider-keyfactor-
  named path, since the tool infers the provider name and page-title
  suffix from the working directory).
- Add a commented weekly-schedule example to
  examples/resources/keyfactor_certificate_authority/resource.tf.
- CHANGELOG: document the new *_weekly_days/*_weekly_time attributes
  and the #185 fix (keyfactor-go-client-sdk day-name deserialization).
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