-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sur 02112024 docs #4834
base: stable
Are you sure you want to change the base?
Sur 02112024 docs #4834
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ title: Schema | |||||||
import CodeBlock from "@theme/CodeBlock"; | ||||||||
import Tabs from '@theme/Tabs'; | ||||||||
import TabItem from '@theme/TabItem'; | ||||||||
import import_infrastructureExtensionRackYaml from '!!raw-loader!../../../models/examples/extension_rack.yml'; | ||||||||
|
||||||||
# Schema | ||||||||
|
||||||||
|
@@ -14,7 +15,61 @@ Out of the box, Infrahub doesn't have a schema for most things and it's up to us | |||||||
|
||||||||
Unlike traditional databases that can only have one schema at a time, in Infrahub it is possible to have a different schema per branch. This is possible because the schema itself is stored in the database like any other object. | ||||||||
|
||||||||
There are several ways to [load a new schema](/guides/import-schema). | ||||||||
## Schema file | ||||||||
|
||||||||
The recommended way to manage and load a schema is to create a schema file in YAML format. With a schema file it's possible to: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not necessarily the recommended way. It's just a way of doing it together with the repository method. Arguably, in a production environment, you might want to have the schema in an external repository and let Infrahub import the changes from it.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wvandeun @BaptisteGi - Currently, under the Guides section, we have a 'Creating a Schema' page that covers a lot, including how to import the schema file. Then we have the next page, 'Schema File', which also covers how to import a schema file. That's why I thought it would be good to move the contents of that page under the 'Schema' topics. I didn't change anything except for adding 'How to generate the token'. |
||||||||
|
||||||||
- Define new nodes | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
- Extend nodes, by adding attributes or relationships to the existing nodes | ||||||||
|
||||||||
At a high level, the format of the schema file looks like the following: | ||||||||
|
||||||||
```yaml | ||||||||
--- | ||||||||
version: '1.0' | ||||||||
nodes: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add the |
||||||||
- <new nodes are defined here> | ||||||||
extensions: | ||||||||
nodes: | ||||||||
- <node extensions are defined here> | ||||||||
``` | ||||||||
|
||||||||
<details> | ||||||||
<summary>Example of schema file that is defining new nodes and adding a relationship to an existing one</summary> | ||||||||
<CodeBlock language="yaml">{import_infrastructureExtensionRackYaml}</CodeBlock> | ||||||||
</details> | ||||||||
|
||||||||
:::note | ||||||||
|
||||||||
To help with the development process of a schema definition file, you can leverage [schema validation](/reference/schema-validation) within your editor. | ||||||||
|
||||||||
::: | ||||||||
|
||||||||
## Load a schema file | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe here we could guide people in the choice, when to use git integration vs infrahubctl, pros and cons. For instance I added that paragraph in the schema library:
|
||||||||
|
||||||||
Schema files can be loaded into Infrahub with the `infrahubctl` command or directly via the Git integration. For a detailed explanation and instructions on how to install `infrahubctl`, you can check out our [infrahubctl topic](/infrahubctl). | ||||||||
|
||||||||
<!-- vale off --> | ||||||||
### infrahubctl command | ||||||||
<!-- vale on --> | ||||||||
The `infrahubctl` command can be used to load individual schema files or multiple files as part of a directory. | ||||||||
|
||||||||
```shell | ||||||||
infrahubctl schema load <path to schema file or a directory> <path to schema file or a directory> | ||||||||
``` | ||||||||
|
||||||||
### Git integration | ||||||||
|
||||||||
You can defined a schema in an [external repository](/topics/repository). | ||||||||
The schemas that should be loaded must be declared in the ``.infrahub.yml`` file, under schemas. | ||||||||
|
||||||||
Individual files and directory are both supported. | ||||||||
|
||||||||
```yaml | ||||||||
--- | ||||||||
schemas: | ||||||||
- schemas/demo_edge_fabric.yml | ||||||||
``` | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can remove the following note below, it's redondant and not really related to the section |
||||||||
|
||||||||
:::note | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling this file becomes a hodgepodge of things:
Here we line out how docs should be organized. I think we should split up the multiple aspects of this file into their proper sections, taken into account that some parts might already exist (like the schema reference and creating a schema guide)
https://docs.infrahub.app/development/docs#organizing-new-pages