Skip to content

refactor(ssm): split put_parameter into parse/overwrite/create#316

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+ssm-put-parameter-split
Apr 12, 2026
Merged

refactor(ssm): split put_parameter into parse/overwrite/create#316
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+ssm-put-parameter-split

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 12, 2026

Summary

SsmService::put_parameter was 215 lines that did everything in one block: argument parsing, six different validations, two branches (overwrite vs create) with their own version-history rotation logic and new-parameter construction.

This PR introduces three helpers:

  • PutParameterInput — a single struct that captures all the request fields and is built by PutParameterInput::from_body, which also runs the field validations up front (Name/Value required, value length, data type, param type, name format).
  • apply_overwrite — a free function that handles the existing-parameter path: overwrite/tags-vs-overwrite checks, the version-limit rotation, the version-history push, and the field updates.
  • create_new_parameter — a free function that handles the new-parameter path: requires Type, builds the SsmParameter, and returns it for insertion.

put_parameter itself is now an 18-line function that reads top-to-bottom: parse input, acquire lock, dispatch to overwrite or create.

Test plan

  • cargo build --workspace
  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance — 1102 passed, 0 failed
  • CI green

Summary by cubic

Refactored SSM put_parameter by splitting parsing, overwrite, and create paths into focused helpers to simplify the flow and keep behavior unchanged.

  • Refactors
    • Added PutParameterInput::from_body to parse and validate fields (required name/value, value length, data type, param type, name format).
    • Added apply_overwrite for existing-parameter updates, including tags-vs-overwrite check, version-limit rotation, and version/history updates.
    • Added create_new_parameter to build new parameters and require Type.
    • Reduced SsmService::put_parameter to 18 lines: parse, lock, dispatch. Responses and error messages are unchanged.

Written for commit 06937c6. Summary will update on new commits.

``SsmService::put_parameter`` was 215 lines that did everything in one
block: argument parsing, six different validations, two branches
(overwrite vs create) with their own version-history rotation logic and
new-parameter construction.

This commit introduces:

- ``PutParameterInput`` — a single struct that captures all the request
  fields and is built by ``PutParameterInput::from_body``, which also
  runs the field validations up front.
- ``apply_overwrite`` — a free function that handles the existing-
  parameter path: overwrite/tags-vs-overwrite checks, the version-limit
  rotation, the version-history push, and the field updates.
- ``create_new_parameter`` — a free function that handles the
  new-parameter path: requires ``Type``, builds the ``SsmParameter``,
  and returns it for insertion.

``put_parameter`` itself is now an 18-line function that reads
top-to-bottom: parse input, acquire lock, dispatch to overwrite or
create.

No behavior change. All 1102 unit tests still pass, ``fakecloud-ssm``
clippy clean.
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 1 file

@vieiralucas vieiralucas merged commit 36139a6 into main Apr 12, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+ssm-put-parameter-split branch April 12, 2026 23:44
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