infrahub-schema-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInfrahub Schema Creator
Infrahub Schema 创建器
Overview
概述
Expert guidance for designing and building Infrahub
schemas. Schemas are YAML files defining nodes (concrete
types), generics (abstract base types), attributes,
relationships, and extensions.
用于设计和构建Infrahub schema的专业指南。Schema是YAML格式文件,定义了节点(实体类型)、泛型(抽象基类型)、属性、关联关系和扩展。
When to Use
适用场景
- Designing new data models or schema nodes
- Adding attributes or relationships to existing schemas
- Setting up hierarchical location trees or component/parent patterns
- Configuring display properties (human_friendly_id, display_label)
- Migrating or refactoring existing schemas
- Debugging schema validation errors
- 设计新的数据模型或schema节点
- 为现有schema添加属性或关联关系
- 搭建层级位置树或组件/父级模式
- 配置展示属性(human_friendly_id、display_label)
- 迁移或重构现有schema
- 调试schema验证报错
Rule Categories
规则分类
| Priority | Category | Prefix | Description |
|---|---|---|---|
| CRITICAL | Naming | | Namespace, node, attribute naming |
| CRITICAL | Relationships | | IDs, peers, component/parent |
| HIGH | Attributes | | Defaults, dropdowns, deprecated |
| HIGH | Hierarchy | | Hierarchical generics, parent/children |
| HIGH | Display | | human_friendly_id, order_weight |
| MEDIUM | Extensions | | Cross-file via extensions block |
| MEDIUM | Uniqueness | | Constraint format, __value suffix |
| MEDIUM | Migration | | Add/remove attributes, state: absent |
| LOW | Validation | | Common errors, pre-check checklist |
| 优先级 | 分类 | 前缀 | 描述 |
|---|---|---|---|
| 严重 | 命名 | | 命名空间、节点、属性命名 |
| 严重 | 关联关系 | | ID、对等节点、组件/父级 |
| 高 | 属性 | | 默认值、下拉选项、废弃标记 |
| 高 | 层级 | | 层级泛型、父级/子级 |
| 高 | 展示 | | human_friendly_id、排序权重 |
| 中 | 扩展 | | 通过扩展块实现跨文件配置 |
| 中 | 唯一性 | | 约束格式、__value 后缀 |
| 中 | 迁移 | | 添加/移除属性、state: absent |
| 低 | 验证 | | 常见错误、预检查清单 |
Schema File Basics
Schema 文件基础
yaml
---yaml
---yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
version: "1.0"
generics: # Abstract base definitions (shared attributes/relationships)
- ... nodes: # Concrete object types
- ...
extensions: # Add attributes/relationships to existing nodes from other files
nodes:
- ...
Always include the `$schema` comment for IDE validation.
Only `version` is required at the top level.version: "1.0"
generics: # 抽象基类定义(共享的属性/关联关系)
- ... nodes: # 实体对象类型
- ...
extensions: # 为其他文件中定义的现有节点添加属性/关联关系
nodes:
- ...
请始终添加`$schema`注释用于IDE验证。
顶层配置中仅`version`为必填项。Supporting References
参考资料
- reference.md -- Complete property tables for nodes, generics, attributes, relationships
- examples.md -- Full schema patterns from production repos
- validation.md -- commands, migration strategies, pre-validation checklist
infrahubctl - ../infrahub-common/infrahub-yml-reference.md -- .infrahub.yml project configuration
- ../infrahub-common/rules/ -- Shared rules (git integration, caching) across all skills
- rules/ -- Individual rules by category prefix
- reference.md -- 节点、泛型、属性、关联关系的完整属性表
- examples.md -- 来自生产环境仓库的完整schema模式示例
- validation.md -- 命令、迁移策略、预验证检查清单
infrahubctl - ../infrahub-common/infrahub-yml-reference.md -- .infrahub.yml项目配置参考
- ../infrahub-common/rules/ -- 所有skill共享的通用规则(git集成、缓存)
- rules/ -- 按分类前缀划分的单条规则文档