Add JMESPath query support for JSON output in CLI commands#6664
Add JMESPath query support for JSON output in CLI commands#6664vhvb1989 merged 2 commits intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds JMESPath query support to Azure Developer CLI (azd) for filtering JSON output, matching functionality available in Azure CLI. Users can now use the --query flag with any azd command that supports JSON output to filter and transform the results using JMESPath syntax.
Changes:
- Added JMESPath query functionality with the
--queryflag for JSON output - Integrated query support into the command building infrastructure
- Added comprehensive unit tests for query operations and functional tests for the env list command
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/output/query.go | Implements core JMESPath query application with error handling and documentation hints |
| cli/azd/pkg/output/query_test.go | Comprehensive unit tests covering various JMESPath query scenarios including filtering, projection, and error cases |
| cli/azd/pkg/output/json.go | Extends JsonFormatter to support optional query filtering before JSON marshaling |
| cli/azd/pkg/output/parameter.go | Adds query flag registration and validation requiring JSON output format |
| cli/azd/cmd/cobra_builder.go | Integrates query flag for all commands supporting JSON output |
| cli/azd/test/functional/env_test.go | Functional test verifying query functionality with env list command |
| cli/azd/go.mod | Adds jmespath-community/go-jmespath v1.1.1 dependency |
| cli/azd/go.sum | Updates checksums for new dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Addresses #3206, #4067 (comment)
Azure CLI allows you to run JMESPath queries on JSON output. This PR brings that same capability to azd commands that support JSON output. A dependency on go-jmespath is needed to accomplish this.
Usage example from a local run: