Compare commits

...

18 commits

Author SHA1 Message Date
b282fd2d7a bump: version 0.1.0a14 → 0.1.0a15 2025-11-21 07:59:29 +01:00
fb230276a8 fix: ExtentionError => ExtensionError 2025-11-21 07:59:17 +01:00
5d39620e39 bump: version 0.1.0a13 → 0.1.0a14 2025-11-06 06:23:42 +01:00
717fa7f367 fix: add translation 2025-11-05 21:37:23 +01:00
43bd217f32 fix: update tests 2025-11-05 21:36:41 +01:00
2fd6427742 bump: version 0.1.0a12 → 0.1.0a13 2025-10-29 11:17:13 +01:00
2f044ec999 feat: can define a new separator 2025-10-29 11:16:37 +01:00
6e4440683a bump: version 0.1.0a11 → 0.1.0a12 2025-10-10 08:11:15 +02:00
61d96ba6ce fix: update test 2025-10-10 08:01:45 +02:00
70efb3d8ad fix: translation + tests 2025-10-05 21:25:12 +02:00
8224b8929f fix: tests for formatter 2025-09-30 21:50:42 +02:00
4061e96511 bump: version 0.1.0a10 → 0.1.0a11 2025-09-29 11:01:41 +02:00
bccea20ded feat: default value for a calculated variable with an unknown optional variable 2025-09-28 15:46:40 +02:00
9e9de6a1de feat: update tests for integer type 2025-09-24 08:52:07 +02:00
29b96dc712 bump: version 0.1.0a9 → 0.1.0a10 2025-09-22 14:18:50 +02:00
d03c084b60 fix: dictionary => structure 2025-09-22 14:18:35 +02:00
3d9f9b3fb4 bump: version 0.1.0a8 → 0.1.0a9 2025-06-18 07:57:12 +03:00
a9ce48d03a fix: rougail separation 2025-06-18 07:38:04 +03:00
1021 changed files with 2659 additions and 902 deletions

View file

@ -1,3 +1,49 @@
## 0.1.0a15 (2025-11-21)
### Fix
- ExtentionError => ExtensionError
## 0.1.0a14 (2025-11-06)
### Fix
- add translation
- update tests
## 0.1.0a13 (2025-10-29)
### Feat
- can define a new separator
## 0.1.0a12 (2025-10-10)
### Fix
- update test
- translation + tests
- tests for formatter
## 0.1.0a11 (2025-09-29)
### Feat
- default value for a calculated variable with an unknown optional variable
- update tests for integer type
## 0.1.0a10 (2025-09-22)
### Fix
- dictionary => structure
## 0.1.0a9 (2025-06-18)
### Fix
- rougail separation
## 0.1.0a8 (2025-05-12)
### Feat

View file

@ -0,0 +1,48 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2025-10-04 17:04+0200\n"
"PO-Revision-Date: 2025-10-04 17:04+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.7\n"
#: src/rougail/user_data_environment/annotator.py:46
msgid ""
"family name must be a lowercase name when we want to use user data "
"\"environment\", so \"{0}\" is invalid"
msgstr ""
"le nom d'une famille doit être un nom en minuscule lorsque vous voulez "
"utiliser de données utilisateur \"environment\", donc \"{0}\" est invalide"
#: src/rougail/user_data_environment/annotator.py:56
msgid ""
"variable name must be a lowercase name when we want to use user data "
"\"environment\", so \"{0}\" is invalid"
msgstr ""
"le nom d'une variable doit être un nom en minuscule lorsque vous voulez "
"utiliser de données utilisateur \"environment\", donc \"{0}\" est invalide"
#: src/rougail/user_data_environment/config.py:34
msgid "Configuration loading environment variables"
msgstr "Configuration le chargement des variables d'environnements"
#: src/rougail/user_data_environment/config.py:42
msgid "Name of the default environment prefix"
msgstr "Nom du préfix d'environnement par défaut"
#: src/rougail/user_data_environment/config.py:49
msgid "Environnement variables may contain secrets"
msgstr "Les variables d'environnement peuvent contenir des secrets"
#~ msgid "Define values from the environment"
#~ msgstr "Défini les valeurs pour l'environnemnt"

View file

@ -0,0 +1,37 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-10-04 17:05+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: src/rougail/user_data_environment/annotator.py:46
msgid "family name must be a lowercase name when we want to use user data \"environment\", so \"{0}\" is invalid"
msgstr ""
#: src/rougail/user_data_environment/annotator.py:56
msgid "variable name must be a lowercase name when we want to use user data \"environment\", so \"{0}\" is invalid"
msgstr ""
#: src/rougail/user_data_environment/config.py:34
msgid "Configuration loading environment variables"
msgstr ""
#: src/rougail/user_data_environment/config.py:42
msgid "Name of the default environment prefix"
msgstr ""
#: src/rougail/user_data_environment/config.py:49
msgid "Environnement variables may contain secrets"
msgstr ""

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.user_data_environment"
version = "0.1.0a8"
version = "0.1.0a15"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "Rougail user_data environment"
@ -13,9 +13,6 @@ license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",

View file

@ -1 +1 @@
__version__ = "0.1.0a8"
__version__ = "0.1.0a15"

View file

@ -22,24 +22,42 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from .i18n import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = """
options = f"""
environment:
description: Define values from the environment
description: {_("Configuration loading environment variables")}
disabled:
jinja: |
{% if step.user_data is propertyerror or 'environment' not in step.user_data %}
{{% if _.step.user_data is propertyerror or 'environment' not in _.step.user_data %}}
disabled
{% endif %}
{{% endif %}}
default_environment_name:
description: Name of the default environment prefix
default: rougail
description: {_("Name of the default environment prefix")}
default: ROUGAIL
validators:
- jinja: |-
{{% if _.default_environment_name | upper != _.default_environment_name %}}
{_("should only user uppercase character")}
{{% endif %}}
disabled:
variable: main_namespace
variable: __.main_namespace
when_not: null
custom_separator:
description: {_('Replace the separator character "." in path by an other')}
help: {_('The "." character could be not allowed in path name')}
mandatory: false
with_secrets:
description: {_("Environnement variables may contain secrets")}
default: true
"""
return {
"name": "environment",

View file

@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
import os
from rougail.object_model import CONVERT_OPTION
from rougail.tiramisu import CONVERT_OPTION
from rougail.config import RougailConfig
from rougail.error import ExtentionError
from rougail.error import ExtensionError
from tiramisu.error import ValueOptionError
@ -42,9 +42,15 @@ class RougailUserDataEnvironment:
user_data.append("environment")
rougailconfig["step.user_data"] = user_data
user_data = rougailconfig["step.user_data"]
self.rougailconfig = rougailconfig
if "environment" not in user_data:
raise ExtentionError("environment is not set in step.user_data")
raise ExtensionError("environment is not set in step.user_data")
if "environment.with_secrets" in rougailconfig:
self.with_secrets = rougailconfig["environment.with_secrets"]
else:
self.with_secrets = True
self.custom_separator = rougailconfig["environment.custom_separator"]
if not rougailconfig["main_namespace"]:
self.default_environment_name = rougailconfig["environment.default_environment_name"]
self.errors = []
self.warnings = []
@ -59,39 +65,43 @@ class RougailUserDataEnvironment:
"options": {
"multi_separator": ",",
"needs_convert": True,
"allow_secrets_variables": self.with_secrets,
},
}
]
def parse(self):
variables = {}
self.prefixes = []
for option in self.config:
if not option.isoptiondescription() or option.group_type() != "namespace":
break
variables.update(get_rougail_environment(option.name()))
self.prefixes.append(option.name().upper() + ".")
else:
return variables
return get_rougail_environment(
None, self.rougailconfig["environment.default_environment_name"]
)
return self.get_rougail_environment(0)
# no namespace then we filter the ROUGAIL_ environment variables
self.prefixes = [self.default_environment_name + "_"]
return self.get_rougail_environment(len(self.prefixes[0]))
def get_rougail_environment(self, len_env):
"""gets all the rougail environment variables and their values
def get_rougail_environment(namespace, environment_name=None):
"""gets all the rougail environment variables and their values
:sample: {'VARINT': '5', 'VARNAME34': '58, 22', 'VARNAME2': 'tata',
'VARNAME1': 'titi', 'MYFAMILY.VARNAME3': 'spam'}
:returns: rougail environment variables as a key/value dict
"""
return {
envvar[len_env:].lower(): envval
for envvar, envval in self.get_correct_envs()
}
:sample: {'VARINT': '5', 'VARNAME34': '58, 22', 'VARNAME2': 'tata',
'VARNAME1': 'titi', 'MYFAMILY.VARNAME3': 'spam'}
:returns: rougail environment variables as a key/value dict
"""
# then we filter the ROUGAIL_ environment variables
if namespace is None:
rougail_environment_var = environment_name.upper() + "_"
len_env = len(rougail_environment_var)
else:
rougail_environment_var = namespace.upper() + "."
len_env = 0
return {
envvar[len_env:].lower(): envval
for envvar, envval in os.environ.items()
if envvar.startswith(rougail_environment_var)
}
def get_correct_envs(self):
for envvar, envval in os.environ.items():
if self.custom_separator:
envvar = envvar.replace(self.custom_separator, '.')
for prefix in self.prefixes:
if envvar.startswith(prefix):
yield envvar, envval
for prefix in self.prefixes:
if envvar.startswith(prefix):
yield envvar, envval

View file

@ -0,0 +1,27 @@
"""Internationalisation utilities
Silique (https://www.silique.fr)
Copyright (C) 2025
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from gettext import translation
from pathlib import Path
t = translation(
"rougail_user_data_environment", str(Path(__file__).parent / "locale"), fallback=True
)
_ = t.gettext

View file

@ -1,6 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"test\" is invalid for \"variable_int\", which is not an integer, it will be ignored when loading from environment variable"
"the value \"test\" is an invalid integer for \"variable_int\", which is not an integer, it will be ignored when loading from environment variable"
]
}

View file

@ -1,6 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"**********\" is invalid for \"secret\", at least 10 characters are required, it will be ignored when loading from environment variable"
"the value \"**********\" is an invalid password for \"secret\", at least 10 characters are required, it will be ignored when loading from environment variable"
]
}

View file

@ -1,3 +1,3 @@
ROUGAIL_LEADERSHIP.VAR1="string1,string2,string3"
ROUGAIL_LEADERSHIP.VAR2="string1,,"
ROUGAIL_LEADERSHIPoVAR2="string1,,"
ROUGAIL_VAR2="string1"

View file

@ -1,3 +1,3 @@
ROUGAIL_LEADERSHIP.VAR1="string1,string2,string3"
ROUGAIL_LEADERSHIP.VAR2="string1,,"
ROUGAIL_LEADERSHIPoVAR2="string1,,"
ROUGAIL_VAR2="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_VAR1="domain1.lan,domain2.lan"
ROUGAIL_VAR2="domain1.lan,domain2.lan"

View file

@ -0,0 +1,2 @@
ROUGAIL_VAR1="domain1.lan,domain2.lan"
ROUGAIL_VAR2="domain1.lan,domain2.lan"

View file

@ -0,0 +1 @@
ROUGAIL_VAR1="domain1.lan,domain2.lan"

View file

@ -0,0 +1,10 @@
{
"var1": [
"domain1.lan",
"domain2.lan"
],
"var2": [
"domain1.lan",
"domain2.lan"
]
}

View file

@ -0,0 +1,10 @@
{
"var1": [
"domain1.lan",
"domain2.lan"
],
"var2": [
"domain1.lan",
"domain2.lan"
]
}

View file

@ -0,0 +1,3 @@
ROUGAIL_VAR1="string1"
ROUGAIL_VAR2="string1"
ROUGAIL_VAR3="string1"

View file

@ -0,0 +1,3 @@
ROUGAIL_VAR1="string1"
ROUGAIL_VAR2="string1"
ROUGAIL_VAR3="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_VAR1="string1"
ROUGAIL_VAR3="string1"

View file

@ -0,0 +1,5 @@
{
"var1": "string1",
"var2": "string1",
"var3": "string1"
}

View file

@ -0,0 +1,5 @@
{
"var1": "string1",
"var2": "string1",
"var3": "string1"
}

View file

@ -0,0 +1,6 @@
ROUGAIL_VAR1="1"
ROUGAIL_VAR2="1"
ROUGAIL_VAR3="1"
ROUGAIL_VAR4="1"
ROUGAIL_VAR5="1"
ROUGAIL_VAR6="1"

View file

@ -0,0 +1,6 @@
ROUGAIL_VAR1="1"
ROUGAIL_VAR2="1"
ROUGAIL_VAR3="1"
ROUGAIL_VAR4="1"
ROUGAIL_VAR5="1"
ROUGAIL_VAR6="1"

View file

@ -0,0 +1,8 @@
{
"var1": 1,
"var2": 1,
"var3": 1,
"var4": 1,
"var5": 1,
"var6": 1
}

View file

@ -0,0 +1,8 @@
{
"var1": 0,
"var2": 0,
"var3": 0,
"var4": 10,
"var5": 10,
"var6": 10
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,3 @@
ROUGAIL_VAR1="192.168.1.6"
ROUGAIL_VAR2="192.168.1.6/24"
ROUGAIL_VAR3="192.168.1.6/24"

View file

@ -0,0 +1,3 @@
ROUGAIL_VAR1="192.168.1.6"
ROUGAIL_VAR2="192.168.1.6/24"
ROUGAIL_VAR3="192.168.1.6/24"

View file

@ -0,0 +1,5 @@
{
"var1": "192.168.1.6",
"var2": "192.168.1.6/24",
"var3": "192.168.1.6/24"
}

View file

@ -0,0 +1,5 @@
{
"var1": "1.1.1.1",
"var2": "1.1.1.1/24",
"var3": "1.1.1.1/24"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,3 @@
ROUGAIL_VAR1="192.168.1.0"
ROUGAIL_VAR2="192.168.1.6/32"
ROUGAIL_VAR3="192.168.1.6/32"

View file

@ -0,0 +1,3 @@
ROUGAIL_VAR1="192.168.1.0"
ROUGAIL_VAR2="192.168.1.6/32"
ROUGAIL_VAR3="192.168.1.6/32"

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,5 @@
{
"var1": "192.168.1.0",
"var2": "192.168.1.6/32",
"var3": "192.168.1.6/32"
}

View file

@ -0,0 +1,5 @@
{
"var1": "1.1.1.0",
"var2": "1.1.1.0/24",
"var3": "1.1.1.0/24"
}

View file

@ -4,3 +4,5 @@ ROUGAIL_VAR3="string1"
ROUGAIL_VAR4="string1"
ROUGAIL_VAR5="string1"
ROUGAIL_VAR6="string1"
ROUGAIL_VAR7="string1"
ROUGAIL_VAR8="string1"

View file

@ -4,3 +4,5 @@ ROUGAIL_VAR3="string1"
ROUGAIL_VAR4="string1"
ROUGAIL_VAR5="string1"
ROUGAIL_VAR6="string1"
ROUGAIL_VAR7="string1"
ROUGAIL_VAR8="string1"

View file

@ -4,5 +4,7 @@
"var3": "string1",
"var4": "string1",
"var5": "string1",
"var6": "string1"
"var6": "string1",
"var7": "string1",
"var8": "string1"
}

View file

@ -4,5 +4,7 @@
"var3": "string1",
"var4": "value",
"var5": "value",
"var6": "value"
"var6": "value",
"var7": "8080",
"var8": "true"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,2 @@
ROUGAIL_MY_VARIABLE="string1"
ROUGAIL_MY_CALCULATED_VARIABLE="string1,string2,string3"

View file

@ -0,0 +1,2 @@
ROUGAIL_MY_VARIABLE="string1"
ROUGAIL_MY_CALCULATED_VARIABLE="string1,string2,string3"

View file

@ -0,0 +1,8 @@
{
"my_variable": "string1",
"my_calculated_variable": [
"string1",
"string2",
"string3"
]
}

View file

@ -0,0 +1,7 @@
{
"my_variable": "val1",
"my_calculated_variable": [
"val1",
"value"
]
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1 @@
ROUGAIL_VAR="0"

View file

@ -0,0 +1 @@
ROUGAIL_VAR="0"

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,3 @@
{
"var": 0
}

View file

@ -0,0 +1,3 @@
{
"var": 9
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1 @@
ROUGAIL_VAR="1,2,3"

View file

@ -0,0 +1 @@
ROUGAIL_VAR="1,2,3"

View file

@ -0,0 +1 @@
ROUGAIL_VAR="1,2,3"

View file

@ -0,0 +1,7 @@
{
"var": [
1,
2,
3
]
}

View file

@ -0,0 +1,7 @@
{
"var": [
1,
2,
3
]
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1 @@
ROUGAIL_VARIABLE="a"

View file

@ -0,0 +1 @@
ROUGAIL_VARIABLE="a"

View file

@ -0,0 +1,3 @@
{
"variable": "a"
}

View file

@ -0,0 +1,3 @@
{
"variable": "c"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,2 @@
ROUGAIL_VAR1="string1"
ROUGAIL_VAR2="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_VAR1="string1"
ROUGAIL_VAR2="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_VAR1="string1"
ROUGAIL_VAR2="string1"

View file

@ -0,0 +1,4 @@
{
"var1": "string1",
"var2": "string1"
}

View file

@ -0,0 +1,4 @@
{
"var1": "string1",
"var2": "string1"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1 @@
ROUGAIL_INT="1"

View file

@ -0,0 +1 @@
ROUGAIL_INT="1"

View file

@ -0,0 +1,3 @@
{
"int": 1
}

Some files were not shown because too many files have changed in this diff Show more