domainname and port ok
This commit is contained in:
parent
40df27bf90
commit
8bc7c9b04d
1 changed files with 101 additions and 6 deletions
|
|
@ -272,15 +272,110 @@ A variable with type `port`
|
|||
git checkout v1.1_032
|
||||
|
||||
|
||||
We will add, according to our use case, a variable of type `port`:
|
||||
After the `address` variable let's add, according to our use case,
|
||||
|
||||
.. image:: images/firefox_port.png
|
||||
|
||||
a new variable of type `port`. Our structure file looks like this:
|
||||
|
||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_032/firefox/10-manual.yml
|
||||
:language: yaml
|
||||
:caption: The `port` type variable in the :file:`firefox/10-manual.yml` structure file
|
||||
:linenos:
|
||||
..
|
||||
port:
|
||||
description: HTTP Port
|
||||
type: port
|
||||
default: 8080
|
||||
|
||||
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_032/firefox/10-manual.yml>`
|
||||
|
||||
Let's assing a value to this port:
|
||||
|
||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_032/config/02/config.yml
|
||||
:language: yaml
|
||||
:caption: A user data :file:`config/02/config.yml` setting a value to the port variable
|
||||
|
||||
..
|
||||
proxy_mode: Manual proxy configuration
|
||||
manual:
|
||||
http_proxy:
|
||||
address: example.net
|
||||
port: 3128
|
||||
|
||||
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_032/config/02/config.yml>`
|
||||
|
||||
If we launch the rougail CLI:
|
||||
|
||||
.. raw:: html
|
||||
:class: terminal
|
||||
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_032/config/02/cmd_ro.txt
|
||||
|
||||
We have this output:
|
||||
|
||||
.. raw:: html
|
||||
:class: output
|
||||
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_032/config/02/output_ro.html
|
||||
|
||||
..
|
||||
<pre>╭─────────────────────────── Caption ────────────────────────────╮
|
||||
│ Variable <span style="color: #00aa00">Modified value</span> │
|
||||
│ <span style="color: #ff0000">Undocumented but modified variable</span> (⏳ Original default value) │
|
||||
╰────────────────────────────────────────────────────────────────╯
|
||||
Variables:
|
||||
<span style="color: #5c5cff">┣━━ </span>📓 <span style="color: #ff0000">Configure Proxy Access to the Internet</span>: <span style="color: #00aa00">Manual proxy configuration</span> ◀
|
||||
<span style="color: #5c5cff">┃ </span>loaded from the YAML file "config/02/config.yml" (⏳ No proxy)
|
||||
<span style="color: #5c5cff">┗━━ </span>📂 Manual proxy configuration
|
||||
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┗━━ </span>📂 HTTP Proxy
|
||||
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 <span style="color: #ff0000">HTTP address</span>: <span style="color: #00aa00">example.net</span> ◀ loaded from the YAML file
|
||||
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span><span style="color: #5c5cff">┃ </span>"config/02/config.yml"
|
||||
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span><span style="color: #5c5cff">┗━━ </span>📓 <span style="color: #ff0000">HTTP Port</span>: <span style="color: #00aa00">3128</span> ◀ loaded from the YAML file
|
||||
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span>"config/02/config.yml" (⏳ 8080)
|
||||
</pre>
|
||||
|
||||
How can we know what validations the port type performs on the value assigned to the variable?
|
||||
|
||||
There are a number of validations that are carried out with this `port` type:
|
||||
|
||||
- well-known ports (1 to 1023) are allowed
|
||||
- registred ports (1024 to 49151) are allowed
|
||||
|
||||
.. - private ports (greater than 49152) are allowed
|
||||
|
||||
Now let's assign a value that is outside the allowed ports:
|
||||
|
||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_032/config/03/config.yml
|
||||
:language: yaml
|
||||
:caption: A user value in :file:`config/03/config.yml` that is not allowed
|
||||
|
||||
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_032/config/03/config.yml>`
|
||||
|
||||
Again, we launch the rougail CLI:
|
||||
|
||||
.. raw:: html
|
||||
:class: terminal
|
||||
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_032/config/03/cmd_invalid.txt
|
||||
|
||||
.. rougail -m firefox/ -u yaml -yf config/03/config.yml --cli.invalid_user_datas_error
|
||||
|
||||
And we have this output:
|
||||
|
||||
.. raw:: html
|
||||
:class: error
|
||||
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_032/config/03/output_invalid.html
|
||||
|
||||
..
|
||||
<pre><span style="font-weight: bold; color: #ff0000">🛑 ERRORS</span>
|
||||
<span style="color: #ff0000">┗━━ </span>the value "100000" is an invalid port for "manual.http_proxy.port" (HTTP
|
||||
<span style="color: #ff0000"> </span>Port), must be between 1 and 65535, it will be ignored when loading from the
|
||||
<span style="color: #ff0000"> </span>YAML file "config/03/config.yml"
|
||||
</pre>
|
||||
|
||||
We observe that, as with the `domainname` type, a number of validations are performed
|
||||
to ensure that the value assigned to this variable conforms to the `port` type.
|
||||
|
||||
.. keypoints:: let's review the key points
|
||||
|
||||
**Keywords**
|
||||
|
||||
- we can set a `domainname` type to a variable
|
||||
- we can add :term:`parameter`\ s to variables to refine their typing behavior
|
||||
|
||||
- we can assign a `domainname` type to a variable
|
||||
- we can set a :term:`parameter` to a `domainname` variable to refine their typing behavior
|
||||
- we can assign a `port` type to a variable
|
||||
|
|
|
|||
Loading…
Reference in a new issue