Repository: gabrieldemarmiesse/python-on-whales (language: python)

Issue:
Error parsing extra_hosts
When wrapping a container that has extra_hosts defined, a parser error is thrown because the expected return is `extra_hosts: Optional[Dict[str, str]]` but the actual return is a list of `"host:ip"` strings 


Discussion / hints:
Thank you for the bug report! I'll look into it

Fix patch:
diff --git a/python_on_whales/components/container/models.py b/python_on_whales/components/container/models.py
index ee36952f..edba0a26 100644
--- a/python_on_whales/components/container/models.py
+++ b/python_on_whales/components/container/models.py
@@ -158,7 +158,7 @@ class ContainerHostConfig(DockerCamelModel):
     dns: Optional[List[str]]
     dns_options: Optional[List[str]]
     dns_search: Optional[List[str]]
-    extra_hosts: Optional[Dict[str, str]]
+    extra_hosts: Optional[List[str]]
     group_add: Optional[List[str]]
     ipc_mode: str
     cgroup: Optional[str]


Test patch:
diff --git a/tests/python_on_whales/components/jsons/containers/17.json b/tests/python_on_whales/components/jsons/containers/17.json
new file mode 100644
index 00000000..69d4431c
--- /dev/null
+++ b/tests/python_on_whales/components/jsons/containers/17.json
@@ -0,0 +1,199 @@
+{
+    "Id": "56072241b290aba129dbbb112256ede680177cff9bdbbbd929341ef25435aeb2",
+    "Created": "2021-05-28T08:19:00.7154563Z",
+    "Path": "sleep",
+    "Args": [
+        "infinity"
+    ],
+    "State": {
+        "Status": "running",
+        "Running": true,
+        "Paused": false,
+        "Restarting": false,
+        "OOMKilled": false,
+        "Dead": false,
+        "Pid": 23421,
+        "ExitCode": 0,
+        "Error": "",
+        "StartedAt": "2021-05-28T08:19:01.0964207Z",
+        "FinishedAt": "0001-01-01T00:00:00Z"
+    },
+    "Image": "sha256:7e0aa2d69a153215c790488ed1fcec162015e973e49962d438e18249d16fa9bd",
+    "ResolvConfPath": "/var/lib/docker/containers/56072241b290aba129dbbb112256ede680177cff9bdbbbd929341ef25435aeb2/resolv.conf",
+    "HostnamePath": "/var/lib/docker/containers/56072241b290aba129dbbb112256ede680177cff9bdbbbd929341ef25435aeb2/hostname",
+    "HostsPath": "/var/lib/docker/containers/56072241b290aba129dbbb112256ede680177cff9bdbbbd929341ef25435aeb2/hosts",
+    "LogPath": "/var/lib/docker/containers/56072241b290aba129dbbb112256ede680177cff9bdbbbd929341ef25435aeb2/56072241b290aba129dbbb112256ede680177cff9bdbbbd929341ef25435aeb2-json.log",
+    "Name": "/objective_blackburn",
+    "RestartCount": 0,
+    "Driver": "overlay2",
+    "Platform": "linux",
+    "MountLabel": "",
+    "ProcessLabel": "",
+    "AppArmorProfile": "",
+    "ExecIDs": null,
+    "HostConfig": {
+        "Binds": null,
+        "ContainerIDFile": "",
+        "LogConfig": {
+            "Type": "json-file",
+            "Config": {}
+        },
+        "NetworkMode": "default",
+        "PortBindings": {},
+        "RestartPolicy": {
+            "Name": "no",
+            "MaximumRetryCount": 0
+        },
+        "AutoRemove": true,
+        "VolumeDriver": "",
+        "VolumesFrom": null,
+        "CapAdd": null,
+        "CapDrop": null,
+        "CgroupnsMode": "host",
+        "Dns": [],
+        "DnsOptions": [],
+        "DnsSearch": [],
+        "ExtraHosts": [
+            "dodo:8.8.8.8"
+        ],
+        "GroupAdd": null,
+        "IpcMode": "private",
+        "Cgroup": "",
+        "Links": null,
+        "OomScoreAdj": 0,
+        "PidMode": "",
+        "Privileged": false,
+        "PublishAllPorts": false,
+        "ReadonlyRootfs": false,
+        "SecurityOpt": null,
+        "UTSMode": "",
+        "UsernsMode": "",
+        "ShmSize": 67108864,
+        "Runtime": "runc",
+        "ConsoleSize": [
+            0,
+            0
+        ],
+        "Isolation": "",
+        "CpuShares": 0,
+        "Memory": 0,
+        "NanoCpus": 0,
+        "CgroupParent": "",
+        "BlkioWeight": 0,
+        "BlkioWeightDevice": [],
+        "BlkioDeviceReadBps": null,
+        "BlkioDeviceWriteBps": null,
+        "BlkioDeviceReadIOps": null,
+        "BlkioDeviceWriteIOps": null,
+        "CpuPeriod": 0,
+        "CpuQuota": 0,
+        "CpuRealtimePeriod": 0,
+        "CpuRealtimeRuntime": 0,
+        "CpusetCpus": "",
+        "CpusetMems": "",
+        "Devices": [],
+        "DeviceCgroupRules": null,
+        "DeviceRequests": null,
+        "KernelMemory": 0,
+        "KernelMemoryTCP": 0,
+        "MemoryReservation": 0,
+        "MemorySwap": 0,
+        "MemorySwappiness": null,
+        "OomKillDisable": false,
+        "PidsLimit": null,
+        "Ulimits": null,
+        "CpuCount": 0,
+        "CpuPercent": 0,
+        "IOMaximumIOps": 0,
+        "IOMaximumBandwidth": 0,
+        "MaskedPaths": [
+            "/proc/asound",
+            "/proc/acpi",
+            "/proc/kcore",
+            "/proc/keys",
+            "/proc/latency_stats",
+            "/proc/timer_list",
+            "/proc/timer_stats",
+            "/proc/sched_debug",
+            "/proc/scsi",
+            "/sys/firmware"
+        ],
+        "ReadonlyPaths": [
+            "/proc/bus",
+            "/proc/fs",
+            "/proc/irq",
+            "/proc/sys",
+            "/proc/sysrq-trigger"
+        ]
+    },
+    "GraphDriver": {
+        "Data": {
+            "LowerDir": "/var/lib/docker/overlay2/f465d319fdc648887be2bbbe09611f291efc41c3843f0aa99c2ba1444a55d0df-init/diff:/var/lib/docker/overlay2/923977bd655d09afda945e7fa79d4a3023617c240859ed9deeae1f567f425813/diff:/var/lib/docker/overlay2/175b5c0daaf373e54a9b79a8ba935016c98ed3db630bafc9ca4a985e45fed41f/diff:/var/lib/docker/overlay2/b1d1f8bf249815a365f494dd83b88a09d87212e168449b3c9a8ebebbb986fc68/diff",
+            "MergedDir": "/var/lib/docker/overlay2/f465d319fdc648887be2bbbe09611f291efc41c3843f0aa99c2ba1444a55d0df/merged",
+            "UpperDir": "/var/lib/docker/overlay2/f465d319fdc648887be2bbbe09611f291efc41c3843f0aa99c2ba1444a55d0df/diff",
+            "WorkDir": "/var/lib/docker/overlay2/f465d319fdc648887be2bbbe09611f291efc41c3843f0aa99c2ba1444a55d0df/work"
+        },
+        "Name": "overlay2"
+    },
+    "Mounts": [],
+    "Config": {
+        "Hostname": "56072241b290",
+        "Domainname": "",
+        "User": "",
+        "AttachStdin": false,
+        "AttachStdout": false,
+        "AttachStderr": false,
+        "Tty": false,
+        "OpenStdin": false,
+        "StdinOnce": false,
+        "Env": [
+            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+        ],
+        "Cmd": [
+            "sleep",
+            "infinity"
+        ],
+        "Image": "ubuntu",
+        "Volumes": null,
+        "WorkingDir": "",
+        "Entrypoint": null,
+        "OnBuild": null,
+        "Labels": {}
+    },
+    "NetworkSettings": {
+        "Bridge": "",
+        "SandboxID": "079c9f37b06b07eb614f588f3fe3fff839a1a2f4b469a68837abf01e2c43b63c",
+        "HairpinMode": false,
+        "LinkLocalIPv6Address": "",
+        "LinkLocalIPv6PrefixLen": 0,
+        "Ports": {},
+        "SandboxKey": "/var/run/docker/netns/079c9f37b06b",
+        "SecondaryIPAddresses": null,
+        "SecondaryIPv6Addresses": null,
+        "EndpointID": "e9a58595db209a9191ae64098fa667c06519ef0e501313267cf9ecf9ad9d2bda",
+        "Gateway": "172.17.0.1",
+        "GlobalIPv6Address": "",
+        "GlobalIPv6PrefixLen": 0,
+        "IPAddress": "172.17.0.3",
+        "IPPrefixLen": 16,
+        "IPv6Gateway": "",
+        "MacAddress": "02:42:ac:11:00:03",
+        "Networks": {
+            "bridge": {
+                "IPAMConfig": null,
+                "Links": null,
+                "Aliases": null,
+                "NetworkID": "30df4a12766fe3f0f08e80c08a5400fb8c1030063212ff6aee808fd1840e8ed0",
+                "EndpointID": "e9a58595db209a9191ae64098fa667c06519ef0e501313267cf9ecf9ad9d2bda",
+                "Gateway": "172.17.0.1",
+                "IPAddress": "172.17.0.3",
+                "IPPrefixLen": 16,
+                "IPv6Gateway": "",
+                "GlobalIPv6Address": "",
+                "GlobalIPv6PrefixLen": 0,
+                "MacAddress": "02:42:ac:11:00:03",
+                "DriverOpts": null
+            }
+        }
+    }
+}
\ No newline at end of file