This commit is contained in:
2025-11-30 13:20:47 +01:00
parent 0420f90ac8
commit ce5765ed78
2 changed files with 40 additions and 29 deletions

View File

@@ -23,40 +23,51 @@ def convert_service(service):
deploy_section = default_deploy()
for key, value in service.items():
#print(key, value)
# Unsupported in Swarm
if key in ["container_name", "restart", "depends_on"]:
continue
# Move labels → deploy.labels
#print(f"Labels: {deploy_section['labels']}")
if key == "labels":
input(f"Key: {key} Value: {value}")
#print("Processing Labels:")
if isinstance(value, dict):
deploy_section["labels"].update(value)
deploy_section["labels"].update({k: str(v).lower() for k, v in value.items()})
elif isinstance(value, list):
for item in value:
if "=" in item:
k, v = item.split("=", 1)
deploy_section["labels"][k] = v
deploy_section["labels"][k] = str(v).lower()
continue
swarm_service[key] = value
print(swarm_service['environment'])
for en in swarm_service['environment']:
#print(f"Environment Variable: {en} : {swarm_service['environment'][en]}")
swarm_service['environment'][en] = str(swarm_service['environment'][en]).lower()
#print("Deploy Section:")
#print(swarm_service)
# Merge user deploy section if present
#input(service)
if "deploy" in service:
user_deploy = service["deploy"]
#print("User Deploy Section:")
# merge deploy.labels
if "labels" in user_deploy:
##print("User Deploy Labels:")
labels = user_deploy["labels"]
if isinstance(labels, dict):
deploy_section["labels"].update(labels)
elif isinstance(labels, list):
for item in labels:
#print(f"Label Item: {item}")
if "=" in item:
k, v = item.split("=", 1)
deploy_section["labels"][k] = v
deploy_section["labels"][k] = str(v).lower()
# merge placement constraints
if "placement" in user_deploy: