Merge branch 'hotfix/0.2.1'
This commit is contained in:
commit
48758eff90
6 changed files with 12 additions and 30 deletions
|
@ -2,7 +2,7 @@
|
||||||
# kiwi-scp instance configuration #
|
# kiwi-scp instance configuration #
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
version: 0.2.0
|
version: 0.2.1
|
||||||
|
|
||||||
shells:
|
shells:
|
||||||
- /bin/bash
|
- /bin/bash
|
||||||
|
|
|
@ -164,7 +164,7 @@ class MissingMemberError(ValueError):
|
||||||
class KiwiConfig(BaseModel):
|
class KiwiConfig(BaseModel):
|
||||||
"""represents a kiwi.yml"""
|
"""represents a kiwi.yml"""
|
||||||
|
|
||||||
version: constr(regex=RE_SEMVER) = "0.2.0"
|
version: constr(regex=RE_SEMVER) = "0.2.1"
|
||||||
|
|
||||||
shells: List[Path] = [
|
shells: List[Path] = [
|
||||||
Path("/bin/bash"),
|
Path("/bin/bash"),
|
||||||
|
|
|
@ -32,8 +32,8 @@ class Instance:
|
||||||
return self.directory.joinpath(CONFIG_DIRECTORY_NAME)
|
return self.directory.joinpath(CONFIG_DIRECTORY_NAME)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def storage_config_directory(self):
|
def storage_directory(self):
|
||||||
return self.config.storage.directory.joinpath(CONFIG_DIRECTORY_NAME)
|
return self.config.storage.directory
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __find_net(net_name):
|
def __find_net(net_name):
|
||||||
|
|
|
@ -64,9 +64,7 @@ class Rootkit:
|
||||||
return argument
|
return argument
|
||||||
|
|
||||||
elif isinstance(argument, Path):
|
elif isinstance(argument, Path):
|
||||||
if argument.is_absolute():
|
argument = argument.absolute().relative_to("/")
|
||||||
argument = argument.relative_to("/")
|
|
||||||
|
|
||||||
return str(ROOTKIT_PREFIX.joinpath(argument))
|
return str(ROOTKIT_PREFIX.joinpath(argument))
|
||||||
|
|
||||||
elif not isinstance(argument, Sequence):
|
elif not isinstance(argument, Sequence):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Generator, Optional, TYPE_CHECKING, TypeVar, Union
|
from typing import List, Generator, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
|
@ -44,36 +44,20 @@ class Services:
|
||||||
yield from service.configs
|
yield from service.configs
|
||||||
|
|
||||||
def copy_configs(self) -> None:
|
def copy_configs(self) -> None:
|
||||||
path_str_list = TypeVar("path_str_list", Union[Path, str], List[Union[Path, str]])
|
|
||||||
|
|
||||||
def prefix_path(path: path_str_list, prefix: Path) -> path_str_list:
|
|
||||||
if isinstance(path, Path):
|
|
||||||
return prefix.absolute().joinpath(path)
|
|
||||||
|
|
||||||
elif isinstance(path, str):
|
|
||||||
return prefix_path(Path(path), prefix)
|
|
||||||
|
|
||||||
elif isinstance(path, list):
|
|
||||||
return [prefix_path(p, prefix) for p in path]
|
|
||||||
|
|
||||||
project = self.parent_project
|
project = self.parent_project
|
||||||
|
configs = list(self.configs)
|
||||||
|
|
||||||
if project is None:
|
if project is None or not configs:
|
||||||
return
|
return
|
||||||
|
|
||||||
instance = project.parent_instance
|
instance = project.parent_instance
|
||||||
cfgs = list(self.configs)
|
|
||||||
|
|
||||||
local_cfgs = prefix_path(cfgs, instance.config_directory)
|
|
||||||
storage_cfgs = prefix_path(cfgs, instance.storage_config_directory)
|
|
||||||
storage_dirs = [path.parent for path in storage_cfgs]
|
|
||||||
|
|
||||||
Rootkit("rsync").run([
|
Rootkit("rsync").run([
|
||||||
"mkdir", "-p", storage_dirs
|
"mkdir", "-p", instance.storage_directory
|
||||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
Rootkit("rsync").run([
|
Rootkit("rsync").run([
|
||||||
"rsync", "-rpt", list(zip(local_cfgs, storage_cfgs))
|
"rsync", "-rpt", instance.config_directory, instance.storage_directory
|
||||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "kiwi-scp"
|
name = "kiwi-scp"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
description = "kiwi is the simple tool for managing container servers."
|
description = "kiwi is the simple tool for managing container servers."
|
||||||
authors = ["ldericher <40151420+ldericher@users.noreply.github.com>"]
|
authors = ["ldericher <40151420+ldericher@users.noreply.github.com>"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue