Refactor: consolidate AWS/Azure config assembly into shared resolvers#50
Merged
Merged
Conversation
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
handle_awsandhandle_azurehad each grown to ~200 lines that assembled the same config dict up to six different ways (config file / non-interactive / profile or cli / manual prompts), repeating the name-fallback expression five times and duplicating the boto3 credential block twice. This PR extracts a config resolution layer so each credential source has one job and the final config is built in one place.What changed
utils/utils.py— two shared helpers:resolve_name(args)— the--name→ timestamped-default logic (was inlined 5×).build_config(...)— assembles the final assessment config envelope (was rebuilt 6×).main.py— per-source resolvers that each return aproviderDetailsdict:_aws_provider_from_profile,_aws_provider_from_env,_aws_provider_from_prompt_azure_cli_credential,_azure_provider_noninteractive,_azure_provider_from_cli,_azure_provider_from_promptConfigErrorsignal lets each caller decide abort semantics (sys.exit(codes.CONFIG)in non-interactive/CI, plainreturninteractively).handle_aws/handle_azureare now thin dispatchers (~200 → ~55 lines each): pick the source, resolve inputs, call a resolver,build_config(...)→run_assessment(...).User-facing impact
None intended. CLI flags, prompt order and wording, env-var handling, exit codes,
and generated config shape are all preserved. Two small consistency fixes ride along:
--clierror path nowreturns cleanly instead offalling through to
run_assessment({})with an empty config.