Skip to content

Commit

Permalink
Merge pull request #130 from epics-containers/dev
Browse files Browse the repository at this point in the history
allow jinja substitution in db template filenames
  • Loading branch information
gilesknap authored Nov 6, 2023
2 parents 35142e0 + 8383bdb commit b21cfa9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
]
description = "IOC Builder for EPICS and Kubernetes"
dependencies = [
"pydantic",
"pydantic==2.3.0",
"typer",
"ruamel.yaml",
"jinja2",
Expand Down
2 changes: 2 additions & 0 deletions src/ibek/render_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def add_row(self, filename: str, args: Dict[str, Any], entity: Entity) -> None:
Adding a new template file if it does not already exist.
Convert all arguments to strings.
"""
filename = render_with_utils(dict(entity), filename)

if filename not in self.render_templates:
# for new filenames create a new RenderDbTemplate entry
headings = [str(i) for i in list(args.keys())]
Expand Down
7 changes: 7 additions & 0 deletions tests/samples/outputs/all.ioc.subst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ pattern
{ "AllObject Two", "Ref1", "1.0", "True" }
}

file "jinjified1.db" {
pattern
{ "name" }
{ "AllObject One" }
{ "AllObject Two" }
}

file "test.db" {
pattern
{ "name", "ip", "value" }
Expand Down
11 changes: 1 addition & 10 deletions tests/samples/schemas/multiple.ibek.ioc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,7 @@
"entities": {
"description": "List of entities this IOC instantiates",
"items": {
"discriminator": {
"mapping": {
"module.AllObject": "#/$defs/module_AllObject",
"object_module.Consumer": "#/$defs/object_module_Consumer",
"object_module.ConsumerTwo": "#/$defs/object_module_ConsumerTwo",
"object_module.RefObject": "#/$defs/object_module_RefObject"
},
"propertyName": "type"
},
"oneOf": [
"anyOf": [
{
"$ref": "#/$defs/object_module_RefObject"
},
Expand Down
10 changes: 1 addition & 9 deletions tests/samples/schemas/objects.ibek.ioc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,7 @@
"entities": {
"description": "List of entities this IOC instantiates",
"items": {
"discriminator": {
"mapping": {
"object_module.Consumer": "#/$defs/object_module_Consumer",
"object_module.ConsumerTwo": "#/$defs/object_module_ConsumerTwo",
"object_module.RefObject": "#/$defs/object_module_RefObject"
},
"propertyName": "type"
},
"oneOf": [
"anyOf": [
{
"$ref": "#/$defs/object_module_RefObject"
},
Expand Down
9 changes: 1 addition & 8 deletions tests/samples/schemas/utils.ibek.ioc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@
"entities": {
"description": "List of entities this IOC instantiates",
"items": {
"discriminator": {
"mapping": {
"epics.InterruptVectorVME": "#/$defs/epics_InterruptVectorVME",
"epics.InterruptVectorVME2": "#/$defs/epics_InterruptVectorVME2"
},
"propertyName": "type"
},
"oneOf": [
"anyOf": [
{
"$ref": "#/$defs/epics_InterruptVectorVME"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/samples/yaml/all.ibek.support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ defs:
my_object:
my_float:
my_bool:
- file: jinjified{{ my_int }}.db
args:
name:

0 comments on commit b21cfa9

Please # to comment.