Skip to content

Commit

Permalink
Remove no longer necessary workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaxy102 committed Nov 14, 2022
1 parent a1262ba commit 3b7eed2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions autocompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def render(struct, args, networks, volumes):
if args.version == 1:
pyaml.p(OrderedDict(struct))
else:
ans = {"version": '"3.6"', "services": struct}
ans = {"version": '3.6', "services": struct}

if networks is not None:
ans["networks"] = networks
Expand All @@ -128,20 +128,6 @@ def render(struct, args, networks, volumes):
pyaml.p(OrderedDict(ans), string_val_style='"')


def is_date_or_time(s: str):
for parse_func in [datetime.date.fromisoformat, datetime.datetime.fromisoformat]:
try:
parse_func(s.rstrip("Z"))
return True
except ValueError:
pass
return False


def fix_label(label: str):
return f"'{label}'" if is_date_or_time(label) else label


def generate(cname, createvolumes=False):
c = docker.from_env()

Expand Down Expand Up @@ -171,7 +157,7 @@ def generate(cname, createvolumes=False):
"environment": cattrs.get("Config", {}).get("Env", None),
"extra_hosts": cattrs.get("HostConfig", {}).get("ExtraHosts", None),
"image": cattrs.get("Config", {}).get("Image", None),
"labels": {label: fix_label(value) for label, value in cattrs.get("Config", {}).get("Labels", {}).items()},
"labels": cattrs.get("Config", {}).get("Labels", {}),
"links": cattrs.get("HostConfig", {}).get("Links"),
#'log_driver': cattrs.get('HostConfig']['LogConfig']['Type'],
#'log_opt': cattrs.get('HostConfig']['LogConfig']['Config'],
Expand Down

0 comments on commit 3b7eed2

Please sign in to comment.