Skip to content

Commit

Permalink
feat(filters): add get_suffix function to retrieve project name
Browse files Browse the repository at this point in the history
  • Loading branch information
guptadev21 committed Feb 12, 2025
1 parent 61329b3 commit 0ae8df9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion riocli/apply/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os
from typing import Dict, List

from riocli.config import new_client
from riocli.config import new_client, Configuration
from riocli.device.util import find_device_guid


Expand Down Expand Up @@ -85,3 +85,17 @@ def get_device_ip_interfaces(device_name: str) -> Dict[str, List[str]]:
device.refresh()

return device.ip_interfaces

def get_suffix(suffix: str) -> str:
"""Get the name of the project.
Usage:
"project_name" : {{ get_project_name() }}
Returns:
The name of the project.
"""
if suffix:
return suffix
config = Configuration()
return config.data.get("project_name")
3 changes: 2 additions & 1 deletion riocli/apply/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ansible.plugins.filter.mathstuff import FilterModule as MathFilterModule
from ansible.plugins.filter.encryption import FilterModule as EncryptionFilterModule

from riocli.apply.filters import get_interface_ip, getenv
from riocli.apply.filters import get_interface_ip, getenv, get_suffix
from riocli.constants import Colors
from riocli.deployment.model import Deployment
from riocli.device.model import Device
Expand Down Expand Up @@ -59,6 +59,7 @@
FILTERS = {
"getenv": getenv,
"get_intf_ip": get_interface_ip,
"get_suffix": get_suffix,
}


Expand Down

0 comments on commit 0ae8df9

Please sign in to comment.