Compare commits
5 commits
99a41bd4e5
...
88f837aa07
| Author | SHA1 | Date | |
|---|---|---|---|
| 88f837aa07 | |||
| 03d24af05c | |||
| 2adef78db3 | |||
| 9159f44efa | |||
| 75fc04c501 |
17 changed files with 169 additions and 28 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -1,3 +1,15 @@
|
||||||
|
## 0.1.0a3 (2025-03-27)
|
||||||
|
|
||||||
|
### Feat
|
||||||
|
|
||||||
|
- add secret_manager support
|
||||||
|
- add Namespace(Param|Calculation) support
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- do not add namespace in param
|
||||||
|
- an empty variable is []
|
||||||
|
|
||||||
## 0.1.0a2 (2025-03-26)
|
## 0.1.0a2 (2025-03-26)
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.output_formatter"
|
name = "rougail.output_formatter"
|
||||||
version = "0.1.0a2"
|
version = "0.1.0a3"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "Rougail output formatter"
|
description = "Rougail output formatter"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ from tiramisu import undefined
|
||||||
from tiramisu.config import get_common_path
|
from tiramisu.config import get_common_path
|
||||||
|
|
||||||
from rougail.convert import RougailConvert
|
from rougail.convert import RougailConvert
|
||||||
from rougail.object_model import Variable, Family, Calculation, JinjaCalculation, IdentifierCalculation, IdentifierPropertyCalculation, IdentifierParam, IndexCalculation, IndexParam, Param
|
from rougail.object_model import Variable, Family, Calculation, JinjaCalculation, IdentifierCalculation, IdentifierPropertyCalculation, NamespaceCalculation, IdentifierParam, IndexCalculation, IndexParam, NamespaceParam, Param
|
||||||
from rougail.utils import normalize_family
|
from rougail.utils import normalize_family
|
||||||
|
|
||||||
from .upgrade import RougailUpgrade
|
from .upgrade import RougailUpgrade
|
||||||
|
|
@ -240,6 +240,9 @@ class RougailOutputFormatter:
|
||||||
# if boolean, the default value is True
|
# if boolean, the default value is True
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
variable["default"] = True
|
variable["default"] = True
|
||||||
|
if "default" not in variable and variable.get("multi") is True and not set(variable) - {'default', 'description', "multi"}:
|
||||||
|
variable["default"] = []
|
||||||
|
del(variable['multi'])
|
||||||
if not isinstance(variable.get("default"), dict) and not set(variable) - {'default', 'description'}:
|
if not isinstance(variable.get("default"), dict) and not set(variable) - {'default', 'description'}:
|
||||||
# shorthand notation
|
# shorthand notation
|
||||||
default = variable.get('default')
|
default = variable.get('default')
|
||||||
|
|
@ -300,6 +303,8 @@ class RougailOutputFormatter:
|
||||||
if key == 'default' and not multi:
|
if key == 'default' and not multi:
|
||||||
jinja["jinja"] = FoldedScalarString(jinja_values.replace('\n', ' '))
|
jinja["jinja"] = FoldedScalarString(jinja_values.replace('\n', ' '))
|
||||||
jinja["jinja"].fold_pos = [i for i, ltr in enumerate(jinja_values) if ltr == '\n']
|
jinja["jinja"].fold_pos = [i for i, ltr in enumerate(jinja_values) if ltr == '\n']
|
||||||
|
elif key == 'secret_manager':
|
||||||
|
return self.object_to_yaml("params", type_, value.params, multi, object_path)
|
||||||
else:
|
else:
|
||||||
jinja["jinja"] = LiteralScalarString(jinja_values)
|
jinja["jinja"] = LiteralScalarString(jinja_values)
|
||||||
if value.return_type:
|
if value.return_type:
|
||||||
|
|
@ -314,8 +319,10 @@ class RougailOutputFormatter:
|
||||||
variable = CommentedMap()
|
variable = CommentedMap()
|
||||||
if isinstance(value, (IdentifierCalculation, IdentifierPropertyCalculation)):
|
if isinstance(value, (IdentifierCalculation, IdentifierPropertyCalculation)):
|
||||||
variable["type"] = "identifier"
|
variable["type"] = "identifier"
|
||||||
if isinstance(value, IndexCalculation):
|
elif isinstance(value, IndexCalculation):
|
||||||
variable["type"] = "index"
|
variable["type"] = "index"
|
||||||
|
elif isinstance(value, NamespaceCalculation):
|
||||||
|
variable["type"] = "namespace"
|
||||||
for key, default in variable_attributes.items():
|
for key, default in variable_attributes.items():
|
||||||
val = getattr(value, key)
|
val = getattr(value, key)
|
||||||
if val != default and val is not undefined:
|
if val != default and val is not undefined:
|
||||||
|
|
@ -326,15 +333,17 @@ class RougailOutputFormatter:
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
return variable
|
return variable
|
||||||
elif isinstance(value, Param):
|
elif isinstance(value, Param):
|
||||||
param_attributes = self.get_object_informations(value, ["type", "key"])
|
param_attributes = self.get_object_informations(value, ["type", "key", "namespace"])
|
||||||
if list(param_attributes) == ['value']:
|
if list(param_attributes) == ['value']:
|
||||||
variable = value.value
|
variable = value.value
|
||||||
else:
|
else:
|
||||||
variable = CommentedMap()
|
variable = CommentedMap()
|
||||||
if isinstance(value, IdentifierParam):
|
if isinstance(value, IdentifierParam):
|
||||||
variable["type"] = "identifier"
|
variable["type"] = "identifier"
|
||||||
if isinstance(value, IndexParam):
|
elif isinstance(value, IndexParam):
|
||||||
variable["type"] = "index"
|
variable["type"] = "index"
|
||||||
|
elif isinstance(value, NamespaceParam):
|
||||||
|
variable["type"] = "namespace"
|
||||||
for key, default in param_attributes.items():
|
for key, default in param_attributes.items():
|
||||||
val = getattr(value, key)
|
val = getattr(value, key)
|
||||||
if val != default and val is not undefined:
|
if val != default and val is not undefined:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
variable:
|
||||||
|
description: a variable
|
||||||
|
default:
|
||||||
|
type: namespace
|
||||||
|
mandatory: false
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
variable:
|
||||||
|
description: a variable
|
||||||
|
default:
|
||||||
|
jinja: >-
|
||||||
|
{{ namespace }}
|
||||||
|
params:
|
||||||
|
namespace:
|
||||||
|
type: namespace
|
||||||
|
mandatory: false
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
condition: [] # a condition
|
||||||
|
|
||||||
|
variable:
|
||||||
|
description: a variable
|
||||||
|
multi: true
|
||||||
|
disabled:
|
||||||
|
variable: _.condition
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
condition: # a condition
|
||||||
|
- val1
|
||||||
|
- val2
|
||||||
|
|
||||||
|
variable:
|
||||||
|
description: a variable
|
||||||
|
multi: true
|
||||||
|
disabled:
|
||||||
|
variable: _.condition
|
||||||
|
|
@ -5,10 +5,8 @@ leader:
|
||||||
description: a leadership
|
description: a leadership
|
||||||
type: leadership
|
type: leadership
|
||||||
|
|
||||||
leader:
|
leader: [] # the leader
|
||||||
description: the leader
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower1: # the follower1
|
follower1: # the follower1
|
||||||
|
|
||||||
follower2: # the follower2
|
follower2: # the follower2
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,9 @@ leadership:
|
||||||
description: A leadership
|
description: A leadership
|
||||||
type: leadership
|
type: leadership
|
||||||
|
|
||||||
leader:
|
leader: [] # The leader
|
||||||
description: The leader
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower1:
|
follower1: [] # The first follower
|
||||||
description: The first follower
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower2: # The second follower
|
follower2: # The second follower
|
||||||
- value
|
- value
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ leader:
|
||||||
description: a leadership
|
description: a leadership
|
||||||
type: leadership
|
type: leadership
|
||||||
|
|
||||||
leader:
|
leader: [] # a leader
|
||||||
description: a leader
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower1:
|
follower1:
|
||||||
description: a follower
|
description: a follower
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ leader:
|
||||||
description: a leadership
|
description: a leadership
|
||||||
type: leadership
|
type: leadership
|
||||||
|
|
||||||
leader:
|
leader: [] # a leader
|
||||||
description: a leader
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower:
|
follower:
|
||||||
description: a follower
|
description: a follower
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
var: # A suffix variable
|
||||||
|
- val.1
|
||||||
|
- val.2
|
||||||
|
|
||||||
|
dyn{{ identifier }}:
|
||||||
|
description: A dynamic family
|
||||||
|
dynamic:
|
||||||
|
variable: _.var
|
||||||
|
|
||||||
|
var1:
|
||||||
|
description: A dynamic variable
|
||||||
|
default:
|
||||||
|
type: identifier
|
||||||
|
|
||||||
|
var2:
|
||||||
|
description: A dynamic variable
|
||||||
|
default:
|
||||||
|
jinja: >-
|
||||||
|
{{ identifier }}
|
||||||
|
params:
|
||||||
|
identifier:
|
||||||
|
type: identifier
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
var1:
|
||||||
|
description: A suffix variable
|
||||||
|
test:
|
||||||
|
- val1
|
||||||
|
multi: true
|
||||||
|
mandatory: false
|
||||||
|
|
||||||
|
dyn{{ identifier }}:
|
||||||
|
dynamic:
|
||||||
|
variable: _.var1
|
||||||
|
|
||||||
|
var: # A dynamic variable
|
||||||
|
|
||||||
|
var2:
|
||||||
|
description: A variable calculated
|
||||||
|
default:
|
||||||
|
variable: _.dynval1.var
|
||||||
|
optional: true
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
var2:
|
||||||
|
description: A variable calculated
|
||||||
|
default:
|
||||||
|
variable: _.dynval1.var
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
var1:
|
||||||
|
description: A suffix variable
|
||||||
|
test:
|
||||||
|
- val1
|
||||||
|
- val2
|
||||||
|
multi: true
|
||||||
|
mandatory: false
|
||||||
|
|
||||||
|
dyn{{ identifier }}:
|
||||||
|
dynamic:
|
||||||
|
variable: _.var1
|
||||||
|
|
||||||
|
var: # A dynamic variable
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
version: 1.1
|
||||||
|
|
||||||
|
var: # a suffix variable
|
||||||
|
- val1
|
||||||
|
- val2
|
||||||
|
|
||||||
|
my_dyn_family_{{ identifier }}:
|
||||||
|
description: a dynamic family
|
||||||
|
dynamic:
|
||||||
|
variable: _.var
|
||||||
|
propertyerror: false
|
||||||
|
|
||||||
|
var:
|
||||||
|
description: a variable inside a dynamic family
|
||||||
|
default:
|
||||||
|
type: identifier
|
||||||
|
mandatory: false
|
||||||
|
|
||||||
|
var2:
|
||||||
|
description: a variable
|
||||||
|
multi: true
|
||||||
|
default:
|
||||||
|
variable: _.my_dyn_family_{{ identifier }}.var
|
||||||
|
|
@ -14,9 +14,7 @@ dyn{{ identifier }}:
|
||||||
description: a leadership
|
description: a leadership
|
||||||
type: leadership
|
type: leadership
|
||||||
|
|
||||||
leader:
|
leader: [] # a leader
|
||||||
description: a leader
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower1:
|
follower1:
|
||||||
description: a follower1
|
description: a follower1
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,7 @@ dyn{{ identifier }}:
|
||||||
description: a leadership
|
description: a leadership
|
||||||
type: leadership
|
type: leadership
|
||||||
|
|
||||||
leader:
|
leader: [] # a leader
|
||||||
description: a leader
|
|
||||||
multi: true
|
|
||||||
|
|
||||||
follower1:
|
follower1:
|
||||||
description: a follower1
|
description: a follower1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue