Skip to content

Commit cf8f980

Browse files
authored
Refactor configuration structure from 'structure' to 'files' (#42)
Update configuration files to prioritize the 'structure' key over 'files', enhancing clarity and consistency in the configuration format.
1 parent aaff50e commit cf8f980

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+85
-53
lines changed

README.es.md

Lines changed: 4 additions & 4 deletions

README.md

Lines changed: 4 additions & 4 deletions

example/structure.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
structure:
1+
files:
22
- README.md:
33
skip: true
44
content: |

struct-schema.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
2+
"$schema": "https://json-schema.org/draft-07/schema",
33
"type": "object",
44
"properties": {
55
"structure": {
@@ -21,6 +21,36 @@
2121
}
2222
}
2323
},
24+
"files": {
25+
"type": "array",
26+
"items": {
27+
"type": "object",
28+
"patternProperties": {
29+
".*": {
30+
"type": "object",
31+
"properties": {
32+
"skip": {
33+
"type": "boolean"
34+
},
35+
"skip_if_exists": {
36+
"type": "boolean"
37+
},
38+
"content": {
39+
"type": "string"
40+
},
41+
"permissions": {
42+
"type": "string"
43+
},
44+
"file": {
45+
"type": "string",
46+
"format": "uri"
47+
}
48+
},
49+
"additionalProperties": false
50+
}
51+
}
52+
}
53+
},
2454
"folders": {
2555
"type": "array",
2656
"items": {

struct_module/commands/generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _create_structure(self, args):
6363
config = yaml.safe_load(f)
6464

6565
template_vars = dict(item.split('=') for item in args.vars.split(',')) if args.vars else None
66-
config_structure = config.get('structure', [])
66+
config_structure = config.get('files', config.get('structure', []))
6767
config_folders = config.get('folders', [])
6868
config_variables = config.get('variables', [])
6969

struct_module/commands/info.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def _get_info(self, args):
3838
print(f" 📌 Name: {args.structure_definition}\n")
3939
print(f" 📌 Description: {config.get('description', 'No description')}\n")
4040

41-
if config.get('structure'):
42-
print(f" 📌 Structure:")
43-
for item in config.get('structure', []):
41+
if config.get('files'):
42+
print(f" 📌 Files:")
43+
for item in config.get('files', []):
4444
for name, content in item.items():
4545
print(f" - {name} ")
4646
# indent all lines of content

struct_module/commands/validate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def execute(self, args):
1818
with open(args.yaml_file, 'r') as f:
1919
config = yaml.safe_load(f)
2020

21-
self._validate_structure_config(config.get('structure', []))
21+
if 'structure' in config and 'files' in config:
22+
self.logger.warning("Both 'structure' and 'files' keys exist. Prioritizing 'structure'.")
23+
self._validate_structure_config(config.get('structure') or config.get('files', []))
2224
self._validate_folders_config(config.get('folders', []))
2325
self._validate_variables_config(config.get('variables', []))
2426

struct_module/contribs/ansible-playbook.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
structure:
1+
files:
22
- main.yml:
33
content: |
44
- name: Example Playbook

struct_module/contribs/chef-cookbook.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
structure:
1+
files:
22
- recipes/default.rb:
33
content: |
44
package 'nginx' do

struct_module/contribs/ci-cd-pipelines.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
structure:
1+
files:
22
- .gitlab-ci.yml:
33
content: |
44
stages:

0 commit comments

Comments
 (0)