refactor(server): extract Cli and introspection helpers from main.rs#319
Merged
vieiralucas merged 1 commit intomainfrom Apr 13, 2026
Merged
refactor(server): extract Cli and introspection helpers from main.rs#319vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
- New crates/fakecloud-server/src/cli.rs holds the Cli struct and a small endpoint_url() helper that derives the public URL from the configured bind address (rewriting wildcard hosts to localhost). - New crates/fakecloud-server/src/introspection.rs hosts the four introspection response builders that translate raw service state into the public RdsInstance / ElastiCache* SDK types, plus the existing test that pins the password-redaction contract. - main.rs now wires these in via mod cli; mod introspection; and shrinks by 165 lines, leaving only the bind/setup orchestration.
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
Clistruct (clap parser) fromcrates/fakecloud-server/src/main.rsinto a newcrates/fakecloud-server/src/cli.rs.Cli::endpoint_url()method that derives the public URL from the configured bind address (rewriting wildcard hosts0.0.0.0/[::]tolocalhostso the URL is meaningful when handed back to clients). main.rs no longer needs to do this string surgery inline.rds_instance_response,elasticache_cluster_response,elasticache_replication_group_response,elasticache_serverless_cache_response) into a newcrates/fakecloud-server/src/introspection.rs. These translate raw service state into the public SDK types and exist explicitly so theGET /_fakecloud/...endpoints don't leak runtime-internal fields like RDS master passwords.rds_instance_response_omits_password_but_keeps_runtime_metadatatest moves with the helper.Test plan
cargo fmtcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformancecargo build -p fakecloudSummary by cubic
Split server startup by moving the CLI parser and introspection builders out of
main.rs, keeping startup orchestration focused. AddedCli::endpoint_url()to derive a client-facing URL (rewrites0.0.0.0/[::]tolocalhost).crates/fakecloud-server/src/cli.rs: definesCli(viaclap) andendpoint_url().crates/fakecloud-server/src/introspection.rs: response builders for RDS/ElastiCache map runtime state tofakecloud-sdktypes without secrets; includes the password-redaction test.main.rsnow imports these helpers and focuses on bind/setup; reduced by ~165 lines.Written for commit b32db67. Summary will update on new commits.