cmds.secrets: Make commands work remotely
The "secrets" class of commands currently only works on the host it's invoked on. Use the current FileContext to allow using the existing commands on a target host. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
3cf5b2264e
commit
1b821f3b3f
5 changed files with 299 additions and 287 deletions
|
|
@ -3,35 +3,41 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from functools import cached_property
|
||||
|
||||
from ..Cmd import Cmd as Base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Iterable
|
||||
from ...lib.Distro import Distro
|
||||
from ...lib.ExecContext import ExecContext
|
||||
from ..CmdDistro import CmdDistro
|
||||
|
||||
from .lib.util import *
|
||||
from .lib.DistroContext import DistroContext
|
||||
|
||||
class Cmd(Base): # export
|
||||
|
||||
@cached_property
|
||||
def ctx(self) -> ExecContext:
|
||||
return DistroContext(self.app.distro)
|
||||
|
||||
async def _match_files(self, packages: Iterable[str], pattern: str) -> list[str]:
|
||||
return await match_files(self.distro, packages, pattern)
|
||||
return await self.ctx.match_files(packages, pattern)
|
||||
|
||||
async def _list_template_files(self, packages: Iterable[str]) -> list[str]:
|
||||
return await list_template_files(self.distro, packages)
|
||||
return await self.ctx.list_template_files(packages)
|
||||
|
||||
async def _list_secret_paths(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]:
|
||||
return await list_secret_paths(self.distro, packages, ignore_missing)
|
||||
return await self.ctx.list_secret_paths(packages, ignore_missing)
|
||||
|
||||
async def _list_compilation_targets(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]:
|
||||
return await list_compilation_targets(self.distro, packages, ignore_missing)
|
||||
return await self.ctx.list_compilation_targets(packages, ignore_missing)
|
||||
|
||||
async def _remove_compilation_targets(self, packages: Iterable[str]) -> list[str]:
|
||||
return await remove_compilation_targets(self.distro, packages)
|
||||
return await self.ctx.remove_compilation_targets(packages)
|
||||
|
||||
async def _compile_template_files(self, packages: Iterable[str], default_attrs: Attrs) -> list[str]:
|
||||
return await compile_template_files(self.distro, packages, default_attrs)
|
||||
return await self.ctx.compile_template_files(packages, default_attrs)
|
||||
|
||||
def __init__(self, parent: CmdDistro, name: str, help: str) -> None:
|
||||
super().__init__(parent, name, help)
|
||||
|
|
|
|||
Loading…
Reference in a new issue