feat: add 'azd extension source validate' command for extension registry validation#6906
Conversation
…istry validation Add a new 'azd extension validate-registry' command that validates extension registry.json files from a local path or URL. This migrates validation logic from the standalone Node.js script in awesome-azd into the CLI. Validates: - Required fields (id, displayName, description, versions) - Extension ID format (dot-separated namespace) - Semver version format - Valid capabilities against known capability types - Platform artifact structure (valid os/arch, required url) - Artifact checksums (warning by default, error with --strict) Supports multiple input formats: - Registry object with 'extensions' array wrapper - Array of extension objects - Single extension object Outputs results as human-readable text (default) or JSON (--output json). Returns exit code 0 on success, non-zero on validation failure. Closes Azure#6896 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an azd extension validate-registry command to validate extension registry.json content from either a local file path or a URL, bringing gallery/author validation into the CLI.
Changes:
- Introduces registry JSON validation logic (IDs, semver shape, capabilities/platforms, checksum presence).
- Adds unit tests covering a variety of valid/invalid registry inputs and strict vs non-strict behavior.
- Registers a new CLI command that reads from file/URL and outputs either human-readable results or JSON.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| cli/azd/pkg/extensions/validate_registry.go | Implements validation routines and result model for registry JSON inputs. |
| cli/azd/pkg/extensions/validate_registry_test.go | Adds test suite for validation rules and supported input formats. |
| cli/azd/cmd/extension.go | Wires up azd extension validate-registry, including URL/file reading and output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wbreza
left a comment
There was a problem hiding this comment.
Looks good - just some changes I'd like to see before going in.
- Move command from 'azd extension validate-registry' to 'azd extension source validate' - Add deprecated hidden alias for backward compatibility - Use SourceManager to resolve sources (leverages existing registry reading code) - Use semver package instead of regex for version validation - Use semver-based latest version detection instead of last-element - Restrict extension ID regex to lowercase only - Add checksum algorithm validation (sha256, sha512) - Require artifacts or dependencies for each version - Guard against nil extension entries - Update --strict flag help text to 'require checksums' - Remove custom HTTP/file reading code in favor of SourceManager - Update and expand test coverage (22 tests) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The command now lives exclusively at azd extension source validate <name-or-path-or-url>. No backwards compatibility alias needed since this is a new command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wbreza
left a comment
There was a problem hiding this comment.
Looks good - Just to a check to see if there is some dead code that can be removed.
…leanup - Add errors.Is(err, ErrSourceNotFound) guard in extension source validate - Regenerate CLI snapshots for validate subcommand - Remove unused ValidateRegistryJSON function - Use semver.StrictNewVersion consistently in findLatestVersion - Replace custom containsStr with strings.Contains in tests - Refactor tests to call ValidateExtensions directly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Summary
Add a new
azd extension source validatecommand that validates extension registry sources. Accepts a source name (fromazd extension source list), a local file path, or a URL. Checks required fields, valid capabilities, semver version format, platform artifact structure, checksum configuration, and extension ID format.This migrates the validation logic from the standalone Node.js script in awesome-azd into the CLI.
Closes #6896
Changes
cli/azd/pkg/extensions/validate_registry.gocli/azd/pkg/extensions/validate_registry_test.gocli/azd/cmd/extension.goazd extension source, flags (--strict), action implementation usingSourceManagercli/azd/cmd/testdata/TestFigSpec.tsvalidatesubcommandcli/azd/cmd/testdata/TestUsage-azd-extension-source-validate.snapazd extension source validatecli/azd/cmd/testdata/TestUsage-azd-extension-source.snapUsage
Validation Rules
id,displayName,description,versionsTesting
go test ./pkg/extensions/ -run TestValidateExtension -vgo build ./...Input Resolution
The command accepts three types of input:
azd extension source listviaSourceManager.Get()SourceManager.CreateSource()withSourceKindFilehttp:///https://prefix, loaded viaSourceManager.CreateSource()withSourceKindUrlThe source's extensions are retrieved via
source.ListExtensions()and validated withextensions.ValidateExtensions().