Пример #1
0
 def run_workflow(self, workflow: str) -> None:
     with cd(self._path):
         try:
             workflow_ = self._workflows[workflow]
         except KeyError:
             raise UnknownItem("workflow", workflow, self._workflows.names())
         workflow_.run(self, None)
Пример #2
0
def down(composition: str) -> None:
    comp = Composition.find(composition)
    if comp is not None:
        comp.down()
    else:
        raise UnknownItem("composition", comp,
                          Composition.known_compositions())
Пример #3
0
 def run(self, comp: Composition) -> None:
     try:
         comp.workflow(self._workflow).run(comp)
     except KeyError:
         raise UnknownItem(
             f"workflow in {comp.name}",
             self._workflow,
             (w.name for w in comp.workflows()),
         )
Пример #4
0
 def run(self, comp: Composition, workflow: Workflow) -> None:
     try:
         # Run the specified workflow with the context of the parent workflow
         sub_workflow = comp.workflow(self._workflow)
         sub_workflow.run(comp, workflow)
     except KeyError:
         raise UnknownItem(
             f"workflow in {comp.name}",
             self._workflow,
             (w.name for w in comp.workflows()),
         )
Пример #5
0
    def find(cls, comp: str) -> "Composition":
        """Try to find a configured comp

        Raises:
            `UnknownItem`: if the composition cannot be discovered
        """
        if cls._demos is None:
            cls._demos = cls.load()
        try:
            return cls._demos[comp]
        except KeyError:
            raise UnknownItem("composition", comp, Composition.known_compositions())
Пример #6
0
def nuke(composition: str) -> None:
    """Destroy everything docker, stopping composition before trying"""
    comp = Composition.find(composition)
    if comp is not None:
        comp.down()
        cmds = [
            "docker system prune -af".split(),
            "docker volume prune -f".split()
        ]
        for cmd in cmds:
            spawn.runv(cmd, capture_output=True)
    else:
        raise UnknownItem("composition", comp,
                          Composition.known_compositions())
Пример #7
0
def run(duration: int, composition: str, tag: str,
        workflow: Optional[str]) -> None:
    """Conduct a docker-composed set of services

    With the --workflow flag, perform all the steps in the workflow together.
    """
    comp = Composition.find(composition)
    if comp is not None:
        if workflow is not None:
            say(f"Executing {comp.name} -> {workflow}")
            comp.run_workflow(workflow)
        else:
            say(f"Starting {comp.name}")
            comp.run()
    else:
        raise UnknownItem("composition", composition,
                          Composition.known_compositions())
Пример #8
0
 def named(cls, name: str) -> Type["WorkflowStep"]:
     try:
         return cls._steps[name]
     except KeyError:
         raise UnknownItem("step", name, list(cls._steps))