refactor(ssm): split put_parameter into parse/overwrite/create#316
Merged
vieiralucas merged 1 commit intomainfrom Apr 12, 2026
Merged
refactor(ssm): split put_parameter into parse/overwrite/create#316vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
``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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SsmService::put_parameterwas 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 byPutParameterInput::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: requiresType, builds theSsmParameter, and returns it for insertion.put_parameteritself is now an 18-line function that reads top-to-bottom: parse input, acquire lock, dispatch to overwrite or create.Test plan
cargo build --workspacecargo fmt --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance— 1102 passed, 0 failedSummary by cubic
Refactored SSM
put_parameterby splitting parsing, overwrite, and create paths into focused helpers to simplify the flow and keep behavior unchanged.PutParameterInput::from_bodyto parse and validate fields (required name/value, value length, data type, param type, name format).apply_overwritefor existing-parameter updates, including tags-vs-overwrite check, version-limit rotation, and version/history updates.create_new_parameterto build new parameters and requireType.SsmService::put_parameterto 18 lines: parse, lock, dispatch. Responses and error messages are unchanged.Written for commit 06937c6. Summary will update on new commits.