Skip to content

Commit

Permalink
Merge pull request #42 from opsmill/pmc-20250204-docs
Browse files Browse the repository at this point in the history
cleanup linting errors
  • Loading branch information
BeArchiTek authored Feb 5, 2025
2 parents c651a6d + 427318a commit 3290c85
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ jobs:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
Expand Down
12 changes: 4 additions & 8 deletions docs/_templates/plugin.mdx.j2
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
---
title: {{ module }}
---

# {{ module }}

{% for function_name, documentation in functions.items() %}

## {{ function_name }}
## `{{ function_name }}`

{{ documentation.description }}

{%- if documentation.params is defined %}

### Parameters

| Parameter | Type | Required | Default | Description |
Expand All @@ -20,15 +17,14 @@ title: {{ module }}
{%- endfor %}
{%- endif %}


### Examples

{%- if documentation.examples is defined and documentation.examples %}
{%- for example in documentation.examples %}
#### {{ example.description.split("\n", 1)[0] }}

#### {{ example.description.split("\n", 1)[0] }}
{{ example.description.split("\n", 1)[1] }}
{%- endfor %}
{% endfor %}
{%- else %}
No example provided.
{%- endif %}
Expand Down
24 changes: 10 additions & 14 deletions docs/docs/nornir/references/plugins/artifact_tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
title: Artifact management plugin
---

# Artifact management plugin



## regenerate_host_artifact
## `regenerate_host_artifact`

Regenerates a host artifact for a given task.

This function retrieves an artifact node associated with the given artifact name from the InfrahubNode,
then sends a request to regenerate the artifact using the Infrahub API.

### Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `task` | `Task` | Yes | | The task instance containing host-related data. |
| `artifact` | `str` | Yes | | The name of the artifact to regenerate. |


### Examples
#### Regenerate artifact for a given device.

#### Regenerate artifact for a given device

```python
from nornir import InitNornir
Expand All @@ -49,12 +45,13 @@ if __name__ == "__main__":
raise SystemExit(main())
```

## generate_artifacts
## `generate_artifacts`

Generates an artifact for a given task.

This function retrieves an artifact definition from the InfrahubNode and triggers
an API request to generate the specified artifact.

### Parameters

| Parameter | Type | Required | Default | Description |
Expand All @@ -63,10 +60,9 @@ an API request to generate the specified artifact.
| `artifact` | `str` | Yes | | The name of the artifact to generate. |
| `timeout` | `int` | No | 10 | The request timeout in seconds. Defaults to 10. |


### Examples
#### Example generating artifacts.

#### Example generating artifacts

```python
from nornir import InitNornir
Expand All @@ -92,24 +88,24 @@ if __name__ == "__main__":
raise SystemExit(main())
```

## get_artifact
## `get_artifact`

Retrieves the specified artifact from the Infrahub storage.

This function fetches an artifact node associated with the given artifact name and
sends a request to retrieve its stored content. The response is returned as JSON or text,
depending on the artifact's content type.

### Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `task` | `Task` | Yes | | The task instance containing host-related data. |
| `artifact` | `str` | Yes | | The name of the artifact to retrieve. |


### Examples
#### Example getting artifacts from Infrahub:

#### Example getting artifacts from Infrahub

```python
from nornir import InitNornir
Expand All @@ -133,4 +129,4 @@ def main():

if __name__ == "__main__":
raise SystemExit(main())
```
```
12 changes: 4 additions & 8 deletions docs/docs/nornir/references/plugins/infrahub_inventory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
title: Inventory plugin
---

# Inventory plugin



## InfrahubInventory
## `InfrahubInventory`

Nornir inventory plugin for integrating with `Opsmill - Infrahub`
(https://github.com/opsmill/infrahub).

This plugin fetches inventory data from Infrahub, maps it to Nornir Hosts,
and supports the creation of Nornir groups based on attributes or relations
from Infrahub Nodes.

### Parameters

| Parameter | Type | Required | Default | Description |
Expand All @@ -26,10 +23,9 @@ from Infrahub Nodes.
| `defaults_file` | `str` | No | "defaults.yaml" | Path to the defaults YAML file. Defaults to "defaults.yaml". |
| `group_file` | `str` | No | "group.yaml" | Path to the group YAML file. Defaults to "group.yaml". |


### Examples
#### Basic usage of `InfrahubInventory` with Nornir.

#### Basic usage of `InfrahubInventory` with Nornir.

```python
from nornir import InitNornir
Expand Down Expand Up @@ -66,4 +62,4 @@ def main():

if __name__ == "__main__":
raise SystemExit(main())
```
```
1 change: 1 addition & 0 deletions nornir_infrahub/plugins/inventory/infrahub.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def main():
if __name__ == "__main__":
raise SystemExit(main())
```
""" # noqa E501

def __init__( # noqa: PLR0913
Expand Down
6 changes: 3 additions & 3 deletions nornir_infrahub/plugins/tasks/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def regenerate_host_artifact(task: Task, artifact: str) -> Result:
httpx.HTTPStatusError: If the API request fails.
Example:
Regenerate artifact for a given device.
Regenerate artifact for a given device
```python
from nornir import InitNornir
Expand Down Expand Up @@ -87,7 +87,7 @@ def generate_artifacts(task: Task, artifact: str, timeout: int = 10) -> Result:
httpx.HTTPStatusError: If the API request fails.
Example:
Example generating artifacts.
Example generating artifacts
```python
from nornir import InitNornir
Expand Down Expand Up @@ -146,7 +146,7 @@ def get_artifact(task: Task, artifact: str) -> Result:
httpx.HTTPStatusError: If the API request fails.
Example:
Example getting artifacts from Infrahub:
Example getting artifacts from Infrahub
```python
from nornir import InitNornir
Expand Down
Loading

0 comments on commit 3290c85

Please sign in to comment.