Skip to content

Commit f797900

Browse files
Add section to show how to access files stored in the Git repository when using a Python transform. (#6892)
1 parent 7ba24b6 commit f797900

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/docs/topics/transformation.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ A TransformPython must be written as a Python class that inherits from `Infrahub
7575

7676
Please refer to the guide [Creating a Python transform](../guides/python-transform) for more information.
7777

78+
##### Python transform accessing local files
79+
80+
There may be times that you want to access files that are stored within the Git repository such as Jinja2 templates.
81+
82+
This can be accomplished by using the `self.root_directory` that points to the root of the Git repository.
83+
84+
```python
85+
async def transform(self, data):
86+
templates_path = f"{self.root_directory}/templates"
87+
```
88+
7889
#### Render a TransformPython
7990

8091
A TransformPython can be rendered with 2 different methods:

0 commit comments

Comments
 (0)