Azure / Azure/azure-dev

Refactor: Extract shared Foundry project selection logic into helper function

Open
#8,296 0 comments 0 reactions 0 assignees View on GitHub
ai area/code-improvements engineering item
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.