Compare commits

...

56 commits

Author SHA1 Message Date
70f45e93b9 bump: version 0.2.0a19 → 0.2.0a20 2026-05-04 13:37:39 +02:00
338d1d1aae feat: multi layers support 2026-05-04 10:52:18 +02:00
ef58253dff fix: load indefine if no default value 2026-05-01 09:12:28 +02:00
b1368ec66f fix: user-data-ansible can set a personalise source 2026-02-11 19:43:29 +01:00
191516ab4f fix: test if password is set in a forbidden file even if it also in legitimate file 2026-02-11 19:43:00 +01:00
bbb584bc39 bump: version 0.2.0a18 → 0.2.0a19 2026-01-21 08:58:01 +01:00
127e5b953b fix: update tests 2026-01-20 12:36:27 +01:00
6c62b78808 bump: version 0.2.0a17 → 0.2.0a18 2025-12-30 10:47:02 +01:00
7be0c275a8 fix: doc 2025-12-29 20:55:50 +01:00
7fadb7f473 fix: update tests 2025-12-29 11:56:56 +01:00
5072fd4efb bump: version 0.2.0a16 → 0.2.0a17 2025-12-22 08:51:59 +01:00
7ed3867401 fix: user_datas => user_data 2025-12-22 08:51:51 +01:00
51be10e39f bump: version 0.2.0a15 → 0.2.0a16 2025-11-21 08:05:34 +01:00
ddecd9d4e3 feat: add 'add_help' option un TiramisuCmdLineParser + -ff => -yf 2025-11-21 08:05:17 +01:00
8bb9bb7e16 bump: version 0.2.0a14 → 0.2.0a15 2025-11-06 06:24:04 +01:00
f83b395f77 fix: update tests 2025-11-05 21:35:11 +01:00
9dad912ab3 fix: unknown variable 2025-10-27 11:14:12 +01:00
61dc196e85 bump: version 0.2.0a13 → 0.2.0a14 2025-10-10 08:10:55 +02:00
8cf9143430 fix: update test 2025-10-10 08:01:09 +02:00
5fda2da0ba fix: tests 2025-10-05 21:24:00 +02:00
f422e0a801 fix: tests for formatter 2025-09-30 21:49:47 +02:00
f40becb2ce bump: version 0.2.0a12 → 0.2.0a13 2025-09-29 11:02:01 +02:00
aa144c1e7c feat: default value for a calculated variable with an unknown optional variable 2025-09-28 15:44:19 +02:00
7e803a5a41 feat: update tests for integer type 2025-09-24 08:51:43 +02:00
d54db472e1 bump: version 0.2.0a11 → 0.2.0a12 2025-09-22 14:16:23 +02:00
4e2caf15ab fix: dependency 2025-09-22 14:16:00 +02:00
1af2120452 bump: version 0.2.0a10 → 0.2.0a11 2025-05-26 07:58:33 +02:00
881cdea72b fix: do not load yaml has YAML object 2025-05-19 18:45:36 +02:00
7ce8559481 bump: version 0.2.0a9 → 0.2.0a10 2025-05-14 08:30:44 +02:00
7552a1ab18 feat: yaml.filename could be the name of a directory 2025-05-14 08:29:53 +02:00
d75e447ec9 bump: version 0.2.0a8 → 0.2.0a9 2025-05-12 09:06:52 +02:00
6824ce4190 fix: black 2025-05-11 18:06:37 +02:00
f0b5cf3367 fix: update translation 2025-05-11 10:24:23 +02:00
26ae0b4e76 fix: load file with order 2025-05-11 08:07:12 +02:00
7dfb0465e5 bump: version 0.2.0a7 → 0.2.0a8 2025-05-02 08:14:39 +02:00
a2787fd7f2 fix: do not force use_data usage 2025-05-02 08:14:19 +02:00
acfca4f6a5 bump: version 0.2.0a6 → 0.2.0a7 2025-04-30 09:07:32 +02:00
64acbc2dbd fix: update tests 2025-04-27 10:19:57 +02:00
6598aff220 bump: version 0.2.0a5 → 0.2.0a6 2025-04-09 21:30:28 +02:00
a7c35b2de9 fix: version 2025-04-09 21:30:21 +02:00
8e8989c858 bump: version 0.2.0a4 → 0.2.0a5 2025-04-09 08:48:39 +02:00
f8bf91fd7a fix: better error message 2025-04-09 08:48:35 +02:00
d2c79690e4 bump: version 0.2.0a3 → 0.2.0a4 2025-04-01 22:15:07 +02:00
076fb40bdd fix: update tests 2025-04-01 21:59:47 +02:00
d2a8a601d8 bump: version 0.2.0a2 → 0.2.0a3 2025-03-30 18:58:31 +02:00
39358a74b5 fix: i18n 2025-03-30 18:58:27 +02:00
bc89583fe4 bump: version 0.2.0a1 → 0.2.0a2 2025-03-30 18:48:09 +02:00
634fdb6a3d fix: update tests 2025-03-30 18:47:16 +02:00
01a86922bd fix: update tests, some errors are now in warnings level 2025-03-02 17:45:56 +01:00
fa039c1743 bump: version 0.2.0a0 → 0.2.0a1 2025-02-10 09:23:51 +01:00
d4f81987e6 feat: add new parameter yaml.file_with_secrets 2025-02-10 09:23:33 +01:00
b0fdef7a52 fix: update tests 2025-02-04 07:45:38 +01:00
586f3a3e91 bump: version 0.1.1a0 → 0.2.0a0 2024-12-11 21:40:09 +01:00
23eadd9269 feat: rename file to yaml 2024-12-11 21:37:54 +01:00
412831278d bump: version 0.1.0 → 0.1.1a0 2024-11-25 10:15:51 +01:00
46db478687 fix: prepare ansible user data 2024-11-25 10:13:58 +01:00
1990 changed files with 17035 additions and 3800 deletions

View file

@ -1,3 +1,153 @@
## 0.2.0a20 (2026-05-04)
### Feat
- multi layers support
### Fix
- load indefine if no default value
- user-data-ansible can set a personalise source
- test if password is set in a forbidden file even if it also in legitimate file
## 0.2.0a19 (2026-01-21)
### Fix
- update tests
## 0.2.0a18 (2025-12-30)
### Fix
- doc
- update tests
## 0.2.0a17 (2025-12-22)
### Fix
- user_datas => user_data
## 0.2.0a16 (2025-11-21)
### Feat
- add 'add_help' option un TiramisuCmdLineParser + -ff => -yf
## 0.2.0a15 (2025-11-06)
### Fix
- update tests
- unknown variable
## 0.2.0a14 (2025-10-10)
### Fix
- update test
- tests
- tests for formatter
## 0.2.0a13 (2025-09-29)
### Feat
- default value for a calculated variable with an unknown optional variable
- update tests for integer type
## 0.2.0a12 (2025-09-22)
### Fix
- dependency
## 0.2.0a11 (2025-05-26)
### Fix
- do not load yaml has YAML object
## 0.2.0a10 (2025-05-14)
### Feat
- yaml.filename could be the name of a directory
## 0.2.0a9 (2025-05-12)
### Fix
- black
- update translation
- load file with order
## 0.2.0a8 (2025-05-02)
### Fix
- do not force use_data usage
## 0.2.0a7 (2025-04-30)
### Fix
- update tests
## 0.2.0a6 (2025-04-09)
### Fix
- version
## 0.2.0a5 (2025-04-09)
### Fix
- better error message
## 0.2.0a4 (2025-04-01)
### Fix
- update tests
## 0.2.0a3 (2025-03-30)
### Fix
- i18n
## 0.2.0a2 (2025-03-30)
### Fix
- update tests
- update tests, some errors are now in warnings level
## 0.2.0a1 (2025-02-10)
### Feat
- add new parameter yaml.file_with_secrets
### Fix
- update tests
## 0.2.0a0 (2024-12-11)
### Feat
- rename file to yaml
### Fix
- prepare ansible user data
## 0.1.0 (2024-11-06)
## 0.1.0rc1 (2024-11-06)
### Fix

20
README.fr.md Normal file
View file

@ -0,0 +1,20 @@
---
gitea: none
include_toc: true
---
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
## Charger les données utilisateur à partir d'un fichier YAML
> [!NOTE]
>
> **Chemin** : yaml\
> *`désactivé`*\
> **Désactivé** : si yaml n'est pas défini dans "[Sélection pour données utilisateur](#step.user_data)"
| Variable | Description | Valeur par défaut | Type | Validateur |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|--------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="yaml.filename" name="yaml.filename">yaml.filename</a>**<br/>**Ligne de commande** : <br/>-yf, --yaml.filename<br/>**Variable d'environnement** : YAML.FILENAME | Noms de fichiers ou répertoires où sont enregistrés les données utilisateur.<br/>Si un répertoire est défini, tous les fichiers avec l&#x27;extension &quot;yml&quot; ou &quot;yaml&quot; seront chargés dans l&#x27;ordre alphanumérique. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `obligatoire` | `unique`<br/>&nbsp;le nom de fichier peut être une chemin relatif<br/>&nbsp;le fichier doit exister<br/>&nbsp;type de fichier autorisé: "fichier" et "répertoire". |
| **<a id="yaml.file_with_secrets" name="yaml.file_with_secrets">yaml.file_with_secrets</a>**<br/>**Ligne de commande** : <br/>--yaml.file_with_secrets<br/>**Variable d'environnement** : YAML.FILE_WITH_SECRETS | Le fichier peut contenir des secrets.<br/>Par défaut, tous les fichiers peuvent contenir des secrets. Il peut être intéressant de définir plus précisément quels fichiers peuvent contenir ces secrets. | all | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | **Choix** : <br/>&nbsp;all<br/>&nbsp;first<br/>&nbsp;last<br/>&nbsp;none |

View file

@ -1,2 +1,20 @@
# rougail-user-data
---
gitea: none
include_toc: true
---
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
## Charge user data from YAML file
> [!NOTE]
>
> **Path**: yaml\
> *`disabled`*\
> **Disabled**: if yaml is not set in "[Select for user datas](#step.user_data)"
| Variable | Description | Default value | Type | Validator |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="yaml.filename" name="yaml.filename">yaml.filename</a>**<br/>**Command line**: <br/>-yf, --yaml.filename<br/>**Environment variable**: YAML.FILENAME | File or directory names where user data are stored.<br/>If a directory is set, all files with &quot;yml&quot; ou &quot;yaml&quot; extension will be load with alphanum order. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `mandatory` | `unique`<br/>&nbsp;this filename could be a relative path<br/>&nbsp;this file must exist<br/>&nbsp;file type allowed: "directory" and "file". |
| **<a id="yaml.file_with_secrets" name="yaml.file_with_secrets">yaml.file_with_secrets</a>**<br/>**Command line**: <br/>--yaml.file_with_secrets<br/>**Environment variable**: YAML.FILE_WITH_SECRETS | File that may contain secrets.<br/>By default, all files can contain secrets. It might be useful to define more precisely which files can contain these secrets. | all | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | **Choices**: <br/>&nbsp;all<br/>&nbsp;first<br/>&nbsp;last<br/>&nbsp;none |

View file

@ -0,0 +1,75 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2025-12-29 12:15+0100\n"
"PO-Revision-Date: 2025-12-29 12:18+0100\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.8\n"
#: src/rougail/user_data_yaml/__init__.py:46
msgid "yaml is not set in step.user_data"
msgstr "\"yaml\" n'est pas défini dans step.user_data"
#: src/rougail/user_data_yaml/__init__.py:74
msgid "cannot load \"{0}\", the root value is not a dict but \"{1}\""
msgstr ""
"ne peut charger \"{0}\", la valeur racine n'est pas une dictionnaire mais "
"\"{1}\""
#: src/rougail/user_data_yaml/__init__.py:95
msgid "the YAML file \"{0}\""
msgstr "le fichier YAML \"{0}\""
#: src/rougail/user_data_yaml/__init__.py:127
msgid "\"{0}\" in {1} has an unknown value"
msgstr "\"{0}\" dans {1} a une valeur inconnue"
#: src/rougail/user_data_yaml/config.py:30
msgid "Charge user data from YAML file"
msgstr "Charger les données utilisateur à partir d'un fichier YAML"
#: src/rougail/user_data_yaml/config.py:35
msgid "if yaml is not set in \"step.user_data\""
msgstr "si yaml n'est pas défini dans \"step.user_data\""
#: src/rougail/user_data_yaml/config.py:38
msgid "File or directory names where user data are stored"
msgstr ""
"Noms de fichiers ou répertoires où sont enregistrés les données utilisateur"
#: src/rougail/user_data_yaml/config.py:39
msgid ""
"If a directory is set, all files with \"yml\" ou \"yaml\" extension will be "
"load with alphanum order."
msgstr ""
"Si un répertoire est défini, tous les fichiers avec l'extension \"yml\" ou "
"\"yaml\" seront chargés dans l'ordre alphanumérique."
#: src/rougail/user_data_yaml/config.py:48
msgid "File that may contain secrets"
msgstr "Le fichier peut contenir des secrets"
#: src/rougail/user_data_yaml/config.py:49
msgid ""
"By default, all files can contain secrets. It might be useful to define more "
"precisely which files can contain these secrets."
msgstr ""
"Par défaut, tous les fichiers peuvent contenir des secrets. Il peut être "
"intéressant de définir plus précisément quels fichiers peuvent contenir ces "
"secrets."
#~ msgid "Configuration rougail-user-data-yaml"
#~ msgstr "Configuration de rougail-user-data-yaml"
#~ msgid "Filename"
#~ msgstr "Nom du fichier"

View file

@ -1,35 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2024-11-01 12:12+0100\n"
"PO-Revision-Date: 2024-11-01 12:13+0100\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.5\n"
#: src/rougail/user_data_file/__init__.py:40
msgid "file is not set in step.user_data"
msgstr "\"file\" n'est pas défini dans step.user_data"
#: src/rougail/user_data_file/__init__.py:58
msgid "cannot load \"{0}\", the root value is not a dict but \"{1}\""
msgstr ""
"ne peut charger \"{0}\", la valeur racine n'est pas une dictionnaire mais "
"\"{1}\""
#: src/rougail/user_data_file/__init__.py:66
msgid "file ({0})"
msgstr "fichier ({0})"
#: src/rougail/user_data_file/__init__.py:88
msgid "\"{0}\" in {1} has an unknown value"
msgstr "\"{0}\" dans {1} a une valeur inconnue"

View file

@ -1,33 +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: 2024-11-01 12:13+0100\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_file/__init__.py:40
msgid "file is not set in step.user_data"
msgstr ""
#: src/rougail/user_data_file/__init__.py:58
msgid "cannot load \"{0}\", the root value is not a dict but \"{1}\""
msgstr ""
#: src/rougail/user_data_file/__init__.py:66
msgid "file ({0})"
msgstr ""
#: src/rougail/user_data_file/__init__.py:88
msgid "\"{0}\" in {1} has an unknown value"
msgstr ""

View file

@ -0,0 +1,57 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-12-29 12:18+0100\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_yaml/__init__.py:46
msgid "yaml is not set in step.user_data"
msgstr ""
#: src/rougail/user_data_yaml/__init__.py:74
msgid "cannot load \"{0}\", the root value is not a dict but \"{1}\""
msgstr ""
#: src/rougail/user_data_yaml/__init__.py:95
msgid "the YAML file \"{0}\""
msgstr ""
#: src/rougail/user_data_yaml/__init__.py:127
msgid "\"{0}\" in {1} has an unknown value"
msgstr ""
#: src/rougail/user_data_yaml/config.py:30
msgid "Charge user data from YAML file"
msgstr ""
#: src/rougail/user_data_yaml/config.py:35
msgid "if yaml is not set in \"step.user_data\""
msgstr ""
#: src/rougail/user_data_yaml/config.py:38
msgid "File or directory names where user data are stored"
msgstr ""
#: src/rougail/user_data_yaml/config.py:39
msgid "If a directory is set, all files with \"yml\" ou \"yaml\" extension will be load with alphanum order."
msgstr ""
#: src/rougail/user_data_yaml/config.py:48
msgid "File that may contain secrets"
msgstr ""
#: src/rougail/user_data_yaml/config.py:49
msgid "By default, all files can contain secrets. It might be useful to define more precisely which files can contain these secrets."
msgstr ""

View file

@ -3,21 +3,20 @@ build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.user_data_file"
version = "0.1.0"
name = "rougail.user_data_yaml"
version = "0.2.0a20"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "Rougail user_data file"
description = "Rougail user_data yaml"
requires-python = ">=3.8"
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",
@ -25,16 +24,21 @@ classifiers = [
]
dependencies = [
"rougail >= 1.1,<2",
"rougail-base >= 1.1,<2",
"ruamel.yaml ~= 0.18.6",
]
[project.urls]
Home = "https://forge.cloud.silique.fr/stove/rougail-user-data-file"
Home = "https://forge.cloud.silique.fr/stove/rougail-user-data-yaml"
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "pep440"
version_provider = "pep621"
#update_changelog_on_bump = true
version_files = [
"src/rougail/user_data_yaml/__version__.py",
"pyproject.toml:version"
]
update_changelog_on_bump = true
changelog_merge_prerelease = true

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
Copyright (C) 2024-2026
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
@ -16,68 +16,107 @@ 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 rougail import RougailConfig
from ruamel.yaml import YAML
from pathlib import Path
from itertools import chain
from rougail.error import ExtensionError
from tiramisu.error import ValueOptionError, PropertiesOptionError, LeadershipError
from rougail.utils import undefined
from tiramisu import MetaConfig
from .i18n import _
from .__version__ import __version__
class RougailUserDataFile:
class RougailUserDataYaml:
has_several_layers = True
def __init__(
self,
config,
*,
rougailconfig=None,
**kwargs,
) -> None:
if rougailconfig is None:
from rougail import RougailConfig
rougailconfig = RougailConfig
user_data = rougailconfig["step.user_data"]
if "file" not in user_data:
user_data.append("file")
if "yaml" not in user_data:
user_data.append("yaml")
rougailconfig["step.user_data"] = user_data
user_data = rougailconfig["step.user_data"]
if "file" not in user_data:
raise Exception(_("file is not set in step.user_data"))
if "yaml" not in user_data:
raise ExtensionError(_("yaml is not set in step.user_data"))
self.rougailconfig = rougailconfig
self.filenames = self.rougailconfig["file.filename"]
self.yaml = YAML()
self.config = config
self.filenames = []
for filename in self.rougailconfig["yaml.filename"]:
filename = Path(filename)
if filename.is_file():
self.filenames.append(filename)
else:
for name in sorted(chain(filename.glob('*.yml'), filename.glob('*.yaml'))):
self.filenames.append(name)
self.file_with_secrets = self.rougailconfig["yaml.file_with_secrets"]
self.errors = []
self.warnings = []
self.source = _('the YAML file "{0}"')
def count_layers(self):
return len(self.filenames)
def run(
self,
) -> None:
user_datas = []
for filename in self.filenames:
with open(filename) as fh_config:
file_values = self.yaml.load(fh_config)
self.yaml = YAML(typ='safe', pure=True)
user_data = []
if self.file_with_secrets == "last":
last_filename_idx = len(self.filenames) - 1
for idx, filename in enumerate(self.filenames):
file_values = self.open(filename)
if not file_values:
continue
values = {}
if not isinstance(file_values, dict):
self.errors.append(
_(
'cannot load "{0}", the root value is not a dict but "{1}"'
).format(filename, file_values)
)
continue
values = {}
else:
self.parse(
values,
"",
file_values,
filename,
)
user_datas.append(
if self.file_with_secrets == "none":
allow_secrets_variables = False
elif self.file_with_secrets == "first":
allow_secrets_variables = idx == 0
elif self.file_with_secrets == "last":
allow_secrets_variables = idx == last_filename_idx
else:
allow_secrets_variables = True
user_data.append(
{
"source": _("file ({0})").format(filename),
"source": self.source.format(filename),
"errors": self.errors,
"warnings": self.warnings,
"values": values,
"options": {
"allow_secrets_variables": allow_secrets_variables,
},
}
)
return user_datas
return user_data
def open(self, filename: str) -> dict:
with filename.open() as fh_config:
return self.yaml.load(fh_config)
def parse(
self,
@ -92,7 +131,7 @@ class RougailUserDataFile:
self.parse(values, path + ".", value, filename)
elif isinstance(value, list) and value and isinstance(value[0], dict):
# it's a leadership
keys = set()
keys = []
for val in value:
if not isinstance(val, dict):
self.errors.append(
@ -101,19 +140,21 @@ class RougailUserDataFile:
)
)
break
keys |= set(val)
for v in val:
if v not in keys:
keys.append(v)
else:
for val in value:
for key in keys:
values.setdefault(path + "." + key, []).append(
val.get(key, None)
val.get(key, undefined)
)
else:
values[path] = value
RougailUserData = RougailUserDataFile
RougailUserData = RougailUserDataYaml
__all__ = ("RougailUserDataFile",)
__all__ = ("RougailUserDataYaml",)

View file

@ -0,0 +1 @@
__version__ = "0.2.0a20"

View file

@ -1,8 +1,8 @@
"""
Config file for Rougail-user-data
Config yaml for Rougail-user-data
Silique (https://www.silique.fr)
Copyright (C) 2024
Copyright (C) 2024-2026
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
@ -18,33 +18,44 @@ 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 .i18n import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = """
file:
description: Configuration rougail-user-data-file
options = f"""
yaml:
description: {_("Charge user data from YAML file")}
disabled:
type: jinja
jinja: |
{% if 'file' not in step.user_data %}
disabled
{% endif %}
jinja: >-
{{{{ step.user_data is propertyerror or 'yaml' not in step.user_data }}}}
return_type: boolean
description: {_('if yaml is not set in "step.user_data"')}
filename:
description: Filename with user data
alternative_name: ff
description: {_("File or directory names where user data are stored")}
help: {_('If a directory is set, all files with "yml" ou "yaml" extension will be load with alphanum order.')}
alternative_name: yf
type: unix_filename
multi: true
params:
allow_relative: True
test_existence: True
types:
- file
file_with_secrets:
description: {_("File that may contain secrets")}
help: {_('By default, all files can contain secrets. It might be useful to define more precisely which files can contain these secrets.')}
default: all
choices:
- all
- first
- last
- none
"""
return {
"name": "file",
"name": "yaml",
"process": "user data",
"options": options,
"level": 50,

View file

@ -1,6 +1,6 @@
"""Internationalisation utilities
Silique (https://www.silique.fr)
Copyright (C) 2024
Copyright (C) 2024-2026
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
@ -20,7 +20,7 @@ from gettext import translation
from pathlib import Path
t = translation(
"rougail_user_data_file", str(Path(__file__).parent / "locale"), fallback=True
"rougail_user_data_yaml", str(Path(__file__).parent / "locale"), fallback=True
)
_ = t.gettext

View file

@ -0,0 +1,5 @@
{
"variable1": "value1",
"variable2": "value2",
"variable3": null
}

View file

@ -0,0 +1,11 @@
---
version: 1.1
variable1:
mandatory: false
variable2:
mandatory: false
variable3:
mandatory: false

View file

@ -0,0 +1,2 @@
---
variable3: value3

View file

@ -0,0 +1,2 @@
---
variable2: value2

View file

@ -0,0 +1,2 @@
---
variable1: value1

View file

@ -0,0 +1,5 @@
{
"dynVal1": {
"var": "string1"
}
}

View file

@ -0,0 +1,10 @@
---
version: '1.1'
var: [] # A suffix variable
"dyn{{ identifier }}":
description: A dynamic family
dynamic:
variable: _.var
var: # A dynamic variable

View file

@ -0,0 +1,5 @@
{
"dynVal1": {
"var": "string1"
}
}

View file

@ -0,0 +1,12 @@
---
version: '1.1'
var: #A suffix variable
mandatory: false
default: []
"dyn{{ identifier }}":
description: A dynamic family
dynamic:
variable: _.var
var: # A dynamic variable

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"unknown\" does not exist so cannot load \"unknown\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/00_unknown_variable.yaml\""
]
}

View file

@ -0,0 +1,19 @@
{
"errors": [],
"warnings": [
[
[
"family \"family_disabled\" has property disabled, so cannot access to \"variable1\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/01_disabled_family.yaml\"",
"family_disabled.variable1",
null
]
],
[
[
"family \"family_disabled\" has property disabled, so cannot access to \"variable2\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/01_disabled_family.yaml\"",
"family_disabled.variable2",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"variable has property disabled, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/01_disabled_variable.yaml\"",
"variable_disabled",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"test\" is an invalid integer, it's not an integer, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/01_wrong_type.yaml\"",
"variable_int",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"family \"family_disabled_hidden\" has property disabled and hidden, so cannot access to \"variable1\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/02_disabled_hidden_family.yaml\"",
"family_disabled_hidden.variable1",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"**********\" is an invalid password, at least 10 characters are required, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/04_value_secret.yaml\"",
"secret",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"it's a family so we cannot set the value \"test\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/05_value_family.yaml\"",
"family",
null
]
]
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"dyn_unknown\" does not exist so cannot load \"dyn_unknown.variable\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/06_dynamic_unknown.yaml\""
]
}

View file

@ -0,0 +1,33 @@
{
"errors": [],
"warnings": [
[
[
"variable \"follower_disabled\" at index \"0\" is disabled, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/07_leadership_disabled.yaml\"",
"leadership.follower_disabled",
null
]
],
[
[
"variable \"follower_disabled\" at index \"1\" is disabled, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/07_leadership_disabled.yaml\"",
"leadership.follower_disabled",
null
]
],
[
[
"variable \"follower_disabled\" at index \"2\" is disabled, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/07_leadership_disabled.yaml\"",
"leadership.follower_disabled",
null
]
],
[
[
"variable \"follower_disabled_at_index\" at index \"1\" is disabled, it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/07_leadership_disabled.yaml\"",
"leadership.follower_disabled_at_index",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"variable or family \"unknwon\" does not exist so cannot load \"leadership.unknwon\", it will be ignored when loading from the YAML file \"/home/gnunux/git/stove/rougail-user-data-yaml/tests/errors/yaml/07_leadership_unknown.yaml\"",
"leadership",
null
]
]
]
}

View file

@ -0,0 +1,68 @@
%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 @@
---
unknown: 1

View file

@ -0,0 +1,4 @@
---
family_disabled:
variable1: test
variable2: test

View file

@ -0,0 +1,2 @@
---
variable_disabled: test

View file

@ -0,0 +1,2 @@
---
variable_int: test

View file

@ -0,0 +1,3 @@
---
family_disabled_hidden:
variable1: test

View file

@ -0,0 +1,2 @@
---
secret: a

View file

@ -0,0 +1,2 @@
---
family: test

View file

@ -0,0 +1,3 @@
---
dyn_unknown:
variable: test

View file

@ -0,0 +1,14 @@
---
leadership:
- leader: test1
follower: test1
follower_disabled: test1
follower_disabled_at_index: test1
- leader: test2
follower: test2
follower_disabled: test2
follower_disabled_at_index: test2
- leader: test3
follower: test3
follower_disabled: test3
follower_disabled_at_index: test3

View file

@ -0,0 +1,4 @@
---
leadership:
- leader: test
unknwon: test

View file

@ -0,0 +1,5 @@
---
leadership:
- leader: test
follower: test1
- follower: test1

View file

@ -0,0 +1,3 @@
---
a_family:
a_boolean: oups

View file

@ -0,0 +1,3 @@
---
a_str:
- ly

View file

@ -0,0 +1,2 @@
---
a_family: oups

View file

@ -0,0 +1,4 @@
---
a_leadership:
- a_leader: val1
a_follower: 1

View file

@ -0,0 +1,2 @@
---
a_multi: oups

View file

@ -0,0 +1,5 @@
---
a_family:
a_boolean:
- true

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"oups\" is an invalid boolean, invalid value, it will be ignored when loading from the YAML file \"tests/invalid/invalid/00.yml\"",
"a_family.a_boolean",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"it's a family so we cannot set the value \"oups\", it will be ignored when loading from the YAML file \"tests/invalid/invalid_family/00.yml\"",
"a_family",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"it's a family so we cannot set the value \"oups\", it has been loading from the YAML file \"tests/invalid/invalid_family/00.yml\"",
"a_family",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"it's a family so we cannot set the value \"oups\", it has been loading from the YAML file \"tests/invalid/invalid_family/00.yml\"",
"a_family",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"it's a family so we cannot set the value \"oups\", it will be ignored when loading from the YAML file \"tests/invalid/invalid_family/00.yml\"",
"a_family",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"oups\" is an invalid boolean, invalid value, it has been loading from the YAML file \"tests/invalid/invalid/00.yml\"",
"a_family.a_boolean",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"oups\" is an invalid boolean, invalid value, it has been loading from the YAML file \"tests/invalid/invalid/00.yml\"",
"a_family.a_boolean",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"1\" is an invalid string, it's not a string, it will be ignored when loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\"",
"a_leadership.a_follower",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"1\" is an invalid string, it's not a string, it has been loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\"",
"a_leadership.a_follower",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"1\" is an invalid string, it's not a string, it has been loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\"",
"a_leadership.a_follower",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"1\" is an invalid string, it's not a string, it will be ignored when loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\"",
"a_leadership.a_follower",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"oups\" is an invalid string, it must be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi/00.yml\"",
"a_multi",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"True\" is an invalid boolean, it must not be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\"",
"a_family.a_boolean",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"True\" is an invalid boolean, it must not be a list, it has been loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\"",
"a_family.a_boolean",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"True\" is an invalid boolean, it must not be a list, it has been loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\"",
"a_family.a_boolean",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"True\" is an invalid boolean, it must not be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\"",
"a_family.a_boolean",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"oups\" is an invalid string, it must be a list, it has been loading from the YAML file \"tests/invalid/invalid_multi/00.yml\"",
"a_multi",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"the value \"oups\" is an invalid string, it must be a list, it has been loading from the YAML file \"tests/invalid/invalid_multi/00.yml\"",
"a_multi",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"oups\" is an invalid string, it must be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi/00.yml\"",
"a_multi",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"oups\" is an invalid boolean, invalid value, it will be ignored when loading from the YAML file \"tests/invalid/invalid/00.yml\"",
"a_family.a_boolean",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"variable or family \"unknown\" does not exist so cannot load \"a_family.unknown\", it will be ignored when loading from the YAML file \"tests/invalid/unknown/00.yml\"",
"a_family",
null
]
]
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"an_unkown_family\" does not exist so cannot load \"an_unkown_family.unknown\", it will be ignored when loading from the YAML file \"tests/invalid/unknown2/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"an_unkown_family\" does not exist so cannot load \"an_unkown_family.unknown\", it will be ignored when loading from the YAML file \"tests/invalid/unknown2/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"variable or family \"an_unkown_family\" does not exist so cannot load \"an_unkown_family.unknown\", it has been loading from the YAML file \"tests/invalid/unknown2/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"variable or family \"an_unkown_family\" does not exist so cannot load \"an_unkown_family.unknown\", it has been loading from the YAML file \"tests/invalid/unknown2/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"variable or family \"unknown\" does not exist so cannot load \"a_family.unknown\", it will be ignored when loading from the YAML file \"tests/invalid/unknown/00.yml\"",
"a_family",
null
]
]
]
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"variable or family \"unknown\" does not exist so cannot load \"a_family.unknown\", it has been loading from the YAML file \"tests/invalid/unknown/00.yml\"",
"a_family",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"errors": [
[
[
"variable or family \"unknown\" does not exist so cannot load \"a_family.unknown\", it has been loading from the YAML file \"tests/invalid/unknown/00.yml\"",
"a_family",
null
]
]
],
"warnings": []
}

View file

@ -0,0 +1,23 @@
%YAML 1.2
---
version: 1.1
a_multi: [] # A multi
a_leadership:
description: A leadership
type: leadership
a_leader: # A leader
a_follower: # A follower
a_str: # A str
- val1
a_family: # A family
a_boolean: true # A boolean
a_fami{{ identifier }}: # A dynamic family
...

View file

@ -0,0 +1,3 @@
---
a_family:
unknown: oups

View file

@ -0,0 +1,3 @@
---
an_unkown_family:
unknown: oups

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,9 @@
[
[
[
"mandatory variable but has no value",
"proxy_mode",
null
]
]
]

View file

@ -0,0 +1,9 @@
[
[
[
"mandatory variable but has no value",
"proxy_mode",
null
]
]
]

View file

@ -0,0 +1,3 @@
{
"proxy_mode": "No proxy"
}

View file

@ -0,0 +1,3 @@
{
"proxy_mode": "No proxy"
}

View file

@ -0,0 +1,9 @@
[
[
[
"mandatory variable but has no value",
"proxy_mode",
null
]
]
]

View file

@ -0,0 +1,9 @@
[
[
[
"mandatory variable but has no value",
"proxy_mode",
null
]
]
]

View file

@ -0,0 +1,12 @@
{
"errors": [],
"warnings": [
[
[
"the value \"1\" is an invalid string, it's not a string, it will be ignored when loading from the YAML file \"../rougail-tutorials_builder/examples/001/config/03/config.yml\"",
"proxy_mode",
null
]
]
]
}

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