The component identity and component diff-identity subcommands compute deterministic fingerprints of component build inputs. For example, CI can compute fingerprints for the base and head commits of a PR, then diff them to determine exactly which components have changed and need to be rebuilt/tested.
# Typical CI workflow
git checkout $BASE_REF && azldev component identity -a -O json > base.json
git checkout $HEAD_REF && azldev component identity -a -O json > head.json
azldev component diff-identity base.json head.json -O json -c
# → {"changed": ["curl"], "added": ["wget"], "removed": [], "unchanged": []}A component's fingerprint is a SHA256 combining:
- Config hash —
hashstructure.Hash()of the resolvedComponentConfig(after all merging). Fields taggedfingerprint:"-"are excluded. - Source identity — content hash for local specs (all files in the spec directory), commit hash for upstream.
- Overlay file hashes — SHA256 of each file referenced by overlay
Sourcefields. - Distro name + version
- Affects commit count — number of
Affects: <component>commits in the project repo.
Global change propagation works automatically: the fingerprint operates on the fully-merged config, so a change to a distro or group default changes the resolved config of every inheriting component.
The hashstructure library uses TagName: "fingerprint". Untagged fields are included by default (safe default: false positive > false negative).
A guard test (TestAllFingerprintedFieldsHaveDecision) reflects over all fingerprinted structs and maintains a bi-directional allowlist of exclusions. It fails if a fingerprint:"-" tag is added without registering it, or if a registered exclusion's tag is removed.
- Add the field to the struct in
internal/projectconfig/. - If NOT a build input: add
fingerprint:"-"to the struct tag and register it inexpectedExclusionsininternal/projectconfig/fingerprint_test.go. - If a build input: do nothing — included by default.
- Run
mage unit.
- Implement
SourceIdentityProvideron your provider (seeResolveLocalSourceIdentityinlocalidentity.gofor a simple example). - Add a case to
sourceManager.ResolveSourceIdentity()insourcemanager.go. - Add tests in
identityprovider_test.go.
Compute fingerprints. Uses standard component filter flags (-a, -p, -g, -s). Exposed as an MCP tool.
Compare two identity JSON files. The --changed-only / -c flag filters to only changed and added components (the build queue). Applies to both table and JSON output.
- It is difficult to determine WHY a diff occurred (e.g., which specific field changed) since the fingerprint is a single opaque hash. The JSON output includes an
inputsbreakdown (configHash,sourceIdentity,overlayFileHashes, etc.) that can help narrow it down by comparing the two identity files manually.