feat(cli): Add component identity-diff command, scenario test#49
feat(cli): Add component identity-diff command, scenario test#49dmcilvaney wants to merge 1 commit intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new CLI workflow for comparing component identity outputs, intended to support CI/build-queue determination by diffing two identity JSON files.
Changes:
- Introduces
azldev component diff-identitycommand to compare two identity JSON files and emit changed/added/removed/unchanged sets. - Adds unit tests for diff computation and file parsing behaviors.
- Adds scenario coverage and generated CLI documentation updates for the new command (plus a new developer reference doc).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/app/azldev/cmds/component/diffidentity.go |
New component diff-identity command implementation and diff logic. |
internal/app/azldev/cmds/component/diffidentity_test.go |
Unit tests for diff logic and JSON/table output behavior. |
internal/app/azldev/cmds/component/component.go |
Registers the new diff-identity subcommand under component. |
scenario/component_identity_test.go |
New scenario tests exercising identity/diff-identity CLI behavior in help mode and in-container flow. |
scenario/__snapshots__/*TestComponentIdentitySnapshots* |
New snapshots for component identity --help and component diff-identity --help. |
docs/user/reference/cli/azldev_component.md |
Adds diff-identity to generated component command index. |
docs/user/reference/cli/azldev_component_diff-identity.md |
Generated CLI docs for the new diff-identity command. |
docs/developer/reference/component-identity.md |
Developer-facing explanation of identity + diff-identity workflow and fingerprint inputs. |
| data, err := fileutils.ReadFile(env.FS(), filePath) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("reading file:\n%w", err) | ||
| } | ||
|
|
||
| var entries []ComponentIdentityResult | ||
|
|
||
| err = json.Unmarshal(data, &entries) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("parsing JSON:\n%w", err) | ||
| } | ||
|
|
||
| result := make(map[string]string, len(entries)) | ||
| for _, entry := range entries { | ||
| result[entry.Component] = entry.Fingerprint | ||
| } |
There was a problem hiding this comment.
readIdentityFile unmarshals into []ComponentIdentityResult, but that type is not defined anywhere in the repo (searching the whole tree only finds this reference). This will fail to compile. Define a local struct matching the on-disk JSON schema (e.g., fields for component and fingerprint) or import/rename to the actual identity entry type used by component identity output.
| "identity help": cmdtest.NewScenarioTest("component", "identity", "--help").Locally(), | ||
| "diff-identity help": cmdtest.NewScenarioTest("component", "diff-identity", "--help").Locally(), | ||
| } | ||
|
|
There was a problem hiding this comment.
This scenario test (and the added snapshots) invoke azldev component identity --help, but there is no component identity command registered anywhere in internal/app/azldev/cmds/ (only diff-identity, diff-sources, add, build, list, prepare-sources, query). As-is, the scenario test should fail with an unknown command error. Either add/register the component identity Cobra command in the CLI, or update the scenario test/snapshots to target the actual command name.
| "identity help": cmdtest.NewScenarioTest("component", "identity", "--help").Locally(), | |
| "diff-identity help": cmdtest.NewScenarioTest("component", "diff-identity", "--help").Locally(), | |
| } | |
| "diff-identity help": cmdtest.NewScenarioTest("component", "diff-identity", "--help").Locally(), | |
| } |
No description provided.