Skip to content

Refactor: Extract shared Foundry project selection logic into helper function #8296

Description

@v1212

Background

PR #8292 introduced a two-step Foundry project selection flow in both init.go and init_from_code.go. The two files now share ~70 lines of near-identical logic:

ensureSubscription → selectFoundryProject → nil check → setEnvValue("USE_EXISTING_AI_PROJECT") → fallback to "create new"

Problem

Future fixes may drift between the two files if only one is updated.

Proposed Solution

Extract a shared helper function (e.g. promptOrSelectFoundryProject(...)) that encapsulates the common sequence, and have both callers use it.

Files

  • cli/azd/extensions/azure.ai.agents/internal/cmd/init.go (~L1182-1250)
  • cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go (~L520-590)

Priority

P3 — non-blocking polish, suggested by @wbreza in PR #8292 review.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions