domain name ok

This commit is contained in:
gwen 2025-12-03 15:04:23 +01:00
parent 65d4440694
commit 40df27bf90

View file

@ -3,7 +3,8 @@ The `domainname` and `port` types
.. objectives:: Objectives .. objectives:: Objectives
Discover new types of variables. There isn't just the `string` or `integer` type,
discover new types of variables, such as `domainname` and `port`.
.. prerequisites:: Prerequisites .. prerequisites:: Prerequisites
@ -25,7 +26,7 @@ The `domainname` and `port` types
.. type-along:: let's recap how far we've come .. type-along:: let's recap how far we've come
We have an `http_proxy` family with an `address` variable. We have an `http_proxy` family with an `address` variable in it.
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/firefox/10-manual.yml .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/firefox/10-manual.yml
:language: yaml :language: yaml
@ -43,7 +44,7 @@ We have an `http_proxy` family with an `address` variable.
A variable with type `domainname` A variable with type `domainname`
----------------------------------- -----------------------------------
And we have assigned a type to this variable: Notice that we have assigned a type to this variable:
.. code-block:: yaml .. code-block:: yaml
:linenos: :linenos:
@ -96,54 +97,17 @@ We have this output:
</pre> </pre>
And we don't really see any change. But if we assign this user data: And we don't really see any change associated with the fact that we have assigned
a type to this variable. But if we assign this (wrong) user data:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/02/config.yml
:language: yaml
:caption: A domain name user data setting with an IP address
..
---
manual:
http_proxy:
address: 19.168.230.51
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_030/config/02/config.yml>`
that is, with a value that is not a domain name, then when we will launch the rougail CLI
we will see a difference:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/02/cmd_invalid.txt
:class: terminal
..
rougail -m firefox/ -u yaml -yf config/02/config.yml --cli.invalid_user_datas_error
we then have this output:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/02/output_invalid.html
:class: error
..
<pre><span style="font-weight: bold; color: #ff0000">🛑 ERRORS</span>
<span style="color: #ff0000">┗━━ </span>the value "192.168.0.1" is an invalid domain name for
<span style="color: #ff0000"> </span>"manual.http_proxy.address" (HTTP address), must not be an IP, it will be
<span style="color: #ff0000"> </span>ignored when loading from the YAML file "config/02/config.yml"
</pre>
We observe that an error has been raised because an IP address is not a domain name.
Therefore, a type validation is taking place because we declared the type `domainname`.
.. type-along:: A domain name has no space in it .. type-along:: A domain name has no space in it
Let's have a look at another example of user setting that does not fit the Let's have a look at an example of user setting that does not fit the
`domainname` type: `domainname` type:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/03/config.yml .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/03/config.yml
:language: yaml :language: yaml
:caption: An invalid domain name user data setting :caption: An invalid domain name for the :file:`config/03/config.yml` user data setting
.. ..
--- ---
@ -175,11 +139,51 @@ we then have this output:
<span style="color: #ff0000"> </span>ignored when loading from the YAML file "config/02/config.yml" <span style="color: #ff0000"> </span>ignored when loading from the YAML file "config/02/config.yml"
</pre> </pre>
.. type-along:: what if we set an IP address instead of a domain name?
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/02/config.yml
:language: yaml
:caption: A domain name in the :file:`config/02/config.yml` user data setting with an IP address
..
---
manual:
http_proxy:
address: 19.168.230.51
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_030/config/02/config.yml>`
With a value that *is not a domain name* but an IP address, then when we will launch the rougail CLI
we will see a little problem:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/02/cmd_invalid.txt
:class: terminal
..
rougail -m firefox/ -u yaml -yf config/02/config.yml --cli.invalid_user_datas_error
we then have this output:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/02/output_invalid.html
:class: error
..
<pre><span style="font-weight: bold; color: #ff0000">🛑 ERRORS</span>
<span style="color: #ff0000">┗━━ </span>the value "192.168.0.1" is an invalid domain name for
<span style="color: #ff0000"> </span>"manual.http_proxy.address" (HTTP address), must not be an IP, it will be
<span style="color: #ff0000"> </span>ignored when loading from the YAML file "config/02/config.yml"
</pre>
We observe that an error has been raised because an IP address is not a domain name.
Therefore, a type validation is taking place because we declared the type `domainname`.
.. type-along:: A variable with type's parameters .. type-along:: A variable with type's parameters
.. questions:: Question .. questions:: Question
OK I agree with the `domainname` type, but what if I want to specify OK I agree with the `domainname` necessary type validation, but what if I want to specify
an IP address as a user value for this `address` variable? an IP address as a user value for this `address` variable?
Because it is therefore simply impossible to do so now. Because it is therefore simply impossible to do so now.
@ -229,16 +233,9 @@ The params allow the domain name `address` variable to be set with IPs.
Now we will test with an IP address as the value for our `address` variable. Now we will test with an IP address as the value for our `address` variable.
.. type-along:: For those who follow the tutorial with the help of the git repository
Now you need to checkout the `v1.1_031` version::
git checkout v1.1_031
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_031/config/02/config.yml .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_031/config/02/config.yml
:language: yaml :language: yaml
:caption: An IP address as a value :caption: An IP address as a value in the :file:`config/02/config.yml` user value
.. ..
--- ---
@ -260,7 +257,7 @@ if we launch the rougail CLI on it:
We have this output: We have this output:
.. raw:: html .. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/config/01/output_ro.html :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_031/config/02/output_ro.html
:class: output :class: output
We can see that the IP address value has been accepted. We can see that the IP address value has been accepted.
@ -268,14 +265,18 @@ We can see that the IP address value has been accepted.
A variable with type `port` A variable with type `port`
------------------------------ ------------------------------
.. type-along:: For those who follow the tutorial with the help of the git repository
Now you need to checkout the `v1.1_032` version::
git checkout v1.1_032
We will add, according to our use case, a variable of type `port`: We will add, according to our use case, a variable of type `port`:
.. image:: images/firefox_port.png .. image:: images/firefox_port.png
.. keypoints:: let's review the key points .. keypoints:: let's review the key points
**Keywords** **Keywords**