Compare commits

..

No commits in common. "develop" and "0.1.0a1" have entirely different histories.

4059 changed files with 2721 additions and 11735 deletions

View file

@ -1,104 +1,3 @@
## 0.1.0a16 (2025-12-22)
### Fix
- add description for validators
## 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
- display loaded_from informations
### Fix
- black
## 0.1.0a7 (2025-05-02)
### Fix
- do not force use_data usage
## 0.1.0a6 (2025-04-30)
### Fix
- update tests
## 0.1.0a5 (2025-04-09)
### Fix
- version
## 0.1.0a4 (2025-04-01)
### Fix
- update tests
## 0.1.0a3 (2025-03-30)
### Fix
- update tests
- update tests, some errors are now in warnings level
## 0.1.0a2 (2025-02-10)
### Fix
- rename source
- add test without namespace
- update tests
## 0.1.0a1 (2024-11-27)
### Fix

View file

@ -1,48 +0,0 @@
# 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

@ -1,37 +0,0 @@
# 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.0a16"
version = "0.1.0a1"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "Rougail user_data environment"
@ -13,10 +13,11 @@ 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",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Natural Language :: English",
@ -35,9 +36,5 @@ name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "pep440"
version_provider = "pep621"
version_files = [
"src/rougail/user_data_environment/__version__.py",
"pyproject.toml:version"
]
update_changelog_on_bump = true
changelog_merge_prerelease = true

View file

@ -1,6 +1,3 @@
from .data import RougailUserDataEnvironment
from .__version__ import __version__
RougailUserData = RougailUserDataEnvironment
__all__ = ("RougailUserDataEnvironment",)
__all__ = ('RougailUserDataEnvironment',)

View file

@ -1 +0,0 @@
__version__ = "0.1.0a16"

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2025
Copyright (C) 2024
distribued with GPL-2 or later license
@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from rougail.error import DictConsistencyError
from rougail.annotator.variable import Walk
from .i18n import _
@ -26,9 +25,9 @@ from .i18n import _
class Annotator(Walk):
"""Annotate for environment"""
level = 95
def __init__(
self,
objectspace,
@ -43,19 +42,11 @@ class Annotator(Walk):
def check_family(self):
for family in self.get_families():
if family.name != family.name.lower():
msg = _(
'family name must be a lowercase name when we want to use user data "environment", so "{0}" is invalid'
)
raise DictConsistencyError(
msg.format(family.name), 200, family.xmlfiles
)
msg = _('family name must be a lowercase name when we want to use user data "environment", so "{0}" is invalid')
raise DictConsistencyError(msg.format(family.name), 200, family.xmlfiles)
def check_variable(self):
for variable in self.get_variables():
if variable.name != variable.name.lower():
msg = _(
'variable name must be a lowercase name when we want to use user data "environment", so "{0}" is invalid'
)
raise DictConsistencyError(
msg.format(variable.name), 201, variable.xmlfiles
)
msg = _('variable name must be a lowercase name when we want to use user data "environment", so "{0}" is invalid')
raise DictConsistencyError(msg.format(variable.name), 201, variable.xmlfiles)

View file

@ -2,7 +2,7 @@
Config file for Rougail-user-data-environment
Silique (https://www.silique.fr)
Copyright (C) 2024-2025
Copyright (C) 2024
distribued with GPL-2 or later license
@ -22,49 +22,31 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from .i18n import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = f"""
def get_rougail_config(*,
backward_compatibility=True,
) -> dict:
options = """
environment:
description: {_("Configuration loading environment variables")}
description: Define values from the environment
disabled:
jinja: |
{{% if _.step.user_data is propertyerror or 'environment' not in _.step.user_data %}}
{% if 'environment' not in step.user_data %}
disabled
{{% endif %}}
{% endif %}
default_environment_name:
description: {_("Name of the default environment prefix")}
default: ROUGAIL
validators:
- jinja: |-
{{{{ _.default_environment_name | upper != _.default_environment_name }}}}
return_type: boolean
description: {_("should only user uppercase character")}
description: Name of the default environment prefix
default:
variable: main_namespace
mandatory: true
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",
"process": "user data",
"options": options,
"level": 50,
}
return {'name': 'environment',
'process': 'user data',
'options': options,
'level': 50,
}
__all__ = ("get_rougail_config",)
__all__ = ('get_rougail_config',)

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2025
Copyright (C) 2024
distribued with GPL-2 or later license
@ -18,90 +18,68 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
import os
from rougail.tiramisu import CONVERT_OPTION
from rougail.object_model import CONVERT_OPTION
from rougail.config import RougailConfig
from rougail.error import ExtensionError
from tiramisu.error import ValueOptionError
class RougailUserDataEnvironment:
def __init__(
self,
config: "Config",
*,
rougailconfig: RougailConfig = None,
):
def __init__(self,
config: 'Config',
*,
rougailconfig: RougailConfig=None,
):
# this is the tiramisu config object
self.config = config
if rougailconfig is None:
rougailconfig = RougailConfig
user_data = rougailconfig["step.user_data"]
if "environment" not in user_data:
user_data.append("environment")
rougailconfig["step.user_data"] = user_data
user_data = rougailconfig["step.user_data"]
if "environment" not in 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"]
user_data = rougailconfig['step.user_data']
if 'environment' not in user_data:
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 Exception('environment is not set in step.user_data')
self.errors = []
self.warnings = []
def run(self):
values = self.parse()
return [
{
"source": "environment variable",
"errors": self.errors,
"warnings": self.warnings,
"values": values,
"options": {
"multi_separator": ",",
"needs_convert": True,
"allow_secrets_variables": self.with_secrets,
},
}
]
return [{'source': 'environment',
'errors': self.errors,
'warnings': self.warnings,
'values': values,
'options': {'multi_separator': ',',
'needs_convert': True,
},
}]
def parse(self):
variables = {}
self.prefixes = []
for option in self.config:
if not option.isoptiondescription() or option.group_type() != "namespace":
break
self.prefixes.append(option.name().upper() + ".")
variables.update(get_rougail_environment(option.name()))
else:
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]))
return variables
return get_rougail_environment(None, self.rougailconfig['environment.default_environment_name'])
def get_rougail_environment(self, len_env):
"""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()
}
def get_rougail_environment(namespace, environment_name=None):
"""gets all the rougail environment variables and their values
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
: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)}

View file

@ -1,27 +0,0 @@
"""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 +0,0 @@
ROUGAIL_UNKNOWN=1

View file

@ -1,2 +0,0 @@
ROUGAIL_FAMILY_DISABLED.VARIABLE1=test
ROUGAIL_FAMILY_DISABLED.VARIABLE2=test

View file

@ -1 +0,0 @@
ROUGAIL_VARIABLE_DISABLED=test

View file

@ -1 +0,0 @@
ROUGAIL_VARIABLE_INT=test

View file

@ -1 +0,0 @@
ROUGAIL_FAMILY_DISABLED_HIDDEN.VARIABLE1=test

View file

@ -1 +0,0 @@
ROUGAIL_SECRET=a

View file

@ -1 +0,0 @@
ROUGAIL_FAMILY=test

View file

@ -1 +0,0 @@
ROUGAIL_DYN_UNKNOWN.VARIABLE=test

View file

@ -1,4 +0,0 @@
ROUGAIL_LEADERSHIP.LEADER=test1,test2,test3
ROUGAIL_LEADERSHIP.FOLLOWER=test1,test2,test3
ROUGAIL_LEADERSHIP.FOLLOWER_DISABLED=test1,test2,test3
ROUGAIL_LEADERSHIP.FOLLOWER_DISABLED_AT_INDEX=test1,test2,test3

View file

@ -1,2 +0,0 @@
ROUGAIL_LEADERSHIP.LEADER=test
ROUGAIL_LEADERSHIP.UNKNWON=test

View file

@ -1,2 +0,0 @@
ROUGAIL_LEADERSHIP.LEADER=test
ROUGAIL_LEADERSHIP.FOLLOWER=test1,test2

View file

@ -1,6 +0,0 @@
{
"errors": [],
"warnings": [
"variable or family \"unknown\" does not exist, it will be ignored when loading from environment variable"
]
}

View file

@ -1,7 +0,0 @@
{
"errors": [],
"warnings": [
"family \"family_disabled\" is disabled, \"family_disabled.variable1\" will be ignored when loading from environment variable",
"family \"family_disabled\" is disabled, \"family_disabled.variable2\" will be ignored when loading from environment variable"
]
}

View file

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

View file

@ -1,6 +0,0 @@
{
"errors": [],
"warnings": [
"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 +0,0 @@
{
"errors": [],
"warnings": [
"family \"family_disabled_hidden\" is disabled and hidden, \"family_disabled_hidden.variable1\" will be ignored when loading from environment variable"
]
}

View file

@ -1,6 +0,0 @@
{
"errors": [],
"warnings": [
"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,6 +0,0 @@
{
"errors": [],
"warnings": [
"cannot set the value \"test\" to the family \"family\", it will be ignored when loading from environment variable"
]
}

View file

@ -1,6 +0,0 @@
{
"errors": [],
"warnings": [
"variable or family \"dyn_unknown\" does not exist, it will be ignored when loading from environment variable"
]
}

View file

@ -1,9 +0,0 @@
{
"errors": [],
"warnings": [
"variable \"leadership.follower_disabled\" at index \"0\" is disabled, it will be ignored when loading from environment variable",
"variable \"leadership.follower_disabled\" at index \"1\" is disabled, it will be ignored when loading from environment variable",
"variable \"leadership.follower_disabled\" at index \"2\" is disabled, it will be ignored when loading from environment variable",
"variable \"leadership.follower_disabled_at_index\" at index \"1\" is disabled, it will be ignored when loading from environment variable"
]
}

View file

@ -1,6 +0,0 @@
{
"errors": [],
"warnings": [
"variable or family \"leadership.unknwon\" does not exist, it will be ignored when loading from environment variable"
]
}

View file

@ -1,6 +0,0 @@
{
"errors": [],
"warnings": [
"index \"1\" is greater than the leadership length \"1\" for option \"leadership.follower\" in environment variable"
]
}

View file

@ -1,68 +0,0 @@
%YAML 1.2
---
version: 1.1
variable:
secret:
type: secret
params:
min_len: 10
variable_disabled:
disabled: true
variable_disabled_hidden:
disabled: true
hidden: true
variable_int:
type: number
family:
variable:
family_disabled:
disabled: true
variable1:
variable2:
family_disabled_hidden:
disabled: true
hidden: true
variable1:
variable2:
dyn_{{ identifier }}:
dynamic:
- var1
- var2
variable:
leadership:
type: leadership
leader:
follower:
follower_disabled:
disabled: true
follower_disabled_at_index:
disabled:
jinja: >-
{% if index == 1 %}
true
{% else %}
{% endif %}
params:
index:
type: index
...

View file

@ -0,0 +1,2 @@
ROUGAIL.VAR1="string1"
ROUGAIL.VAR2="string1,string2,string3"

View file

@ -0,0 +1,2 @@
ROUGAIL.VAR1="string1"
ROUGAIL.VAR2="string1,string2,string3"

View file

@ -0,0 +1,2 @@
ROUGAIL.VAR1="string1,string2,string3"
ROUGAIL.VAR2="string1,string2,string3"

View file

@ -0,0 +1,2 @@
ROUGAIL.VAR1="string1,string2,string3"
ROUGAIL.VAR2="string1,string2,string3"

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,3 @@
{
"rougail.var1": "string1"
}

View file

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

View file

@ -0,0 +1,6 @@
ROUGAIL.VAR1="True"
ROUGAIL.VAR2="True"
ROUGAIL.VAR3="True"
ROUGAIL.VAR4="True"
ROUGAIL.VAR5="True"
ROUGAIL.VAR6="True"

View file

@ -0,0 +1,6 @@
ROUGAIL.VAR1="True"
ROUGAIL.VAR2="True"
ROUGAIL.VAR3="True"
ROUGAIL.VAR4="True"
ROUGAIL.VAR5="True"
ROUGAIL.VAR6="True"

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