Skip to content
Snippets Groups Projects

Support feature worker declaration from gitlab.teklia.com

Merged Valentin Rigal requested to merge teklia-workers into release-1.7.1
All threads resolved!
1 file
+ 9
9
Compare changes
  • Side-by-side
  • Inline
@@ -158,7 +158,7 @@ class Command(BaseCommand):
)
self.stdout.write(self.style.SUCCESS(f"Using new worker version {worker_version.id}"))
def check_existing_version(self, worker_version: WorkerVersion, feature: ArkindexFeature, docker_image: str, docker_command: str = None, configuration: dict = {}) -> None:
def check_existing_version(self, worker_version: WorkerVersion, feature: ArkindexFeature, *, docker_image: str, docker_command: str = None, configuration: dict = {}) -> None:
self.stdout.write(f"Current worker version: {worker_version.id} ({worker_version.docker_image_iid})")
valid = True
@@ -209,21 +209,21 @@ class Command(BaseCommand):
self.update_or_create_version(worker, feature, docker_image, docker_command, configuration)
@transaction.atomic
def update_feature(self, feature: ArkindexFeature, config: dict):
self.stdout.write(f"Using {config['image']} to provide {feature.name}")
def update_feature(self, feature: ArkindexFeature, *, image, command, configuration = {}):
self.stdout.write(f"Using {image} to provide {feature.name}")
try:
worker_version = WorkerVersion.objects.get_by_feature(feature)
self.check_existing_version(
worker_version,
feature,
config["image"],
config["command"],
config.get("configuration", {}),
docker_image=image,
docker_command=command,
configuration=configuration
)
except WorkerVersion.DoesNotExist:
worker = self.get_system_worker(feature)
self.update_or_create_version(worker, feature, config["image"], config["command"], config["configuration"])
self.update_or_create_version(worker, feature, image, command, configuration)
def update_feature_from_worker(self, feature, *, name, version, slug):
"""
@@ -248,7 +248,7 @@ class Command(BaseCommand):
raise CommandError(f"No worker with slug {slug} in .arkindex.yml at {url}.")
image = f"registry.gitlab.teklia.com/{name}/{version}"
command = worker_conf.get("command", None)
self.update_feature(feature, {"image": image, "command": command, "configuration": worker_conf})
self.update_feature(feature, image=image, command=command, configuration=worker_conf)
def handle(self, *args, **options):
config = parse_config()
@@ -259,4 +259,4 @@ class Command(BaseCommand):
if worker is not None:
self.update_feature_from_worker(feature, **worker)
else:
self.update_feature(feature, feature_config)
self.update_feature(feature, **feature_config)
Loading