Skip to content

Commit 48da073

Browse files
committed
Rename "content" default key to "base"
1 parent bb0e5c1 commit 48da073

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/plugins/files.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Due to the structure of the custom configuration filenames, the **‌files** plu
9797
Use the **netlab show defaults paths.custom.files** command to display the order of components _netlab_ expects you to use in the custom configuration template names. The `.j2` suffix is automatically appended to the names generated from the **‌configlets** dictionary.
9898
```
9999

100-
Finally, you might want to create a variant of a configuration template for a specific provider, and a more generic one for all other providers. That cannot be easily expressed as a dictionary structure, so the **files** plugin treats **content** key as a special case, meaning *do not append anything to the file name*. The following example will thus create **ifup/eos.j2** and **ifup/eos-clab.j2** files:
100+
Finally, you might want to create a variant of a configuration template for a specific provider, and a more generic one for all other providers. That cannot be easily expressed as a dictionary structure, so the **files** plugin treats **base** key as a special case, meaning *do not append anything to the file name*. The following example will thus create **ifup/eos.j2** and **ifup/eos-clab.j2** files:
101101

102102
```
103103
configlets:
@@ -106,7 +106,7 @@ configlets:
106106
clab: |
107107
interface Management0
108108
description Management interface
109-
content: |
109+
base: |
110110
interface Management1
111111
description Management interface
112112
```

netsim/extra/files/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def restructure_files(topology: Box) -> None:
1313
return # Everything else will be handled in attribute validation code
1414

1515
f_dict = filemaps.box_to_dict(topology.files) # Recover the original data structure
16-
f_list = [ {'path': k, 'content': v}
16+
f_list = [ {'path': k, 'content': v}
1717
for k,v in f_dict.items() ] # Create normalized list-based data structure
1818
topology.files = f_list # Replace dict with list
1919

@@ -26,7 +26,7 @@ def build_files(cfg: Box, path: str) -> None: # Recursively transform conf
2626
for k,v in cfg.items(): # Iterate over dictionary contents
2727
separator = '' if path.endswith('/') else \
2828
'-' if k in topology.defaults.providers else '.'
29-
if k != 'content': # If this is not a 'raw content' element
29+
if k != 'base': # If this is not a 'base content' element
3030
k_path = path + separator + k # ... add next bit to file name (provider is prefixed with '-')
3131
else:
3232
k_path = path

0 commit comments

Comments
 (0)