feat(schemas): migrate to v1beta3 canonical-casing types (component, model, design)#988
Conversation
…model, design)
Migrate meshkit's schema consumers from the legacy
v1beta1/{component,pattern} and v1beta2/design packages to the
canonical-casing v1beta3/{component,design} (and v1beta2/model where
applicable). The v1beta3/* types published in meshery/schemas@1.1.x
(PR #825 helpers, PR #826 gorm fix, PR #824 workspace/connection env
refs) are now the target for component and design-level consumers; the
inner `*v1beta1/model.ModelDefinition` type is deliberately retained on
`ComponentDefinition.Model` and similar fields because the schemas type
graph (v1beta3/const.go) wires v1beta3/component.Model at
`*v1beta1/model.ModelDefinition`, so meshkit preserves that layering
rather than forcing a partial migration that would diverge from the
schemas contract.
Files migrated:
- converter/k8s.go, files/identification.go, orchestration/design.go
- models/patterns/pattern.go, models/registration/{dir,register,utils}.go
- models/meshmodel/core/v1beta1/{host,policy}.go,
models/meshmodel/registry/{registry.go,v1beta1/{component,model}_filter.go}
- registry/{component,model,component_test,spreadsheet_update}.go
- utils/component/{generator,openapi_generator,generator_test}.go
- generators/{github,artifacthub}/package.go, generators/models/interfaces.go
- schema/registry_test.go (latest-wins resolution now picks v1beta3 assets)
Intentional carve-outs:
- models/meshmodel/core/policies/rego_policy_relationship.go remains on
v1beta1/pattern because EvaluationResponse has not been ported into
v1beta3/design yet; migrating this file is a follow-up that requires
adding an evaluation package parallel to v1beta3/design on the schemas
side.
- validator/validate_test.go retains v1beta1/model — the test is
exercising the validator against a specific v1beta1 model wire
schema, not verifying the canonical-casing contract.
- registry/relationship.go retains v1beta1/model as a standalone
RelationshipDefinition reference; the relationship schemas graph
separately migrates per the Phase 3 plan.
Validator registration behavior:
- Existing on-disk designs authored against designs.meshery.io/v1beta1
remain valid for parsing via files.ParseFileAsMesheryDesign; it now
accepts both v1beta1 and v1beta3 design schemaVersion strings.
- models/registration/utils.go accepts both v1beta1 and v1beta3
Component/Model SchemaVersion literals when dispatching getEntity.
Generator golden regeneration:
- generators/{github,artifacthub} *.json goldens refresh to reflect the
v1beta3/component wire shape: schemaVersion now resolves to
components.meshery.io/v1beta2, sub_type → subType, created_at →
createdAt, updated_at → updatedAt, and a new deletedAt: null field.
These are additive/rename-only; no structural divergence from the
previous output beyond the canonical-casing contract.
This PR unblocks ~85 deferred component/pattern/model repoint sites in
meshery/meshery (39 component, 34 pattern/design, 12 model) and lets
downstream consumers pin meshkit at this HEAD to continue the Phase 3
canonical-casing rollout. See identifier-naming-migration plan:
https://github.com/meshery/schemas/blob/master/docs/identifier-naming-migration.md
Relates-to: meshery/schemas#825 (v1beta3 helpers), meshery/schemas#826
(gorm foreignKey fix), meshery/schemas#824 (workspace/connection env
refs).
Signed-off-by: Yi Nuo <218099172+yi-nuo426@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Migrates meshkit’s schema-type usage to the canonical-casing constructs introduced in @meshery/schemas@1.1.x (notably v1beta3 component/design), updating wire schemaVersion constants and regenerating generator outputs to match the new casing/version defaults while preserving select legacy types where required by the schemas type graph.
Changes:
- Repoint component/design consumers to v1beta3 (and v1beta2 where required) and update
SchemaVersionconstants accordingly. - Update design parsing/registration logic to accept both legacy and canonical
schemaVersionliterals. - Bump
github.com/meshery/schemasdependency and refresh generated JSON goldens to match canonical casing and schemaVersion bumps.
Reviewed changes
Copilot reviewed 38 out of 39 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/component/openapi_generator.go | Emit v1beta3 component defs (and updated schemaVersion constants) from OpenAPI-derived input. |
| utils/component/generator.go | Generate component definitions using v1beta3 schemaVersion constants/types. |
| utils/component/generator_test.go | Update component import to v1beta3 for tests. |
| schema/registry_test.go | Adjust expectations for “latest wins” discovery to prefer v1beta3 assets where present. |
| registry/spreadsheet_update.go | Update component type import to v1beta3 for spreadsheet-driven workflows. |
| registry/model.go | Use updated model schemaVersion constant (from v1beta3 package) while retaining v1beta1 model types. |
| registry/component.go | Switch component types/constants to v1beta3 and read v1beta3 component schema asset. |
| registry/component_test.go | Update component import to v1beta3 for registry tests. |
| orchestration/design.go | Update component import to v1beta3. |
| models/registration/utils.go | Accept both legacy and canonical schemaVersion literals when dispatching entity decoding. |
| models/registration/register.go | Update component import to v1beta3 in registration types. |
| models/registration/dir.go | Update component import to v1beta3 for directory registration. |
| models/patterns/pattern.go | Migrate pattern/design handling to v1beta3/design while bridging component type versions as required. |
| models/meshmodel/registry/v1beta1/model_filter.go | Update component import to v1beta3 in v1beta1 registry filter package. |
| models/meshmodel/registry/v1beta1/component_filter.go | Update component import to v1beta3 for component queries/joins. |
| models/meshmodel/registry/registry.go | Update component import to v1beta3 in registry manager implementation. |
| models/meshmodel/core/v1beta1/policy.go | Isolated model type migration to v1beta2/model for policy definition. |
| models/meshmodel/core/v1beta1/host.go | Update component import to v1beta3 for host summaries. |
| models/meshmodel/core/policies/rego_policy_relationship.go | Add clarifying note and intentionally retain v1beta1/pattern dependency for evaluation types. |
| files/identification.go | Parse Meshery designs as v1beta3/design while accepting both v1beta1 and v1beta3 schemaVersion literals. |
| converter/k8s.go | Update schema imports to v1beta3/design and v1beta2/component for k8s conversion path. |
| generators/models/interfaces.go | Update component import to v1beta3 for generator interfaces. |
| generators/github/package.go | Update generator to use v1beta3 component types. |
| generators/artifacthub/package.go | Update generator to use v1beta3 component types. |
| generators/github/gateway-api/GatewayClass.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/github/channels/Channel.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/github/acm-controller/MeshSync.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/github/acm-controller/Broker.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/ProviderRevision.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/Provider.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/KubernetesTarget.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/KubernetesApplicationResource.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/KubernetesApplication.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/ConfigurationRevision.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/Configuration.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/Composition.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| generators/artifacthub/crossplane-types/CompositeResourceDefinition.json | Regenerated golden: schemaVersion bump, canonical field casing, add deletedAt. |
| go.mod | Bump github.com/meshery/schemas and pgx indirect dependency. |
| go.sum | Update checksums for bumped dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return parsed, nil | ||
| } | ||
| return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta1.DesignSchemaVersion) | ||
| return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta3.DesignSchemaVersion) |
| return parsed, nil | ||
| } | ||
| return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta1.DesignSchemaVersion) | ||
| return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta3.DesignSchemaVersion) |
| schmeaVersion "github.com/meshery/schemas/models/v1beta3" | ||
| "github.com/meshery/schemas/models/v1beta3/component" |
There was a problem hiding this comment.
Code Review
This pull request migrates various Meshery constructs, including components, models, and designs, from v1beta1 to newer schema versions (v1beta3 and v1beta2). Key changes include updating Go imports, transitioning JSON fields to camelCase (e.g., subType, createdAt), and adjusting test expectations for asset locations and version strings. Feedback identifies critical bugs where ComponentDefinition objects are initialized without a Status field in the generator utilities, which will lead to nil pointer dereference panics during registration. Additionally, there is a reported inconsistency in handling v1beta3 wire version strings in the entity identification logic, which could lead to parsing failures.
| @@ -81,7 +81,7 @@ func IncludeComponentBasedOnGroup(resource string, groupFilter string) (bool, er | |||
|
|
|||
| func Generate(resource string) (component.ComponentDefinition, error) { | |||
| cmp := component.ComponentDefinition{} | |||
There was a problem hiding this comment.
The ComponentDefinition is initialized without a Status. In models/registration/register.go, the registration logic dereferences this field (e.g., status := *comp.Status), which will cause a nil pointer dereference panic during the registration of generated components. Consider assigning a default status such as entity.Enabled.
| c := component.ComponentDefinition{ | ||
| SchemaVersion: v1beta1.ComponentSchemaVersion, | ||
| SchemaVersion: v1beta3.ComponentSchemaVersion, |
| // and model wire format to camelCase (see v1beta3/const.go); the legacy | ||
| // v1beta1 strings remain accepted for backward compatibility with | ||
| // existing on-disk definitions that have not been regenerated yet. | ||
| case v1beta1.ComponentSchemaVersion, v1beta3.ComponentSchemaVersion: |
There was a problem hiding this comment.
There is an inconsistency between the wire versions expected by the tests and those handled here. The tests in schema/registry_test.go expect components.meshery.io/v1beta3 for core components, but v1beta3.ComponentSchemaVersion is components.meshery.io/v1beta2 (as seen in the golden files and PR description). Consequently, v1beta3 components will fall through to the default case and fail to be identified. You should explicitly handle the v1beta3 wire version string here.
Summary
v1beta1/component,v1beta1/pattern, andv1beta2/designto the canonical-casing types published in@meshery/schemas@1.1.x(v1beta3/component, v1beta3/design).v1beta1/modelonComponentDefinition.Modeland similar embedded pointer fields because the schemas type graph itself wires v1beta3/component.Model at*v1beta1/model.ModelDefinitionperv1beta3/const.go— migrating meshkit to v1beta2/model across the board would diverge from the schemas contract.File changes (grouped by package)
Core migrations (v1beta1/component → v1beta3/component)
converter/k8s.go,files/identification.go,orchestration/design.gomodels/registration/{dir,register,utils}.gomodels/meshmodel/core/v1beta1/host.go,models/meshmodel/registry/{registry.go,v1beta1/{component,model}_filter.go}registry/{component,model,spreadsheet_update}.go+ testsutils/component/{generator,openapi_generator,generator_test}.gogenerators/{github,artifacthub}/package.go,generators/models/interfaces.goDesign migrations (v1beta1/pattern → v1beta3/design)
converter/k8s.go,files/identification.go,models/patterns/pattern.goModel migration (v1beta1/model → v1beta2/model)
models/meshmodel/core/v1beta1/policy.go(isolated type — no cross-construct assignment)Test fixture updates
schema/registry_test.go— latest-wins resolution now picks v1beta3 for component/connection/design/relationship/environment/workspace, and v1beta2 for model (no v1beta3/model YAML is shipped).registry/component_test.go,utils/component/generator_test.go— import updates only.Auto-regenerated goldens
generators/github/*.json,generators/artifacthub/crossplane-types/*.json— schemaVersionv1beta1→v1beta2(matchesv1beta3.ComponentSchemaVersion),sub_type→subType,created_at→createdAt,updated_at→updatedAt, newdeletedAt: nullfield. Additive/rename-only; no structural divergence.Notable field renames
ComponentDefinition.ModelId→ComponentDefinition.ModelID(v1beta3/component renamed the gorm field; meshkit does not reference it directly, so no call-site changes were needed)DeletedAt core.NullTime(emitted asdeletedAtin goldens)SchemaVersionwire values nowmodels.meshery.io/v1beta2,components.meshery.io/v1beta2,designs.meshery.io/v1beta3(perv1beta3/const.go)Intentional carve-outs
models/meshmodel/core/policies/rego_policy_relationship.goretainsv1beta1/patternforPatternFile+EvaluationResponse. v1beta3/design does not yet ship anEvaluationResponseequivalent (and v1beta1/evaluation still types itsDesignfield aspatternv1beta1.PatternFile). Migrating this handler is a follow-up that requires adding an evaluation package parallel to v1beta3/design on the schemas side. In-line comment added.validator/validate_test.goretainsv1beta1/model— the test is validating a specific v1beta1 wire schema, not verifying canonical-casing.registry/relationship.goretainsv1beta1/modelas a standaloneRelationshipDefinition.Modelreference; the relationship schemas graph migrates separately per Phase 3.Backward compatibility
files.ParseFileAsMesheryDesignnow accepts bothdesigns.meshery.io/v1beta1anddesigns.meshery.io/v1beta3on the wire. Existing on-disk designs do not need to be regenerated.models/registration.getEntityaccepts both v1beta1 and v1beta3 Component/Model schemaVersion literals when dispatching entity parsing.Test plan
go build ./...— cleango vet ./...— cleango test -count=1 -short ./...— all packages greengo test -count=1 -short -race ./models/... ./registry/... ./schema/... ./files/... ./generators/... ./utils/component/... ./validator/... ./converter/... ./orchestration/...— all packages green with race detectiondeletedAt: null)Unblocks
After this lands and a meshkit release is tagged, meshery/meshery can pin the new meshkit version and proceed with its Phase 3 repoint of the ~85 deferred component/pattern/design/model sites. Until the release is cut, meshery can consume this branch via
go get github.com/meshery/meshkit@<commit>.Related
ModelId→ModelIDfix on v1beta3/component