fix: translation + tests

This commit is contained in:
egarette@silique.fr 2025-10-05 21:25:12 +02:00
parent 8224b8929f
commit 70efb3d8ad
90 changed files with 311 additions and 8 deletions

View file

@ -22,24 +22,32 @@ 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
description: {_("Name of the default environment prefix")}
default: rougail
disabled:
variable: main_namespace
variable: __.main_namespace
when_not: null
with_secrets:
description: {_("Environnement variables may contain secrets")}
default: true
"""
return {
"name": "environment",

View file

@ -45,6 +45,10 @@ class RougailUserDataEnvironment:
self.rougailconfig = rougailconfig
if "environment" not in user_data:
raise ExtentionError("environment is not set in step.user_data")
if "environment.with_secrets" in self.rougailconfig:
self.with_secrets = self.rougailconfig["environment.with_secrets"]
else:
self.with_secrets = True
self.errors = []
self.warnings = []
@ -59,6 +63,7 @@ class RougailUserDataEnvironment:
"options": {
"multi_separator": ",",
"needs_convert": True,
"allow_secrets_variables": self.with_secrets,
},
}
]

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

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

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

View file

@ -0,0 +1,3 @@
{
"condition": true
}

View file

@ -0,0 +1,3 @@
{
"condition": true
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"condition\" (a condition) is hidden, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

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

View file

@ -0,0 +1,4 @@
{
"condition": false,
"variable": "string1"
}

View file

@ -0,0 +1,4 @@
{
"condition": false,
"variable": "string1"
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

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

View file

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

View file

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

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

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

View file

@ -0,0 +1,3 @@
{
"condition": true
}

View file

@ -0,0 +1,4 @@
{
"condition": false,
"variable": "string1"
}

View file

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

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

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

View file

@ -0,0 +1,3 @@
{
"condition": true
}

View file

@ -0,0 +1,3 @@
{
"condition": true
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL_CONDITION="True"
ROUGAIL_VARIABLE="string1"

View file

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

View file

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

View file

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

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1 @@
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,3 @@
{
"rougail.condition": true
}

View file

@ -0,0 +1,3 @@
{
"rougail.condition": true
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.condition\" (a condition) is hidden, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1 @@
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,4 @@
{
"rougail.condition": false,
"rougail.variable": "string1"
}

View file

@ -0,0 +1,4 @@
{
"rougail.condition": false,
"rougail.variable": "string1"
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1 @@
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,3 @@
{
"rougail.variable": "string1"
}

View file

@ -0,0 +1,3 @@
{
"rougail.variable": "string1"
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1 @@
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,3 @@
{
"rougail.condition": true
}

View file

@ -0,0 +1,4 @@
{
"rougail.condition": false,
"rougail.variable": "string1"
}

View file

@ -0,0 +1,7 @@
{
"errors": [],
"warnings": [
"variable \"rougail.condition\" (a condition) is hidden, it will be ignored when loading from environment variable",
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1 @@
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,3 @@
{
"rougail.condition": true
}

View file

@ -0,0 +1,3 @@
{
"rougail.condition": true
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,2 @@
ROUGAIL.CONDITION="True"
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1 @@
ROUGAIL.VARIABLE="string1"

View file

@ -0,0 +1,3 @@
{
"rougail.variable": "string1"
}

View file

@ -0,0 +1,3 @@
{
"rougail.variable": "string1"
}