Skip to content
Snippets Groups Projects
Commit 532940c5 authored by Martin Mareš's avatar Martin Mareš
Browse files

Pulling of images of now configurable and overridable in both ways

parent 35f2b956
Branches
No related tags found
No related merge requests found
# Example configuration of a container # Example configuration of a container
# Defaults for some options can be specified in shipcat.toml.
# Image to pull # Container image
image = "registry.ks.matfyz.cz/gimli/web-checker" image = "registry.ks.matfyz.cz/gimli/web-checker"
# Pull the image automatically when creating the container
pull_image = true
# Root directory where data of the container reside # Root directory where data of the container reside
root_dir = "/tmp/root" root_dir = "/tmp/root"
......
...@@ -12,5 +12,8 @@ verbosity = 0 ...@@ -12,5 +12,8 @@ verbosity = 0
# Where to find container root: root_dir/container_name # Where to find container root: root_dir/container_name
root_dir = "/aux/containers" root_dir = "/aux/containers"
# Pull the image automatically when creating the container
pull_image = true
# Do we re-create the container on every start? # Do we re-create the container on every start?
create_on_start = false create_on_start = false
...@@ -20,6 +20,7 @@ class GlobalConfig: ...@@ -20,6 +20,7 @@ class GlobalConfig:
verbosity: int verbosity: int
default_root_path: Path default_root_path: Path
default_create_on_start: bool default_create_on_start: bool
default_pull_image: bool
@classmethod @classmethod
def load(self, filename: str) -> 'GlobalConfig': def load(self, filename: str) -> 'GlobalConfig':
...@@ -47,6 +48,7 @@ class GlobalConfig: ...@@ -47,6 +48,7 @@ class GlobalConfig:
with w['defaults'].enter_object() as d: with w['defaults'].enter_object() as d:
self.default_root_path = Path(d['root_dir'].as_str()) self.default_root_path = Path(d['root_dir'].as_str())
self.default_create_on_start = d['create_on_start'].as_bool(False) self.default_create_on_start = d['create_on_start'].as_bool(False)
self.default_pull_image = d['pull_image'].as_bool(True)
class ContainerConfig: class ContainerConfig:
...@@ -54,6 +56,7 @@ class ContainerConfig: ...@@ -54,6 +56,7 @@ class ContainerConfig:
root_path: Path root_path: Path
data_path: Path data_path: Path
image: str image: str
pull_image: bool
allowed_users: Set[int] allowed_users: Set[int]
allowed_groups: Set[int] allowed_groups: Set[int]
create_on_start: bool create_on_start: bool
...@@ -99,6 +102,7 @@ class ContainerConfig: ...@@ -99,6 +102,7 @@ class ContainerConfig:
self.data_path = self.root_path / 'data' self.data_path = self.root_path / 'data'
self.image = w['image'].as_str() self.image = w['image'].as_str()
self.pull_image = w['pull_image'].as_bool(self.global_config.default_pull_image)
self.allowed_users = set() self.allowed_users = set()
for wu in w['allowed_users'].default_to([]).array_values(): for wu in w['allowed_users'].default_to([]).array_values():
......
...@@ -192,7 +192,12 @@ def service_action(cc: ContainerConfig, action: str) -> None: ...@@ -192,7 +192,12 @@ def service_action(cc: ContainerConfig, action: str) -> None:
def cmd_update(args: argparse.Namespace) -> None: def cmd_update(args: argparse.Namespace) -> None:
cc = setup_container(args, False) cc = setup_container(args, False)
if not args.no_pull: if args.pull is not None:
should_pull = args.pull
else:
should_pull = cc.pull_image
if should_pull:
progress('Pulling new image') progress('Pulling new image')
run_command( run_command(
['podman', 'pull', cc.image] ['podman', 'pull', cc.image]
...@@ -441,7 +446,7 @@ def main() -> None: ...@@ -441,7 +446,7 @@ def main() -> None:
update_parser = subparsers.add_parser('update', help='update a container from an image', description='Update a container from an image and start it.') update_parser = subparsers.add_parser('update', help='update a container from an image', description='Update a container from an image and start it.')
update_parser.add_argument('name', help='name of the container') update_parser.add_argument('name', help='name of the container')
update_parser.add_argument('--no-pull', default=False, action='store_true', help='do not pull a new image') update_parser.add_argument('--pull', action=argparse.BooleanOptionalAction, help='pull a new image (use --pull or --no-pull to override behavior specified by container config) ')
args = parser.parse_args() args = parser.parse_args()
get_caller_credentials() get_caller_credentials()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment