fix: translation + tests
This commit is contained in:
parent
8224b8929f
commit
70efb3d8ad
90 changed files with 311 additions and 8 deletions
|
|
@ -22,24 +22,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
from .i18n import _
|
||||||
|
|
||||||
|
|
||||||
def get_rougail_config(
|
def get_rougail_config(
|
||||||
*,
|
*,
|
||||||
backward_compatibility=True,
|
backward_compatibility=True,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
options = """
|
options = f"""
|
||||||
environment:
|
environment:
|
||||||
description: Define values from the environment
|
description: {_("Configuration loading environment variables")}
|
||||||
disabled:
|
disabled:
|
||||||
jinja: |
|
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
|
disabled
|
||||||
{% endif %}
|
{{% endif %}}
|
||||||
|
|
||||||
default_environment_name:
|
default_environment_name:
|
||||||
description: Name of the default environment prefix
|
description: {_("Name of the default environment prefix")}
|
||||||
default: rougail
|
default: rougail
|
||||||
disabled:
|
disabled:
|
||||||
variable: main_namespace
|
variable: __.main_namespace
|
||||||
when_not: null
|
when_not: null
|
||||||
|
|
||||||
|
with_secrets:
|
||||||
|
description: {_("Environnement variables may contain secrets")}
|
||||||
|
default: true
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"name": "environment",
|
"name": "environment",
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ class RougailUserDataEnvironment:
|
||||||
self.rougailconfig = rougailconfig
|
self.rougailconfig = rougailconfig
|
||||||
if "environment" not in user_data:
|
if "environment" not in user_data:
|
||||||
raise ExtentionError("environment is not set in step.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.errors = []
|
||||||
self.warnings = []
|
self.warnings = []
|
||||||
|
|
||||||
|
|
@ -59,6 +63,7 @@ class RougailUserDataEnvironment:
|
||||||
"options": {
|
"options": {
|
||||||
"multi_separator": ",",
|
"multi_separator": ",",
|
||||||
"needs_convert": True,
|
"needs_convert": True,
|
||||||
|
"allow_secrets_variables": self.with_secrets,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
27
src/rougail/user_data_environment/i18n.py
Normal file
27
src/rougail/user_data_environment/i18n.py
Normal 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
|
||||||
|
|
||||||
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"errors": [],
|
"errors": [],
|
||||||
"warnings": [
|
"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"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"errors": [],
|
"errors": [],
|
||||||
"warnings": [
|
"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"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"condition\" (a condition) is hidden, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"condition": false,
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"condition": false,
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"condition": false,
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL_CONDITION="True"
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL_VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.condition\" (a condition) is hidden, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": false,
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": false,
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": false,
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.variable\" (a variable) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.condition": true
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": [
|
||||||
|
"variable \"rougail.condition\" (a condition) is disabled, it will be ignored when loading from environment variable"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errors": [],
|
||||||
|
"warnings": []
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ROUGAIL.CONDITION="True"
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
ROUGAIL.VARIABLE="string1"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"rougail.variable": "string1"
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue