From 8437658402ce55a377391d698718702334c47e1b Mon Sep 17 00:00:00 2001 From: Suresh Date: Sat, 2 Nov 2024 20:19:16 +0000 Subject: [PATCH 1/5] added schema to topics sidebar --- docs/sidebars.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sidebars.ts b/docs/sidebars.ts index 09ddea929e..1b14384d7e 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -100,6 +100,7 @@ const sidebars: SidebarsConfig = { 'topics/ipam', 'topics/local-demo-environment', 'topics/generator', + 'topics/schema', 'topics/graphql', 'topics/groups', 'topics/metadata', From 54a8c36bf291ad9896c94f51edb8c5e48eac3016 Mon Sep 17 00:00:00 2001 From: Suresh Date: Sat, 2 Nov 2024 21:14:12 +0000 Subject: [PATCH 2/5] edited infrahubctl page --- docs/docs/infrahubctl.mdx | 4 ++- docs/docs/topics/schema.mdx | 57 ++++++++++++++++++++++++++++++++++++- docs/sidebars.ts | 1 - 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/docs/docs/infrahubctl.mdx b/docs/docs/infrahubctl.mdx index fd1d21929a..ac09ac0a2f 100644 --- a/docs/docs/infrahubctl.mdx +++ b/docs/docs/infrahubctl.mdx @@ -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`. +You can obtain the `INFRAHUB_API_TOKEN` from the web GUI by navigating to 'Account Settings' under your profile and selecting '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" diff --git a/docs/docs/topics/schema.mdx b/docs/docs/topics/schema.mdx index b09c0728ab..a67f7bdf43 100644 --- a/docs/docs/topics/schema.mdx +++ b/docs/docs/topics/schema.mdx @@ -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: + +- Define new nodes +- 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: + - +extensions: + nodes: + - +``` + +
+ Example of schema file that is defining new nodes and adding a relationship to an existing one + {import_infrastructureExtensionRackYaml} +
+ +:::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 + +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). + + +### infrahubctl command + +The `infrahubctl` command can be used to load individual schema files or multiple files as part of a directory. + +```shell +infrahubctl schema load +``` + +### 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 +``` :::note diff --git a/docs/sidebars.ts b/docs/sidebars.ts index 1b14384d7e..0ee4f82e1e 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -66,7 +66,6 @@ const sidebars: SidebarsConfig = { items: [ 'guides/installation', 'guides/create-schema', - 'guides/import-schema', 'guides/menu', 'guides/accounts-permissions', 'guides/groups', From 949a87cbcb51f85f81ead51a94e34b9bb11bf925 Mon Sep 17 00:00:00 2001 From: Suresh Date: Sat, 2 Nov 2024 21:21:44 +0000 Subject: [PATCH 3/5] infrahubctl page --- docs/docs/infrahubctl.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/infrahubctl.mdx b/docs/docs/infrahubctl.mdx index ac09ac0a2f..ef526108e5 100644 --- a/docs/docs/infrahubctl.mdx +++ b/docs/docs/infrahubctl.mdx @@ -32,7 +32,7 @@ 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 obtain the `INFRAHUB_API_TOKEN` from the web GUI by navigating to 'Account Settings' under your profile and selecting 'Tokens'. +You can obtain the `INFRAHUB_API_TOKEN` from the web GUI by navigating to 'Account Settings' under your profile and selecting 'Tokens'. You can also manage the tokens via GraphQL queries. You can find more information on how to do that [here](/guides/managing-api-tokens). ### `infrahubctl.toml` file From 8172ea45c6ed382f2599e477187fd31db7f875d9 Mon Sep 17 00:00:00 2001 From: Suresh Date: Sun, 3 Nov 2024 19:37:14 +0000 Subject: [PATCH 4/5] deleted import-schema page --- docs/docs/guides/import-schema.mdx | 62 ------------------------------ 1 file changed, 62 deletions(-) delete mode 100644 docs/docs/guides/import-schema.mdx diff --git a/docs/docs/guides/import-schema.mdx b/docs/docs/guides/import-schema.mdx deleted file mode 100644 index c9e5cad5ca..0000000000 --- a/docs/docs/guides/import-schema.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Import Schema file ---- - -import CodeBlock from "@theme/CodeBlock"; -import import_infrastructureExtensionRackYaml from '!!raw-loader!../../../models/examples/extension_rack.yml'; - -# 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: - -- Define new nodes -- 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: - - -extensions: - nodes: - - -``` - -
- Example of schema file that is defining new nodes and adding a relationship to an existing one - {import_infrastructureExtensionRackYaml} -
- -:::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 - -Schema files can be loaded into Infrahub with the `infrahubctl` command or directly via the Git integration. - - -### infrahubctl command - -The `infrahubctl` command can be used to load individual schema files or multiple files as part of a directory. - -```shell -infrahubctl schema load -``` - -### 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 -``` From f4d4aa66816bff0ddd9a555407ef9ef9dbb7e2ab Mon Sep 17 00:00:00 2001 From: Suresh Date: Thu, 7 Nov 2024 18:48:17 +0000 Subject: [PATCH 5/5] updated token guide --- docs/docs/infrahubctl.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/infrahubctl.mdx b/docs/docs/infrahubctl.mdx index ef526108e5..09bd2b1dac 100644 --- a/docs/docs/infrahubctl.mdx +++ b/docs/docs/infrahubctl.mdx @@ -32,7 +32,7 @@ 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 obtain the `INFRAHUB_API_TOKEN` from the web GUI by navigating to 'Account Settings' under your profile and selecting 'Tokens'. You can also manage the tokens via GraphQL queries. You can find more information on how to do that [here](/guides/managing-api-tokens). +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