-
Notifications
You must be signed in to change notification settings - Fork 267
Auto-detect infrastructure provider from infra directory files #6461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: spboyer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements automatic detection of infrastructure providers (Bicep or Terraform) when infra.provider is not explicitly set in azure.yaml. The detection scans the infra directory for characteristic file extensions to determine the appropriate provider.
Key changes:
- Added
detectProviderFromFilesfunction that scans infra directory for.bicep/.bicepparamor.tf/.tfvarsfiles - Updated
ProjectInfrastructureto automatically detect and set the provider when not specified - Added comprehensive unit tests covering all detection scenarios including error cases
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cli/azd/pkg/project/importer.go |
Adds detectProviderFromFiles function and integrates auto-detection into ProjectInfrastructure workflow |
cli/azd/pkg/project/importer_test.go |
Adds comprehensive table-driven unit tests for provider detection, including edge cases for mixed files, empty directories, and directory exclusion |
.gitignore |
Adds cli/azd/azd binary to gitignore (duplicate entry) |
|
/azp run azure-dev - cli |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
/check-enforcer override |
Enables automatic detection of Bicep or Terraform as the infrastructure provider when
infra.provideris not explicitly set inazure.yaml. The detection scans the infra directory for.bicep/.bicepparamor.tf/.tfvarsfiles.Implementation
Added
detectProviderFromFilesfunctionprovisioning.Bicepif only Bicep files presentprovisioning.Terraformif only Terraform files presentprovisioning.NotSpecifiedfor empty/non-existent directoriesUpdated
ProjectInfrastructurefunctioninfraRootpath wheninfraOptions.Provider == provisioning.NotSpecifiedauto-detected infrastructure provider: <bicep|terraform>Example behavior
Backward Compatibility
Explicit
infra.providerinazure.yamlalways takes precedence. Auto-detection only runs when provider isNotSpecified. All existing projects continue to work unchanged.Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.