Skip to content

feat(schemas): migrate to v1beta3 canonical-casing types (component, model, design)#988

Merged
leecalcote merged 1 commit intomasterfrom
feat/schemas-v1beta3-migration
Apr 23, 2026
Merged

feat(schemas): migrate to v1beta3 canonical-casing types (component, model, design)#988
leecalcote merged 1 commit intomasterfrom
feat/schemas-v1beta3-migration

Conversation

@leecalcote
Copy link
Copy Markdown
Member

Summary

  • Migrates meshkit's consumers of v1beta1/component, v1beta1/pattern, and v1beta2/design to the canonical-casing types published in @meshery/schemas@1.1.x (v1beta3/component, v1beta3/design).
  • Retains v1beta1/model on ComponentDefinition.Model and similar embedded pointer fields because the schemas type graph itself wires v1beta3/component.Model at *v1beta1/model.ModelDefinition per v1beta3/const.go — migrating meshkit to v1beta2/model across the board would diverge from the schemas contract.
  • 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 HEAD to continue the Phase 3 canonical-casing rollout.

File changes (grouped by package)

Core migrations (v1beta1/component → v1beta3/component)

  • converter/k8s.go, files/identification.go, orchestration/design.go
  • models/registration/{dir,register,utils}.go
  • models/meshmodel/core/v1beta1/host.go, models/meshmodel/registry/{registry.go,v1beta1/{component,model}_filter.go}
  • registry/{component,model,spreadsheet_update}.go + tests
  • utils/component/{generator,openapi_generator,generator_test}.go
  • generators/{github,artifacthub}/package.go, generators/models/interfaces.go

Design migrations (v1beta1/pattern → v1beta3/design)

  • converter/k8s.go, files/identification.go, models/patterns/pattern.go

Model 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 — schemaVersion v1beta1v1beta2 (matches v1beta3.ComponentSchemaVersion), sub_typesubType, created_atcreatedAt, updated_atupdatedAt, new deletedAt: null field. Additive/rename-only; no structural divergence.

Notable field renames

  • ComponentDefinition.ModelIdComponentDefinition.ModelID (v1beta3/component renamed the gorm field; meshkit does not reference it directly, so no call-site changes were needed)
  • v1beta3/component adds DeletedAt core.NullTime (emitted as deletedAt in goldens)
  • SchemaVersion wire values now models.meshery.io/v1beta2, components.meshery.io/v1beta2, designs.meshery.io/v1beta3 (per v1beta3/const.go)

Intentional carve-outs

  • models/meshmodel/core/policies/rego_policy_relationship.go retains v1beta1/pattern for PatternFile + EvaluationResponse. v1beta3/design does not yet ship an EvaluationResponse equivalent (and v1beta1/evaluation still types its Design field as patternv1beta1.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.go retains v1beta1/model — the test is validating a specific v1beta1 wire schema, not verifying canonical-casing.
  • registry/relationship.go retains v1beta1/model as a standalone RelationshipDefinition.Model reference; the relationship schemas graph migrates separately per Phase 3.

Backward compatibility

  • files.ParseFileAsMesheryDesign now accepts both designs.meshery.io/v1beta1 and designs.meshery.io/v1beta3 on the wire. Existing on-disk designs do not need to be regenerated.
  • models/registration.getEntity accepts both v1beta1 and v1beta3 Component/Model schemaVersion literals when dispatching entity parsing.

Test plan

  • go build ./... — clean
  • go vet ./... — clean
  • go test -count=1 -short ./... — all packages green
  • go test -count=1 -short -race ./models/... ./registry/... ./schema/... ./files/... ./generators/... ./utils/component/... ./validator/... ./converter/... ./orchestration/... — all packages green with race detection
  • Generator goldens regenerated and match expected canonical-casing (schemaVersion bumps + camelCase timestamp fields + deletedAt: null)
  • Schema registry tests updated to reflect v1beta3 latest-wins resolution; schema-version fallback for legacy v1beta1 design still resolves correctly

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

…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>
Copilot AI review requested due to automatic review settings April 23, 2026 19:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SchemaVersion constants accordingly.
  • Update design parsing/registration logic to accept both legacy and canonical schemaVersion literals.
  • Bump github.com/meshery/schemas dependency 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.

Comment thread files/identification.go
return parsed, nil
}
return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta1.DesignSchemaVersion)
return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta3.DesignSchemaVersion)
Comment thread files/identification.go
return parsed, nil
}
return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta1.DesignSchemaVersion)
return pattern.PatternFile{}, utils.ErrInvalidConstructSchemaVersion("design", parsed.SchemaVersion, v1beta3.DesignSchemaVersion)
Comment thread registry/component.go
Comment on lines +20 to +21
schmeaVersion "github.com/meshery/schemas/models/v1beta3"
"github.com/meshery/schemas/models/v1beta3/component"
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Comment on lines 126 to +127
c := component.ComponentDefinition{
SchemaVersion: v1beta1.ComponentSchemaVersion,
SchemaVersion: v1beta3.ComponentSchemaVersion,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the standard component generator, the ComponentDefinition created here lacks a Status value. This will lead to a panic in models/registration/register.go when the component is processed. Please ensure a default status is set.

// 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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

@leecalcote leecalcote merged commit f01c33f into master Apr 23, 2026
8 checks passed
@leecalcote leecalcote deleted the feat/schemas-v1beta3-migration branch April 23, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants