fix: nullable 091
This commit is contained in:
parent
65009bb6f7
commit
81c40d6eb2
1 changed files with 84 additions and 8 deletions
|
|
@ -6,8 +6,8 @@ Nullable variable
|
|||
Now in this section we would like to make it possible that it is not necessary to specify a value
|
||||
for a variable.
|
||||
|
||||
With rougail, it is possible for a variable's setttings have no value (nothing, null, None),
|
||||
that is, neither an assigned value nor a default value.
|
||||
With rougail, it is possible for a variable's setttings to have no value (nothing, null, None),
|
||||
that is, neither a default value nor a user assigned value.
|
||||
|
||||
.. prerequisites:: Prerequisites
|
||||
|
||||
|
|
@ -33,18 +33,18 @@ Variable with the value "null"
|
|||
|
||||
|
||||
.. note:: It is important to keep in mind that in Rougail a variable is :term:`mandatory` by default,
|
||||
meaning that it must either have a default value set or a :term:`user data` value assigned in the :term:`user data file`\ .
|
||||
meaning that it must either have a :term:`default value` set or a :term:`user data` value assigned in the :term:`user data file`\ .
|
||||
This is Rougail's default behavior.
|
||||
|
||||
Besides, note that the explicit keyword to express the setting "no value, nothing" in YAML is the `null` explicit keyword.
|
||||
|
||||
Here is how we are going to specify a "no value" (nothing, `null`) as a possible setting for the `address` variable in the `socks_proxy` family.
|
||||
|
||||
We need to:
|
||||
There are a few things to set in the variable. We need to:
|
||||
|
||||
- explicitely disable the default :term:`mandatory` behavior (we will set it to `false`,
|
||||
- redefine the
|
||||
- define a default value of None (null).
|
||||
- explicitely disable the default :term:`mandatory` behavior of the `address` variable(just by setting it to `false`),
|
||||
- redefine the `address` variable inside the `socks_proxy` because this family uses the `proxy` type definition,
|
||||
- finally set the `address` default value to `null`.
|
||||
|
||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_090/firefox/20-manual.yml
|
||||
:language: yaml
|
||||
|
|
@ -97,10 +97,86 @@ We need to:
|
|||
...
|
||||
|
||||
|
||||
Here are somme maybe usefull explanations:
|
||||
Some more, maybe usefull, explanations about our `address` variable in the `socks_proxy` family:
|
||||
|
||||
- Allowing the "no value, nothing" behavior is easy, we just add the `mandatory: false` attribute,
|
||||
- we explicitely need to set the `redefine: true` attribute because in the type `proxy` type setting
|
||||
we didn't set the `mandatory` attribute to false, this is then a type redefinition,
|
||||
- finally we can set the `default: null` that means that we can set no value to our address variable.
|
||||
|
||||
Note too that is is necessary to redefine (to set a `redefine` attribute) as soon as you
|
||||
modify the type definition. Here we have set a default value to our `socks_proxy`'s `port` variable.
|
||||
We need then to redefine not only because of the `description` attribute but because of the default value too.
|
||||
|
||||
|
||||
Variables disabled when condition is null
|
||||
--------------------------------------------
|
||||
|
||||
.. type-along:: For those who follow the tutorial with the help of the git repository
|
||||
|
||||
Now you need to checkout the :tutorial:`v1.1_091 <src/tag/v1.1_091/README.md>` version::
|
||||
|
||||
git switch --detach v1.1_091
|
||||
|
||||
.. questions:: Question
|
||||
|
||||
But actually, why did we want a variable to be non-mandatory?
|
||||
|
||||
Well, what we want is we need to be able to disable either the `port` and the `version` in case of the `address` has no value set:
|
||||
|
||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_091/firefox/20-manual.yml
|
||||
:language: yaml
|
||||
:caption: The :file:`firefox/20-manual.yml` structure file with the `disabled` set in case of the `address` has no value set
|
||||
|
||||
..
|
||||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
manual:
|
||||
|
||||
use_for_https: true # Also use this proxy for HTTPS
|
||||
|
||||
https_proxy:
|
||||
description: HTTPS Proxy
|
||||
type: proxy
|
||||
hidden:
|
||||
variable: _.use_for_https
|
||||
|
||||
address:
|
||||
redefine: true
|
||||
description: HTTPS proxy address
|
||||
|
||||
port:
|
||||
redefine: true
|
||||
description: HTTPS proxy port
|
||||
|
||||
socks_proxy:
|
||||
description: SOCKS Proxy
|
||||
type: proxy
|
||||
|
||||
address:
|
||||
redefine: true
|
||||
description: SOCKS proxy address
|
||||
default: null
|
||||
mandatory: false
|
||||
|
||||
port:
|
||||
redefine: true
|
||||
description: SOCKS proxy port
|
||||
default: 1080
|
||||
disabled:
|
||||
variable: _.address
|
||||
when: null
|
||||
|
||||
version:
|
||||
description: SOCKS host version used by proxy
|
||||
choices:
|
||||
- v4
|
||||
- v5
|
||||
default: v5
|
||||
disabled:
|
||||
variable: _.address
|
||||
when: null
|
||||
...
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue