Read this before touching models/registration/ or models/meshmodel/registry/.
models/registration/ingests model packages and assembles aPackagingUnit: exactly onemodel.ModelDefinitionplus any number of components, relationships, and connections associated with it.- A
RegistrationHelper(constructed with an SVG base directory, aRegistryManager, and aRegistrationErrorStore) drivesRegister(entity)for eachRegisterableEntity- currently directory (dir.go), tar (tar.go), and OCI (oci.go) sources. models/meshmodel/registry/persists registrants, models, components, and relationships through GORM-backed helpers (RegistryManager), with versioned entity handling underregistry/v1alpha3andregistry/v1beta1.
- One model definition per imported package/directory. Registration assumes an imported package/directory contains exactly one model definition and then any number of components/relationships associated with it.
- Entity types come from
github.com/meshery/schemas(model,component,relationship,connectiondefinitions). MeshKit is NOT the schema source of truth; never redeclare schema types locally - focus on how MeshKit loads, normalizes, registers, and persists those entities.
Registration code is intentionally permissive on input shape:
- Directory import recursively unwraps nested zip/tar/OCI content.
- YAML is normalized to JSON before entity detection and unmarshal.
- Registration accepts both legacy and canonical schema-version strings for models,
components, and relationships where compatibility is required. Regression coverage
exists, e.g.
go test ./models/registration -run TestGetEntityAcceptsV1Beta2RelationshipSchemaVersion -count=1.
Do not tighten these behaviors without coordinating with every downstream importer (Meshery Server model import, mesheryctl, generators).
ComponentCSVHelper.ParseComponentsSheet returns CSV parsing and read failures,
including failures after the file opens. Rows read before a failure can already
be present in Components, so callers must check the returned error before
using that data to update the registry. Successful completion includes every
selected row, including the final row when filtering by model.
ModelCSVHelper.ParseModelsSheet returns CSV parsing and read failures,
including failures after the file opens. Rows read before a failure can already
be present in Models, so callers must check the returned error before
using that data to update the registry. Successful completion includes every
selected row, including the final row when filtering by model.
RelationshipCSVHelper.ParseRelationshipsSheet returns CSV parsing and read failures,
including failures after the file opens. Rows read before a failure can already
be present in Relationships, so callers must check the returned error before
using that data to update the registry. Successful completion includes every
selected row, including the final row when filtering by model.
Registration mutates asset references as part of ingestion: model and component SVG
fields (color/white/complete SVGs) are written to the filesystem under the configured
SVG base directory and the in-memory fields are replaced with file paths before
persistence through RegistryManager (see models/registration/svg_helper.go). Code
that inspects a PackagingUnit after registration sees file paths, not inline SVG
content. Keep this in mind when adding fields that carry embedded assets.