Skip to content

Commit

Permalink
Document new feature
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Aug 5, 2024
1 parent ada5245 commit 04001ca
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docs/code/plugin-introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ standard location under ``tmt/steps`` , from all directories
provided in the ``TMT_PLUGINS`` environment variable and from
``tmt.plugin`` entry point.

.. versionadded:: 1.35
You can use ``tmt.resources`` entry point to inject resource
files to be used for tmt, e.g. schemas or templates. See
:ref:`additional-resources` for more details.


Inheritance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -57,3 +62,48 @@ features which cannot be covered by generic ssh implementation of
the ``Guest`` class.

__ https://github.com/teemtee/tmt/tree/main/examples/plugins

.. additional-resources:
Additional resource files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In order to make resource files available to the base ``tmt``
execution, you need to point a ``tmt.resources`` entry point to the
root python package where the resource files are located from, e.g.
with in the ``examples/plugins``:

.. code-block:: toml
:caption: pyproject.toml
:emphasize-lines: 5,6
[project.entry-points."tmt.plugin"]
ProvisionExample = "example.provision:ProvisionExample"
DiscoverExample = "example.discover:DiscoverExample"
[project.entry-points."tmt.resources"]
ResourcesExample = "example"
you can, for example, add a json schema file for the plugins
implemented above by including the schema files under a ``schemas``
folder:

.. code-block:: shell
$ tree ./example
./example
├── __init__.py
├── discover.py
├── provision.py
└── schemas
├── discover
│ └── example.yaml
└── provision
└── example.yaml
.. note::

Both the entry-point entries as well as any resource file
under the ``tmt.resources`` path **must** have unique names.
Consider namespacing all relevant entries with the name of the
project or an unambiguous derivative of it.
4 changes: 4 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ support for :ref:`cpu.vendor-name</spec/hardware/cpu>` and
The linting of tests, plans and stories has been extended by detecting
duplicate ids.

External plugins can inject additional resources to be used by tmt using
the ``tmt.resources`` entry-point, e.g. to extend the schema validation
or tmt templates.

tmt-1.34
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 04001ca

Please sign in to comment.