m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-08 13:13:49 -05:00

feat: allow usage without a daemon (#142)

This commit is contained in:
makonde-on-git
2025-10-14 17:05:11 +02:00
committed by GitHub
parent 547d418401
commit 6ab06db5cb
4 changed files with 20 additions and 2 deletions

View File

@@ -70,7 +70,7 @@
}, },
"socket": { "socket": {
"type": "string", "type": "string",
"description": "The path to the unix socket you would like Cup to use for communication with the Docker daemon. Useful if you're trying to use Cup with Podman.", "description": "The path to the unix socket you would like Cup to use for communication with the Docker daemon. Useful if you're trying to use Cup with Podman. To disable use \"none\" as value.",
"minLength": 1 "minLength": 1
}, },
"servers": { "servers": {

View File

@@ -23,7 +23,7 @@ For example, if using Podman, you might do
$ cup -s /run/user/1000/podman/podman.sock check $ cup -s /run/user/1000/podman/podman.sock check
``` ```
This option is also available in the configuration file and it's best to put it there. This option is also available in the configuration file and it's best to put it there. If both are defined the CLI `-s` option takes precedence.
<Cards.Card <Cards.Card
icon={<IconPlug />} icon={<IconPlug />}
@@ -31,6 +31,8 @@ This option is also available in the configuration file and it's best to put it
href="/docs/configuration/socket" href="/docs/configuration/socket"
/> />
To disable Docker/Podman socket use "none" as value.
## Configuration file ## Configuration file
Cup has an option to be configured from a configuration file named `cup.json`. Cup has an option to be configured from a configuration file named `cup.json`.

View File

@@ -17,3 +17,12 @@ You can also specify a TCP socket if you're using a remote Docker host or a [pro
// Other options // Other options
} }
``` ```
Or use the "none" value to disable any Docker/Podman query:
```jsonc
{
"socket": "none"
// Other options
}
```

View File

@@ -41,6 +41,9 @@ pub async fn get_images_from_docker_daemon(
ctx: &Context, ctx: &Context,
references: &Option<Vec<String>>, references: &Option<Vec<String>>,
) -> Vec<Image> { ) -> Vec<Image> {
if ctx.config.socket.as_deref() == Some("none") {
return vec![];
}
let client: Docker = create_docker_client(ctx.config.socket.as_deref()); let client: Docker = create_docker_client(ctx.config.socket.as_deref());
let mut swarm_images = match client.list_services::<String>(None).await { let mut swarm_images = match client.list_services::<String>(None).await {
Ok(services) => services Ok(services) => services
@@ -96,6 +99,10 @@ pub async fn get_images_from_docker_daemon(
} }
pub async fn get_in_use_images(ctx: &Context) -> Vec<String> { pub async fn get_in_use_images(ctx: &Context) -> Vec<String> {
if ctx.config.socket.as_deref() == Some("none") {
return vec![];
}
let client: Docker = create_docker_client(ctx.config.socket.as_deref()); let client: Docker = create_docker_client(ctx.config.socket.as_deref());
let containers = match client let containers = match client