m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-17 01:23:39 -05:00

Add support for connecting with both unix and http docker sockets. Hasn't been tested yet.

This commit is contained in:
Sergio
2025-01-02 12:47:52 +02:00
parent 0a8295fff4
commit ded441cf75

View File

@@ -6,20 +6,33 @@ use crate::{config::Config, error, structs::image::Image};
fn create_docker_client(socket: Option<&String>) -> Docker {
let client: Result<Docker, bollard::errors::Error> = match socket {
Some(sock) => Docker::connect_with_local(
sock,
120,
&ClientVersion {
major_version: 1,
minor_version: 44,
},
),
None => Docker::connect_with_local_defaults(),
Some(sock) => {
if sock.starts_with("unix://") {
Docker::connect_with_unix(
sock,
120,
&ClientVersion {
major_version: 1,
minor_version: 44,
},
)
} else {
Docker::connect_with_http(
sock,
120,
&ClientVersion {
major_version: 1,
minor_version: 44,
},
)
}
}
None => Docker::connect_with_unix_defaults(),
};
match client {
Ok(d) => d,
Err(e) => error!("Failed to connect to docker socket!\n{}", e),
Err(e) => error!("Failed to connect to docker daemon!\n{}", e),
}
}