Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.es.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# 🚀 STRUCT: Generador Automático de Estructuras de Proyectos

[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/httpdss/struct/blob/master/README.md) [![es](https://img.shields.io/badge/lang-es-yellow.svg)](https://github.com/httpdss/struct/blob/master/README.es.md)
Expand Down Expand Up @@ -235,6 +234,22 @@ structure:
slugify project_name: {{@ project_name | slugify @}}
```

### Cláusula `with`

La cláusula `with` te permite pasar variables adicionales a estructuras anidadas. Estas variables se fusionarán con las variables globales y se pueden usar dentro de la estructura anidada.

Ejemplo:

```yaml
folders:
- .devops/modules/mod1:
struct: terraform-module
- .devops/modules/mod2:
struct: terraform-module
with:
module_name: mymod2
```

## 👩‍💻 Desarrollo

Para comenzar con el desarrollo, sigue estos pasos:
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@ structure:
slugify project_name: {{@ project_name | slugify @}}
```

### `with` Clause

The `with` clause allows you to pass additional variables to nested structures. These variables will be merged with the global variables and can be used within the nested structure.

Example:

```yaml
folders:
- .devops/modules/mod1:
struct: terraform-module
- .devops/modules/mod2:
struct: terraform-module
with:
module_name: mymod2
```

## 👩‍💻 Development

To get started with development, follow these steps:
Expand Down
2 changes: 2 additions & 0 deletions example/structure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ folders:
struct: terraform-module
- .devops/modules/mod2:
struct: terraform-module
with:
module_name: mymod2
- ./:
struct:
- docker-files
Expand Down
17 changes: 14 additions & 3 deletions struct_module/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,25 @@ def _create_structure(self, args):
# check if content has struct value
if 'struct' in content:
self.logger.info(f"Generating structure in folder: {folder} with struct {content['struct']}")
if isinstance(content['struct'], str):

# get vars from with param. this will be a dict of key value pairs
merged_vars = ""

# dict to comma separated string
if 'with' in content:
if isinstance(content['with'], dict):
merged_vars = ",".join([f"{k}={v}" for k, v in content['with'].items()])

if args.vars:
merged_vars = args.vars + "," + merged_vars

if isinstance(content['struct'], str):
self._create_structure({
'structure_definition': content['struct'],
'base_path': folder_path,
'structures_path': args.structures_path,
'dry_run': args.dry_run,
'vars': args.vars,
'vars': merged_vars,
'backup': args.backup,
'file_strategy': args.file_strategy,
'global_system_prompt': args.global_system_prompt,
Expand All @@ -121,7 +132,7 @@ def _create_structure(self, args):
'base_path': folder_path,
'structures_path': args.structures_path,
'dry_run': args.dry_run,
'vars': args.vars,
'vars': merged_vars,
'backup': args.backup,
'file_strategy': args.file_strategy,
'global_system_prompt': args.global_system_prompt,
Expand Down
Loading