Skip to content

Refactor: consolidate AWS/Azure config assembly into shared resolvers#50

Merged
bencehezso merged 1 commit into
mainfrom
task/refactor_config_resolution_helpers
Jul 23, 2026
Merged

Refactor: consolidate AWS/Azure config assembly into shared resolvers#50
bencehezso merged 1 commit into
mainfrom
task/refactor_config_resolution_helpers

Conversation

@bencehezso

Copy link
Copy Markdown
Contributor

Summary

handle_aws and handle_azure had 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 a providerDetails dict:
    • AWS: _aws_provider_from_profile, _aws_provider_from_env, _aws_provider_from_prompt
    • Azure: _azure_cli_credential, _azure_provider_noninteractive, _azure_provider_from_cli, _azure_provider_from_prompt
    • A small ConfigError signal lets each caller decide abort semantics (sys.exit(codes.CONFIG) in non-interactive/CI, plain return interactively).
    • handle_aws / handle_azure are 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:

  • AWS profile error messages are unified to the richer wording both paths used inconsistently.
  • The interactive Azure --cli error path now returns cleanly instead of
    falling through to run_assessment({}) with an empty config.

@bencehezso bencehezso self-assigned this Jul 23, 2026
@bencehezso bencehezso added the enhancement New feature or request label Jul 23, 2026
@bencehezso
bencehezso merged commit b8532ac into main Jul 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant