1"""
2The thin runner is used to manage the salt thin systems.
3
4Salt Thin is a transport-less version of Salt that can be used to run routines
5in a standalone way. This runner has tools which generate the standalone salt
6system for easy consumption.
7"""
8
9
10import salt.utils.thin
11
12
13def generate(
14    extra_mods="",
15    overwrite=False,
16    so_mods="",
17    absonly=True,
18    compress="gzip",
19):
20    """
21    Generate the salt-thin tarball and print the location of the tarball
22    Optional additional mods to include (e.g. mako) can be supplied as a comma
23    delimited string.  Permits forcing an overwrite of the output file as well.
24
25    CLI Example:
26
27    .. code-block:: bash
28
29        salt-run thin.generate
30        salt-run thin.generate mako
31        salt-run thin.generate mako,wempy 1
32        salt-run thin.generate overwrite=1
33    """
34    conf_mods = __opts__.get("thin_extra_mods")
35    if conf_mods:
36        extra_mods = ",".join([conf_mods, extra_mods])
37
38    return salt.utils.thin.gen_thin(
39        __opts__["cachedir"],
40        extra_mods,
41        overwrite,
42        so_mods,
43        absonly,
44        compress,
45    )
46
47
48def generate_min(
49    extra_mods="",
50    overwrite=False,
51    so_mods="",
52):
53    """
54    Generate the salt-thin tarball and print the location of the tarball
55    Optional additional mods to include (e.g. mako) can be supplied as a comma
56    delimited string.  Permits forcing an overwrite of the output file as well.
57
58    CLI Example:
59
60    .. code-block:: bash
61
62        salt-run thin.generate_min
63    """
64    conf_mods = __opts__.get("min_extra_mods")
65    if conf_mods:
66        extra_mods = ",".join([conf_mods, extra_mods])
67
68    return salt.utils.thin.gen_min(
69        __opts__["cachedir"],
70        extra_mods,
71        overwrite,
72        so_mods,
73    )
74