ocrd_network.runtime_data.connection_clients module¶
- class ocrd_network.runtime_data.connection_clients.CustomDockerClient(user: str, host: str, **kwargs)[source]¶
Bases:
DockerClient
Wrapper for docker.DockerClient to use an own SshHttpAdapter.
This makes it possible to use provided password/keyfile for connecting with python-docker-sdk, which otherwise only allows to use ~/.ssh/config for login
XXX: inspired by https://github.com/docker/docker-py/issues/2416 . Should be replaced when docker-sdk provides its own way to make it possible to use custom SSH Credentials. Possible Problems: APIClient must be given the API-version because it cannot connect prior to read it. I could imagine this could cause Problems. This is not a rushed implementation and was the only workaround I could find that allows password/keyfile to be used (by default only keyfile from ~/.ssh/config can be used to authenticate via ssh)
XXX 2: Reasons to extend DockerClient: The code-changes regarding the connection should be in one place, so I decided to create CustomSshHttpAdapter as an inner class. The super constructor must not be called to make this workaround work. Otherwise, the APIClient constructor would be invoked without version and that would cause a connection-attempt before this workaround can be applied.
- ocrd_network.runtime_data.connection_clients.create_docker_client(address: str, username: str, password: str = '', keypath: str = '') CustomDockerClient [source]¶