Skip to content

refactor(ssm): split long parameter, document, command, and maintenance ops#325

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+ssm-splits
Apr 13, 2026
Merged

refactor(ssm): split long parameter, document, command, and maintenance ops#325
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+ssm-splits

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

Four SSM operations were carrying enough inline parsing/duplication to obscure their actual work.

  • parameters: `get_parameter` and `get_parameters` both built the same 'historical version Value' inline (same `json!` body, same SecureString masking, repeated three times across the two functions). Move that into `build_param_history_value` so each call site is one line.
  • documents: `get_document` had a 35-line if/else chain to resolve which `SsmDocumentVersion` the request was asking for (`VersionName` + `DocumentVersion` combinations, plus `$LATEST`, plus default). Move it into `select_document_version`, a pure function over `(doc, version, version_name)` that returns `Option<&SsmDocumentVersion>`.
  • commands: `send_command`'s first 80 lines were entirely body parsing and validation. Move them into `SendCommandInput::from_body` so the operation body just constructs `SsmCommand`, persists it, and shapes the response.
  • maintenance: same treatment for `create_maintenance_window` — pull the field-by-field validation and parsing into `CreateMaintenanceWindowInput::from_body`. The operation body keeps the idempotency check + state insertion which is the part that actually mutates state.

No behavior change. Same lock semantics, same error messages.

Test plan

  • `cargo fmt`
  • `cargo clippy --workspace --all-targets -- -D warnings`
  • `cargo test -p fakecloud-ssm` (60 passed)

Summary by cubic

Refactored SSM handlers to move heavy parsing and version selection into small helpers. The handlers are shorter, easier to read, and behavior is unchanged.

  • Refactors
    • Parameters: added build_param_history_value to build historical values and apply SecureString masking; simplified get_parameter/get_parameters.
    • Documents: added select_document_version to handle DocumentVersion/VersionName (incl. $LATEST and default); get_document stays defaulting to JSON when format isn’t specified.
    • Commands: added SendCommandInput::from_body for request parsing/validation; send_command now focuses on constructing SsmCommand, persisting, and shaping the response.
    • Maintenance: added CreateMaintenanceWindowInput::from_body; operation keeps the ClientToken idempotency check and state insertion.

Written for commit 89f9fdf. Summary will update on new commits.

…ce ops

Four SSM operations were carrying enough inline parsing/duplication to
obscure their actual work.

- parameters: get_parameter and get_parameters both built the same
  'historical version Value' inline (same json! body, same SecureString
  masking, repeated three times across the two functions). Move that
  into build_param_history_value so each call site is one line.

- documents: get_document had a 35-line if/else chain to resolve which
  SsmDocumentVersion the request was asking for (VersionName +
  DocumentVersion combinations, plus '$LATEST', plus default). Move
  it into select_document_version, a pure function over (doc, version,
  version_name) that returns Option<&SsmDocumentVersion>.

- commands: send_command's first 80 lines were entirely body parsing
  and validation. Move them into SendCommandInput::from_body so the
  operation body just constructs SsmCommand, persists it, and shapes
  the response.

- maintenance: same treatment for create_maintenance_window — pull the
  field-by-field validation and parsing into
  CreateMaintenanceWindowInput::from_body. The operation body keeps
  the idempotency check + state insertion which is the part that
  actually mutates state.

No behavior change. Same lock semantics, same error messages.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

@vieiralucas vieiralucas merged commit 01fee37 into main Apr 13, 2026
33 of 34 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+ssm-splits branch April 13, 2026 01:24
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