Make docker optional

This commit is contained in:
Olivier 'reivilibre' 2020-11-01 20:19:09 +00:00
parent 2f2dbb1902
commit 9c0360e2e8
2 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,11 @@
from typing import Optional
import attr
import docker.errors
try:
import docker.errors
except ImportError:
docker = None
from scone.common.chanpro import Channel
from scone.sous import Utensil
@ -67,7 +71,7 @@ class DockerImagePull(Utensil):
@attr.s(auto_attribs=True)
class DockerVolumeCreate(Utensil):
name: str
@attr.s(auto_attribs=True)
class Result:
name: str
@ -79,7 +83,7 @@ class DockerVolumeCreate(Utensil):
# the docker server returned an error
await channel.send(None)
return
await channel.send(DockerVolumeCreate.Result(name=volume.name))
@ -91,7 +95,7 @@ class DockerNetworkCreate(Utensil):
enable_ipv6: Optional[bool]
attachable: Optional[bool]
ingress: Optional[bool]
@attr.s(auto_attribs=True)
class Result:
name: str
@ -110,5 +114,5 @@ class DockerNetworkCreate(Utensil):
# the docker server returned an error
await channel.send(None)
return
await channel.send(DockerContainerRun.Result(name=network.name))

View File

@ -53,7 +53,9 @@ EXTRAS = {
],
"sous": EX_SOUS_ALL,
"sous-core": EX_SOUS_BASE,
"sous-pg": EX_SOUS_PG
"sous-pg": EX_SOUS_PG,
"docker": ["docker"] # TODO do this more properly if we can...
}
# The rest you shouldn't have to touch too much :)