Skip to content

Commit bdd4d32

Browse files
committed
Update doc
1 parent 4d7cf89 commit bdd4d32

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

docs/docs/python-sdk/topics/object_file.mdx

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: Manage data with Object Files
33
---
44

5-
# Manage data with Object filess
5+
# Manage data with Object files
66

77
## Introduction
88

9-
An Object file is a YAML file that allows you to manage data to be loaded in Infrahub based on your own custom schema.
9+
An Object file is a YAML file that allows you to manage data to be loaded in Infrahub based on your own custom schema. It provides a declarative way to define and manage resources in your Infrahub instance.
1010

11-
Object files work well for models that don't change too often and/or that needs to be tracked in Git: Examples: Groups, tags, Users etc ..
11+
Object files work well for models that don't change too often and/or that need to be tracked in Git. Examples include: Groups, tags, Users, etc.
1212
Below is an example of an Object file that defines tags (`BuiltinTag`).
1313

1414
```yaml
@@ -23,22 +23,22 @@ spec:
2323
- name: Red
2424
```
2525
26-
Object files are meant to be used in an idempotent way and as such they would work better for models with a Human Friendly ID (hfid) defined.
26+
Object files are meant to be used in an idempotent way and as such they work better for models with a Human Friendly ID (HFID) defined. An HFID is a unique identifier that makes it easier to reference objects across different files and operations.
2727
2828
## Load Object files into Infrahub
2929
30-
Object files can be loaded into Infrahub using the `infrahub load object` command.
30+
Object files can be loaded into Infrahub using the `infrahub object load` command.
3131

3232
```bash
3333
infrahub object load <path_to_object_file>
3434
```
3535

3636
Multiple object files can be loaded at once by specifying the path to multiple files or by specifying a directory.
3737

38-
The object `object load` command will create/update the objects using an `Upsert` operation. All objects previously loaded will NOT be deleted in the Infrahub instance.
39-
Also, if some objects present in different files are identical are dependent on each other, the `object load` command will NOT calculate the dependencies between the objects and as such it's the reponsability of the users to execute the command in the right order.
38+
The `object load` command will create/update the objects using an `Upsert` operation. All objects previously loaded will NOT be deleted in the Infrahub instance.
39+
Also, if some objects present in different files are identical and dependent on each other, the `object load` command will NOT calculate the dependencies between the objects and as such it's the responsibility of the users to execute the command in the right order.
4040

41-
### Validate the format of the object facilitates
41+
### Validate the format of object files
4242

4343
The object file can be validated using the `infrahub object validate` command.
4444

@@ -48,9 +48,9 @@ infrahub object validate <path_to_object_file>
4848

4949
## Object file format
5050

51-
All object files must start with the following format, all other format will be automatically ignored
51+
All object files must start with the following format, all other formats will be automatically ignored.
5252
Each file is intended for one specific top level kind, but one file can include multiple nested objects of any kind.
53-
The kind of the top level object must be defined in spec/kind
53+
The kind of the top level object must be defined in spec/kind.
5454

5555
```yaml
5656
---
@@ -62,12 +62,12 @@ spec:
6262
- [...]
6363
```
6464

65-
> Multiple documents in a single Yaml file are also supported, each document will be loaded as a separately. Documents are separated by `---`
65+
> Multiple documents in a single YAML file are also supported, each document will be loaded separately. Documents are separated by `---`
6666

6767
### Relationship of cardinality One
6868

6969
A relationship of cardinality one can either reference an existing node via its HFID or create a new node if it doesn't exist.
70-
In the example below, both `site` and `primary_ip` are relationship of cardinality one.
70+
In the example below, both `site` and `primary_ip` are relationships of cardinality one.
7171

7272
```yaml
7373
---
@@ -85,12 +85,12 @@ spec:
8585

8686
### Relationship of cardinality Many
8787

88-
A relationship of cardinality many can reference existing nodes via their HFID or define nested objects
88+
A relationship of cardinality many can reference existing nodes via their HFID or define nested objects.
8989

9090
#### Existing nodes referenced by their HFID
9191

9292
Existing nodes can be referenced by their HFID in string format or in list format.
93-
In the example below, both `best_friends` and `tags` are relationship of cardinality many.
93+
In the example below, both `best_friends` and `tags` are relationships of cardinality many.
9494

9595
> An HFID is composed of a single value, it's possible to use a string instead of a list
9696

@@ -103,7 +103,7 @@ spec:
103103
data:
104104
- name: Mike Johnson
105105
height: 175
106-
best_friends: # Relationship of cardinality many that referenced existing nodes based on their HFID
106+
best_friends: # Relationship of cardinality many that references existing nodes based on their HFID
107107
- [Jane Smith, Max]
108108
- [Sarah Williams, Charlie]
109109
tags:
@@ -113,17 +113,17 @@ spec:
113113

114114
#### Nested Objects
115115

116-
When defining nested objects, the node will be automatically created if it doesn't exist and if their relationship between the parent object and the nested object it will be automatically inserted.
117-
For example, in the example below, the `owner` of a `TestingDog` doesn't need to be specify because it will be automatically inserted.
116+
When defining nested objects, the node will be automatically created if it doesn't exist and if the relationship between the parent object and the nested object exists, it will be automatically inserted.
117+
For example, in the example below, the `owner` of a `TestingDog` doesn't need to be specified because it will be automatically inserted.
118118

119-
For 2 different syntaxes are supported:
119+
Two different syntax are supported:
120120

121-
- A dictionnary with multiple value under data
121+
- A dictionary with multiple values under data
122122
- A list of objects
123123

124124
##### Nested objects as a dictionary
125125

126-
In the example below, `tags` is a relationship of cardinality many that is defined as a dictionnary with multiple values under data.
126+
In the example below, `tags` is a relationship of cardinality many that is defined as a dictionary with multiple values under data.
127127

128128
> The kind is optional here because there is only one option possible (not a generic)
129129

@@ -149,7 +149,7 @@ For more complex cases, the list of objects format is more flexible.
149149
##### Nested objects as a list of objects
150150

151151
In the example below, `animals` is a relationship of cardinality many that is defined as a list of objects.
152-
Each object must contains a `data` key and each object can also define a specific `kind`.
152+
Each object must contain a `data` key and each object can also define a specific `kind`.
153153

154154
> If the kind is not specified, it will be inferred from schema
155155

@@ -177,4 +177,19 @@ spec:
177177

178178
### Support for Metadata
179179

180-
Please stay tuned, the Object file does not support metadata yet, neither on attribute or relationship.
180+
Metadata support is planned for future releases. Currently, the Object file does not support metadata on attributes or relationships.
181+
182+
## Troubleshooting
183+
184+
### Common Issues
185+
186+
1. **Objects not being created**: Ensure that the YAML syntax is correct and that the file follows the required format.
187+
2. **Dependency errors**: When objects depend on each other, load them in the correct order (dependencies first).
188+
3. **Validation errors**: Use the `infrahub object validate` command to check for syntax errors before loading.
189+
190+
### Best Practices
191+
192+
1. Use Human Friendly IDs (HFIDs) for all objects to ensure consistent referencing.
193+
2. Keep object files organized by model type or purpose.
194+
3. Validate object files before loading them into production environments.
195+
4. Use comments in your YAML files to document complex relationships or dependencies.

0 commit comments

Comments
 (0)