Standardize schemas/models/core import to bare core alias#977
Standardize schemas/models/core import to bare core alias#977leecalcote merged 1 commit intomasterfrom
Conversation
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
There was a problem hiding this comment.
Pull request overview
Standardizes Go imports of github.com/meshery/schemas/models/core by removing non-standard aliases (coreV1, corev1alpha1) and using the canonical core.<Type> form across the touched MeshKit file handling and registry code, aligning with the project’s stated convention and addressing #971.
Changes:
- Replace
coreV1import alias with barecorein file sanitization tests and file identification logic. - Replace
corev1alpha1import alias with barecorein registry component styling updates. - Update affected type references (
IaCFileTypes,MesheryDesign,K8sManifest,HelmChart,DockerCompose,K8sKustomize,Shape) to usecore.*.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
registry/component.go |
Removes corev1alpha1 alias and updates style Shape cast to core.Shape. |
files/tests/sanitization_test.go |
Removes coreV1 alias and updates expected IaC file type constants to core.*. |
files/identification.go |
Removes coreV1 alias and updates identified file type + trace map to core.*. |
files/error.go |
Removes coreV1 alias and updates error helper signature to map[core.IaCFileTypes]error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase by removing package aliases for the core schemas and updating type references accordingly. A review comment identifies a redundant assignment within a loop in registry/component.go that should be moved for efficiency, along with a suggestion to use more idiomatic type conversion for the Shape field.
| if c.Shape != "" { | ||
| shape := c.Shape | ||
| compDefStyles.Shape = (*corev1alpha1.Shape)(&shape) | ||
| compDefStyles.Shape = (*core.Shape)(&shape) |
There was a problem hiding this comment.
This assignment is redundant as it is executed in every iteration of the loop starting at line 181, despite not depending on the loop variable key. For improved efficiency, consider moving the if c.Shape != "" block outside of the loop. Furthermore, the pointer cast (*core.Shape)(&shape) is non-idiomatic; if core.Shape is a defined type (e.g., type Shape string) rather than a type alias, this will cause a compilation error. A more idiomatic approach is to perform a type conversion: s := core.Shape(shape); compDefStyles.Shape = &s.
Summary
Replaces non-standard import aliases (
coreV1,corev1alpha1) forgithub.com/meshery/schemas/models/corewith the barecoreimport across 4 files.The project standard is
core.Uuid,core.Map, etc. — no aliases.Fixes #971
Files changed
files/error.go—coreV1→corefiles/identification.go—coreV1→corefiles/tests/sanitization_test.go—coreV1→coreregistry/component.go—corev1alpha1→coreTest plan
go build ./...passesgo test ./...passes