Skip to content
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

Open
wants to merge 5 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions docs/docs/guides/import-schema.mdx

This file was deleted.

4 changes: 3 additions & 1 deletion docs/docs/infrahubctl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ The `infrahubctl` command line utility is installed as a part of the [Infrahub S
| `INFRAHUB_API_TOKEN` | `06438eb2-8019-4776-878c-0941b1f1d1ec` |
| `INFRAHUB_DEFAULT_BRANCH` | main |

> You can also provide the location of a configuration file via the environment variable `INFRAHUBCTL_CONFIG`.
Don't have the token yet? You can find more information on how to manage the API token in this [guide](/guides/managing-api-tokens).

### `infrahubctl.toml` file

You can also provide the location of a configuration file via the environment variable `INFRAHUBCTL_CONFIG`. Create the `infrahubctl.toml` file and set the `INFRAHUBCTL_CONFIG` environment variable to its location.

```toml title="infrahubctl.toml"
server_address="http://localhost:8000"
api_token="06438eb2-8019-4776-878c-0941b1f1d1ec"
Expand Down
57 changes: 56 additions & 1 deletion docs/docs/topics/schema.mdx
Copy link
Contributor

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:

  • It's a guide that explains how to load a schema
  • It's a topic that explains what the schema is
  • It's a reference that explains what the format of a schema file is

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

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

infrahubctl schema load is great when you are developing a schema or trying to test something, or when you want to make one of changes, which might be required during some migrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Define new nodes
- Define new nodes
- Define new generics

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

Choose a reason for hiding this comment

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

Maybe add the generics section as well

- <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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

There are several ways to [load a schema in Infrahub](https://docs.infrahub.app/guides/import-schema):

Quick View: To take a quick look at a schema, you can use Infrahub CTL. Follow [this guide](https://docs.infrahub.app/infrahubctl) to install Infrahub CTL.
Controlled Integration: For a more organized and unified approach to loading schemas, you can connect a Git repository. Follow [this guide](https://docs.infrahub.app/guides/repository) to connect a Git repository.


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
```
Copy link
Contributor

Choose a reason for hiding this comment

The 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 load schema


:::note

Expand Down
2 changes: 1 addition & 1 deletion docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const sidebars: SidebarsConfig = {
items: [
'guides/installation',
'guides/create-schema',
'guides/import-schema',
'guides/menu',
'guides/accounts-permissions',
'guides/groups',
Expand Down Expand Up @@ -100,6 +99,7 @@ const sidebars: SidebarsConfig = {
'topics/ipam',
'topics/local-demo-environment',
'topics/generator',
'topics/schema',
'topics/graphql',
'topics/groups',
'topics/metadata',
Expand Down
Loading