rougail-output-environment/src/rougail/output_environment/config.py

131 lines
4 KiB
Python
Raw Normal View History

2026-07-10 08:22:19 +02:00
"""
Silique (https://www.silique.fr)
Copyright (C) 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
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 .i18n import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
options = [f"""
environment:
exists: true
redefine: true
description: {_("Load user data from environment variables or export configuration to environment variables")}
help: null
disabled:
jinja: |-
{{{{ (step.output is propertyerror or step.output != 'environment') and (step.user_data is propertyerror or 'environment' not in step.user_data) }}}}
return_type: boolean
description: >-
{_('if environment is not in "step.output" and not in "step.user_data"')}
""", f"""
environment:
exists: false
type: family
description: {_('Export configuration to environment variables')}
help: |-
{_('Exporting the configuration as an environment variable makes it available to applications that require this type of variable (scripts, Twelve-Factor Apps, etc.).')}
{_('You can use it, with the appropriate .rougailconf.yaml file, by doing: "source <(rougail)".')}
{_('Note: A variable within a "sequence" that is disabled for a specific index will be replaced by an empty string.')}
disabled:
variable: step.output
when_not: environment
propertyerror: false
""", f"""
environment:
output:
description: {_('Configuration for output environment')}
disabled:
variable: step.output
when_not: environment
propertyerror: false
prefix:
description: {_('Add prefix to environment variables')}
mandatory: false
boolean_type:
description: {_('Booleans are converted into')}
help: |-
{_('There is no boolean in shell, so we have to convert it')}
{_('"string" means the string "true" or "false"')}
{_('"number" means the number "1" or "0"')}
choices:
- string
- number
default: string
upper: true # {_('Variables name are upper')}
path_is_variable_name: true # {_('The variables name is, in fact, the path')}
custom_separator:
description: {_('Replace the separator character "." in path by an other')}
help: {_('The character dot (".") may not be allowed in the environment variable name.')}
mandatory: false
disabled:
variable: _.path_is_variable_name
when: false
default: "_"
multi_in_array:
description: {_('Multiple values variable will be loaded in a array')}
help: |-
{_('Not all shells support arrays. This feature is not POSIX-compatible, it\'s a Bash-specific feature (other shells like zsh or ksh also support arrays).')}
{_('If your shell supports arrays, it is preferable to use them to iterate over the values in the list.')}
default: true
multi_separator:
description: {_('The separator for multiple values variable')}
help:
default: ;
disabled:
variable: _.multi_in_array
submulti_separator:
description: {_('The separator for sub multiple values variable')}
default:
jinja: |-
{{% if _.multi_in_array %}}
;
{{% else %}}
,
{{% endif %}}
description: >-
{_('if "_.multi_in_array" the value is ";" otherwise the value is ","')}
"""]
return {
"name": "environment",
"process": "output",
"options": options,
"level": 60,
}
__all__ = ("get_rougail_config",)