You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add data processing strategy for object files with range expansion support
- Introduced `strategy` field in object file specification to control data processing.
- Implemented `DataProcessor` classes for normal and range expansion strategies.
- Updated validation and processing methods to utilize the specified strategy.
- Enhanced tests to cover new strategy functionality and ensure correct behavior.
Copy file name to clipboardExpand all lines: docs/docs/python-sdk/topics/object_file.mdx
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,12 +60,24 @@ apiVersion: infrahub.app/v1
60
60
kind: Object
61
61
spec:
62
62
kind: <NamespaceName>
63
+
strategy: <normal|range_expand> # Optional, defaults to normal
63
64
data:
64
65
- [...]
65
66
```
66
67
67
68
> Multiple documents in a single YAML file are also supported, each document will be loaded separately. Documents are separated by `---`
68
69
70
+
### Data Processing Strategies
71
+
72
+
The `strategy` field controls how the data in the object file is processed before loading into Infrahub:
73
+
74
+
| Strategy | Description | Default |
75
+
|----------|-------------|---------|
76
+
| `normal` | No data manipulation is performed. Objects are loaded as-is. | Yes |
77
+
| `range_expand` | Range patterns (e.g., `[1-5]`) in string fields are expanded into multiple objects. | No |
78
+
79
+
When `strategy` is not specified, it defaults to `normal`.
80
+
69
81
### Relationship of cardinality one
70
82
71
83
A relationship of cardinality one can either reference an existing node via its HFID or create a new node if it doesn't exist.
@@ -198,7 +210,19 @@ Metadata support is planned for future releases. Currently, the Object file does
198
210
199
211
## Range Expansion in Object Files
200
212
201
-
The Infrahub Python SDK supports **range expansion** for string fields in object files. This feature allows you to specify a range pattern (e.g., `[1-5]`) in any string value, and the SDK will automatically expand it into multiple objects during validation and processing.
213
+
The Infrahub Python SDK supports **range expansion** for string fields in object files when the `strategy` is set to `range_expand`. This feature allows you to specify a range pattern (e.g., `[1-5]`) in any string value, and the SDK will automatically expand it into multiple objects during validation and processing.
214
+
215
+
```yaml
216
+
---
217
+
apiVersion: infrahub.app/v1
218
+
kind: Object
219
+
spec:
220
+
kind: BuiltinLocation
221
+
strategy: range_expand # Enable range expansion
222
+
data:
223
+
- name: AMS[1-3]
224
+
type: Country
225
+
```
202
226
203
227
### How Range Expansion Works
204
228
@@ -213,6 +237,7 @@ The Infrahub Python SDK supports **range expansion** for string fields in object
213
237
```yaml
214
238
spec:
215
239
kind: BuiltinLocation
240
+
strategy: range_expand
216
241
data:
217
242
- name: AMS[1-3]
218
243
type: Country
@@ -234,6 +259,7 @@ This will expand to:
234
259
```yaml
235
260
spec:
236
261
kind: BuiltinLocation
262
+
strategy: range_expand
237
263
data:
238
264
- name: AMS[1-3]
239
265
description: Datacenter [A-C]
@@ -261,6 +287,7 @@ If you use ranges of different lengths in multiple fields:
0 commit comments