chore: Update template

This commit is contained in:
jeanluc
2023-04-11 09:52:38 +02:00
parent 5af9a75618
commit 1af36c6f21
18 changed files with 164 additions and 76 deletions

View File

@@ -1,6 +1,6 @@
{ {
"template": "https://github.com/lkubb/salt-template-formula", "template": "https://github.com/lkubb/salt-template-formula",
"commit": "c33be7342f32db2e215f929e5a51a690ed445c11", "commit": "a63c03d95375f235c2d4a6159a26ae48d4fdc40b",
"checkout": null, "checkout": null,
"context": { "context": {
"cookiecutter": { "cookiecutter": {
@@ -25,7 +25,7 @@
"subcomponent": "", "subcomponent": "",
"subcomponent_config": "", "subcomponent_config": "",
"git_username": "lkubb", "git_username": "lkubb",
"_lookup": { "lookup": {
"paths": { "paths": {
"bin": "/opt/gitea", "bin": "/opt/gitea",
"conf": "/etc/gitea", "conf": "/etc/gitea",
@@ -75,7 +75,7 @@
"path": "/usr/local/bin/grst" "path": "/usr/local/bin/grst"
} }
}, },
"_settings": { "settings": {
"version": "latest", "version": "latest",
"service": { "service": {
"requires_mount": [], "requires_mount": [],

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
name: Commitlint name: Commitlint

View File

@@ -52,7 +52,7 @@ repos:
always_run: true always_run: true
pass_filenames: false pass_filenames: false
- repo: https://github.com/warpnet/salt-lint - repo: https://github.com/warpnet/salt-lint
rev: v0.8.0 rev: v0.9.2
hooks: hooks:
- id: salt-lint - id: salt-lint
name: Check Salt files using salt-lint name: Check Salt files using salt-lint

View File

@@ -102,7 +102,26 @@ class State:
self.comment = str(comment) self.comment = str(comment)
self.formula_root = formula_root self.formula_root = formula_root
def to_state_id(self, include_init=True, relative_to="", split=False, formula_root=False): def to_state_id(
self, include_init=True, relative_to="", split=False, formula_root=False
):
"""
Return this state's state ID.
include_init
If False, remove ``.init`` suffix. Defaults to True.
relative_to
Render the state ID relative to another state or file.
split
Return a tuple of parts instead of a string.
formula_root
If not using relative_to, include the formula's root
directory in the state ID (the actually correct one).
Defaults to False (for compatibility reasons).
"""
ret = self.path.with_suffix("") ret = self.path.with_suffix("")
if not include_init and ret.parts[-1] == "init": if not include_init and ret.parts[-1] == "init":
@@ -120,9 +139,15 @@ class State:
return tuple(ret.split(".")) return tuple(ret.split("."))
def is_init(self): def is_init(self):
"""
Checks whether this is an ``.init`` state.
"""
return self.path.parts[-1] == "init.sls" return self.path.parts[-1] == "init.sls"
def is_clean(self): def is_clean(self):
"""
Checks whether this is a ``.clean`` state.
"""
return self.path.parts[-1] == "clean.sls" return self.path.parts[-1] == "clean.sls"
def __str__(self): def __str__(self):
@@ -141,9 +166,17 @@ class StateRegistry:
by some of the downstream classes. by some of the downstream classes.
""" """
def __init__(self, reg=None, states=None, prefixes=None, default_sort_fn=None, avoid_init_dup=True, sort_list=None): def __init__(
self,
data=None,
states=None,
prefixes=None,
default_sort_fn=None,
avoid_init_dup=True,
sort_list=None,
):
# nested dict # nested dict
self.reg = reg or {} self.reg = data or {}
# flat dict with ptr to reg # flat dict with ptr to reg
self.states = states or {} self.states = states or {}
# flat dict with ptr to reg # flat dict with ptr to reg
@@ -152,7 +185,9 @@ class StateRegistry:
# ensure no prefix lists the root # ensure no prefix lists the root
self.prefixes[()] = self.reg self.prefixes[()] = self.reg
self.avoid_init_dup = avoid_init_dup self.avoid_init_dup = avoid_init_dup
self.sort_list = tuple(sort_list or ("init", "clean", "package", "config", "service")) self.sort_list = tuple(
sort_list or ("init", "clean", "package", "config", "service")
)
def _default_sort(self, a): def _default_sort(self, a):
""" """
@@ -192,12 +227,15 @@ class StateRegistry:
if isinstance(ptr, State) or tree: if isinstance(ptr, State) or tree:
return ptr return ptr
# map init.sls same way as salt does # map init.sls same way as salt does
elif "init" in ptr: if "init" in ptr:
return ptr["init"] return ptr["init"]
raise ValueError("State could not be found. Most likely, this is a prefix.") raise ValueError("State could not be found. Most likely, this is a prefix.")
def register(self, state): def register(self, state):
"""
Register a state object.
"""
try: try:
state_id = state.to_state_id(split=True) state_id = state.to_state_id(split=True)
except AttributeError as err: except AttributeError as err:
@@ -214,13 +252,16 @@ class StateRegistry:
ptr[cur] = state ptr[cur] = state
break break
# make sure subdicts are initialized # make sure subdicts are initialized
elif cur not in ptr: if cur not in ptr:
ptr[cur] = {} ptr[cur] = {}
self.prefixes[tuple(prefix)] = ptr[cur] self.prefixes[tuple(prefix)] = ptr[cur]
ptr = ptr[cur] ptr = ptr[cur]
self.states[state_id] = ptr[cur] self.states[state_id] = ptr[cur]
def unregister(self, state): def unregister(self, state):
"""
Unregister a state object.
"""
try: try:
state_id = state.to_state_id(split=True) state_id = state.to_state_id(split=True)
except AttributeError as err: except AttributeError as err:
@@ -259,6 +300,9 @@ class StateRegistry:
return 0 return 0
def count(self): def count(self):
"""
Return the number of registered states.
"""
return len(self.states) return len(self.states)
def dump(self, prefix=None, sort_fn=None): def dump(self, prefix=None, sort_fn=None):
@@ -269,7 +313,7 @@ class StateRegistry:
if isinstance(prefix, str): if isinstance(prefix, str):
prefix = tuple(prefix.split(".")) prefix = tuple(prefix.split("."))
for state_id in sorted(self.states, key=sort_fn or self.default_sort_fn): for state_id in sorted(self.states, key=sort_fn or self.default_sort_fn):
if state_id[:len(prefix)] == prefix: if state_id[: len(prefix)] == prefix:
if self.avoid_init_dup and state_id[-1] not in ["init", "clean"]: if self.avoid_init_dup and state_id[-1] not in ["init", "clean"]:
# given package.init, package.install and package.clean, # given package.init, package.install and package.clean,
# only dump init and clean # only dump init and clean
@@ -318,7 +362,8 @@ The following states are found in {where}:
""" """
if not hasattr(self, "f"): if not hasattr(self, "f"):
raise ValueError( raise ValueError(
"Sorry, you need to set self.f to a file pointer before calling self._write methods." "Sorry, you need to set self.f to a file pointer "
"before calling self._write methods."
) )
self.f.write(text + "\n" * ncount) self.f.write(text + "\n" * ncount)
@@ -373,10 +418,12 @@ The following states are found in {where}:
Returns a string to be used as the main description (after the main header). Returns a string to be used as the main description (after the main header).
Looks up in the following order: Looks up in the following order:
1. If there is a documented root init.sls, return everything but its first line. 1. If there is a documented root init.sls, return everything but its first line.
If it was found, unregister it to not render it twice (bad form again, maybe consider was_rendered on State) If it was found, unregister it to not render it twice
(bad form again, maybe consider was_rendered on State)
2. If a description was specified in opts, return that. 2. If a description was specified in opts, return that.
3. general description 3. general description
""" """
def get_default_desc(): def get_default_desc():
return self.opts["default_description"].format( return self.opts["default_description"].format(
where=".".join(self.prefix) if self.prefix else "this formula" where=".".join(self.prefix) if self.prefix else "this formula"
@@ -433,11 +480,18 @@ class SingleRenderer(Renderer):
"include_formula_root": True, "include_formula_root": True,
} }
def __init__(self, target="docs/states.rst", prefix=None, basedir=base_dir, **kwargs): def __init__(
self, target="docs/states.rst", prefix=None, basedir=base_dir, **kwargs
):
if isinstance(target, str): if isinstance(target, str):
target = Path(target) target = Path(target)
target = target.with_suffix(".rst") target = target.with_suffix(".rst")
super().__init__(target=target, prefix=prefix, basedir=basedir, opts=self.default_opts | kwargs) super().__init__(
target=target,
prefix=prefix,
basedir=basedir,
opts=self.default_opts | kwargs,
)
def render(self, states): def render(self, states):
relative_to = "/".join(self.prefix) if self.opts["cut_prefix"] else "" relative_to = "/".join(self.prefix) if self.opts["cut_prefix"] else ""
@@ -452,11 +506,19 @@ class SingleRenderer(Renderer):
continue continue
if not self.opts["clean"] and state.is_clean(): if not self.opts["clean"] and state.is_clean():
continue continue
state_id = state.to_state_id(self.opts["init_suffix"], relative_to, formula_root=self.opts["include_formula_root"]) state_id = state.to_state_id(
self.opts["init_suffix"],
relative_to,
formula_root=self.opts["include_formula_root"],
)
if state_id == ".": if state_id == ".":
continue continue
self._write_heading( self._write_heading(
state.to_state_id(self.opts["init_suffix"], relative_to, formula_root=self.opts["include_formula_root"]) state.to_state_id(
self.opts["init_suffix"],
relative_to,
formula_root=self.opts["include_formula_root"],
)
) )
self._write(state.comment, 3) self._write(state.comment, 3)
@@ -499,13 +561,22 @@ class DepthRenderer(Renderer):
"clean": False, "clean": False,
"cut_prefix": True, "cut_prefix": True,
"include_formula_root": False, "include_formula_root": False,
} },
} }
def __init__(self, max_depth=1, target="docs/states", delegate_cls=None, basedir=base_dir, **kwargs): def __init__(
self,
max_depth=1,
target="docs/states",
delegate_cls=None,
basedir=base_dir,
**kwargs,
):
self.max_depth = max_depth self.max_depth = max_depth
self.delegate = delegate_cls or SingleRenderer self.delegate = delegate_cls or SingleRenderer
super().__init__(target=target, basedir=basedir, opts=self.default_opts | (kwargs or {})) super().__init__(
target=target, basedir=basedir, opts=self.default_opts | (kwargs or {})
)
def render(self, states): def render(self, states):
found = [] found = []
@@ -519,9 +590,8 @@ class DepthRenderer(Renderer):
# This also goes not too well with rendering clean states # This also goes not too well with rendering clean states
# by default since they will be separate. # by default since they will be separate.
if cur_top: if cur_top:
if prefix[:len(cur_top)] == cur_top: if prefix[: len(cur_top)] == cur_top:
continue continue
else:
cur_top = () cur_top = ()
if states.depth(prefix) <= self.max_depth: if states.depth(prefix) <= self.max_depth:
found.append(prefix) found.append(prefix)
@@ -560,8 +630,10 @@ class DepthRenderer(Renderer):
def _render_single(self, states, prefix): def _render_single(self, states, prefix):
target = self._get_target(prefix) target = self._get_target(prefix)
renderer = self.delegate(target=target, prefix=prefix, **self.opts["single_opts"]) rendr = self.delegate(
renderer.render(states) target=target, prefix=prefix, **self.opts["single_opts"]
)
rendr.render(states)
def _render_index(self, states, indices, prefix=None): def _render_index(self, states, indices, prefix=None):
prefix = prefix or () prefix = prefix or ()
@@ -571,12 +643,14 @@ class DepthRenderer(Renderer):
self.prefix = prefix self.prefix = prefix
self._write_header(states) self._write_header(states)
self.prefix = () self.prefix = ()
f.write(f""" f.write(
f"""
.. toctree:: .. toctree::
:maxdepth: {self.opts['index_maxdepth']} :maxdepth: {self.opts['index_maxdepth']}
:caption: Contents: :caption: Contents:
""") """
)
for s in sorted(indices["_index"]): for s in sorted(indices["_index"]):
f.write(" " + s + "\n") f.write(" " + s + "\n")
for sub in sorted(indices): for sub in sorted(indices):
@@ -605,7 +679,15 @@ class SaltAutodoc:
SKIP_FILE = "@internal" SKIP_FILE = "@internal"
def __init__(self, base=None, renderer=None, registry=None, env=None, include_empty=False, ignore=None): def __init__(
self,
base=None,
rendr=None,
registry=None,
env=None,
include_empty=False,
ignore=None,
):
""" """
base: base path containing Salt states to autodocument base: base path containing Salt states to autodocument
renderer: renderer to use for rendering renderer: renderer to use for rendering
@@ -613,7 +695,7 @@ class SaltAutodoc:
if base is None: if base is None:
base = list(base_dir.glob("*/init.sls"))[0].parent base = list(base_dir.glob("*/init.sls"))[0].parent
self.base = base self.base = base
self.renderer = renderer or SingleRenderer() self.renderer = rendr or SingleRenderer()
self.env = env or Environment() self.env = env or Environment()
self.registry = registry or StateRegistry() self.registry = registry or StateRegistry()
self.include_empty = include_empty self.include_empty = include_empty
@@ -633,12 +715,14 @@ class SaltAutodoc:
text = "".join(f.readlines()) text = "".join(f.readlines())
try: try:
comment = self.find_comment(text) comment = self.find_comment(text)
except TemplateSyntaxError as e: except TemplateSyntaxError as err:
raise RuntimeError( raise RuntimeError(
f"There was an error parsing the Jinja syntax in file '{file}':\n\n{e}" f"There was an error parsing the Jinja syntax in file '{file}':\n\n{err}"
) ) from err
if (comment or self.include_empty) and not comment.startswith(self.SKIP_FILE): if (comment or self.include_empty) and not comment.startswith(
self.SKIP_FILE
):
path = file.relative_to(self.base) path = file.relative_to(self.base)
self.registry.register(State(path, comment, self.base.name)) self.registry.register(State(path, comment, self.base.name))
@@ -676,12 +760,16 @@ class SaltAutodoc:
docutils.prepare_docstring. docutils.prepare_docstring.
""" """
# return d.prepare_docstring(comment) # return d.prepare_docstring(comment)
ws = min([len(x) - len(x.lstrip()) for x in comment.splitlines() if len(x) > 0]) ws = min(len(x) - len(x.lstrip()) for x in comment.splitlines() if len(x) > 0)
return "\n".join([x[ws:] for x in comment.splitlines()]).strip("\n") return "\n".join([x[ws:] for x in comment.splitlines()]).strip("\n")
if __name__ == "__main__": if __name__ == "__main__":
options = toml.loads((base_dir / "pyproject.toml").read_text()).get("tool", {}).get("slsdoc", {}) options = (
toml.loads((base_dir / "pyproject.toml").read_text())
.get("tool", {})
.get("slsdoc", {})
)
renderer = options.get("renderer", "single") renderer = options.get("renderer", "single")
if renderer == "single": if renderer == "single":
@@ -691,6 +779,14 @@ if __name__ == "__main__":
else: else:
raise ValueError(f"Invalid value for renderer: {renderer}") raise ValueError(f"Invalid value for renderer: {renderer}")
registry = StateRegistry(avoid_init_dup=options.get("avoid_init_dup", True), sort_list=options.get("sort_list")) reg = StateRegistry(
doc = SaltAutodoc(renderer=rend, registry=registry, include_empty=options.get("include_empty", False), ignore=options.get("ignore", ["_mapdata"])) avoid_init_dup=options.get("avoid_init_dup", True),
sort_list=options.get("sort_list"),
)
doc = SaltAutodoc(
rendr=rend,
registry=reg,
include_empty=options.get("include_empty", False),
ignore=options.get("ignore", ["_mapdata"]),
)
doc.run() doc.run()

View File

@@ -474,7 +474,6 @@ Here is an example based on `template-formula/gitea/config/file.sls`_:
.. code-block:: sls .. code-block:: sls
# -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #} {#- Get the `tplroot` from `tpldir` #}

View File

@@ -4,8 +4,8 @@
Removes Gitea configuration. Has a dependency on `gitea.service.clean`_. Removes Gitea configuration. Has a dependency on `gitea.service.clean`_.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- set sls_service_clean = tplroot ~ ".service.clean" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
include: include:

View File

@@ -1,7 +1,7 @@
# vim: ft=sls # vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %} {%- set sls_package_install = tplroot ~ ".package.install" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}

View File

@@ -4,8 +4,8 @@
Removes the build user and Go installation. Removes the build user and Go installation.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ ".config.file" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
Go is absent for build user: Go is absent for build user:

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- {#-
@@ -6,8 +5,8 @@
Required for building Chroma. Required for building Chroma.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ ".config.file" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
Gitea build user is present: Gitea build user is present:

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- {#-
@@ -6,8 +5,8 @@
``grst`` script. ``grst`` script.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ ".config.file" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- {#-
@@ -9,9 +8,9 @@
Has a dependency on `gitea.go`_. Has a dependency on `gitea.go`_.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ ".config.file" %}
{%- set sls_go_install = tplroot ~ '.go' %} {%- set sls_go_install = tplroot ~ ".go" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
@@ -60,9 +59,9 @@ Chroma is installed:
RST external renderer is installed: RST external renderer is installed:
file.managed: file.managed:
- name: {{ gitea.lookup.mod_rst.path }} - name: {{ gitea.lookup.mod_rst.path }}
- source: {{ files_switch(['grst'], - source: {{ files_switch(["grst"],
use_subpath=True, use_subpath=True,
lookup='RST external renderer is installed' lookup="RST external renderer is installed"
) )
}} }}
- mode: '0755' - mode: '0755'

View File

@@ -5,8 +5,8 @@
Has a dependency on `gitea.config.clean`_. Has a dependency on `gitea.config.clean`_.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_config_clean = tplroot ~ '.config.clean' %} {%- set sls_config_clean = tplroot ~ ".config.clean" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
include: include:
@@ -17,8 +17,8 @@ Gitea package files are absent:
file.absent: file.absent:
- names: - names:
- {{ gitea.lookup.service.unit.format(name=gitea.lookup.service.name) }} - {{ gitea.lookup.service.unit.format(name=gitea.lookup.service.name) }}
- {{ gitea.lookup.paths.bin | path_join('gitea') }} - {{ gitea.lookup.paths.bin | path_join("gitea") }}
{%- for p in ['conf', 'custom', 'log'] %} {%- for p in ["conf", "custom", "log"] %}
- {{ gitea.lookup.paths[p] }} - {{ gitea.lookup.paths[p] }}
{%- endfor %} {%- endfor %}
# to make sure this can be installed again (onchanges req in package.installed) # to make sure this can be installed again (onchanges req in package.installed)

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
@@ -112,7 +111,7 @@ Gitea binary is absent if verification failed:
Gitea directories are setup: Gitea directories are setup:
file.directory: file.directory:
- names: - names:
{%- for p in ['conf', 'work', 'custom', 'data', 'log', 'repos'] %} {%- for p in ["conf", "work", "custom", "data", "log", "repos"] %}
- {{ gitea.lookup.paths[p] }} - {{ gitea.lookup.paths[p] }}
{%- endfor %} {%- endfor %}
- makedirs: true - makedirs: true
@@ -123,7 +122,7 @@ Gitea directories are setup:
Gitea binary is installed: Gitea binary is installed:
file.copy: file.copy:
- name: {{ gitea.lookup.paths.bin | path_join('gitea') }} - name: {{ gitea.lookup.paths.bin | path_join("gitea") }}
- source: /tmp/gitea-{{ gitea.version }} - source: /tmp/gitea-{{ gitea.version }}
# in case the version changed, overwrite previous binary # in case the version changed, overwrite previous binary
- force: true - force: true
@@ -141,15 +140,15 @@ Gitea service unit is available:
file.managed: file.managed:
- name: {{ gitea.lookup.service.unit.format(name=gitea.lookup.service.name) }} - name: {{ gitea.lookup.service.unit.format(name=gitea.lookup.service.name) }}
- source: {{ files_switch( - source: {{ files_switch(
['gitea.service.j2'], ["gitea.service.j2"],
lookup='Gitea service unit is available', lookup="Gitea service unit is available",
) }} ) }}
- template: jinja - template: jinja
- mode: '0644' - mode: '0644'
- user: root - user: root
- group: {{ gitea.lookup.rootgroup }} - group: {{ gitea.lookup.rootgroup }}
- makedirs: true - makedirs: true
- context: {{ {'gitea': gitea} | json }} - context: {{ {"gitea": gitea} | json }}
- require: - require:
- Gitea binary is installed - Gitea binary is installed
{%- if 'systemctl' | which %} {%- if 'systemctl' | which %}

View File

@@ -1,4 +1,3 @@
{#- -*- coding: utf-8 -*- #}
{#- vim: ft=jinja #} {#- vim: ft=jinja #}
{#- If latest was specified, query the official download server for the latest version. -#} {#- If latest was specified, query the official download server for the latest version. -#}

View File

@@ -4,10 +4,10 @@
Stops the gitea service and disables it at boot time. Stops the gitea service and disables it at boot time.
#} #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
Gitea is dead: Gitea is dead:
service.dead: service.dead:
- name: {{ gitea.lookup.service.name }} - name: {{ gitea.lookup.service.name }}
- enable: False - enable: false

View File

@@ -1,7 +1,7 @@
# vim: ft=sls # vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split("/")[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_file = tplroot ~ ".config.file" %}
{%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %} {%- from tplroot ~ "/map.jinja" import mapdata as gitea with context %}
include: include:
@@ -10,7 +10,7 @@ include:
Gitea is running: Gitea is running:
service.running: service.running:
- name: {{ gitea.lookup.service.name }} - name: {{ gitea.lookup.service.name }}
- enable: True - enable: true
- watch: - watch:
- sls: {{ sls_config_file }} - sls: {{ sls_config_file }}
- Gitea binary is installed - Gitea binary is installed

View File

@@ -139,6 +139,6 @@ gitea:
# The entries under `source_files` are prepended to the default source files # The entries under `source_files` are prepended to the default source files
# given for the state # given for the state
source_files: source_files:
gitea-config-file-file-managed: Gitea configuration is managed:
- 'app_alt.ini' - 'app_alt.ini'
- 'app_alt.ini.jinja' - 'app_alt.ini.jinja'

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
--- ---
name: default name: default