From 178d3a88a5ad91ddd448b7c65befbebcf47aaa23 Mon Sep 17 00:00:00 2001 From: "Fabien D." Date: Sun, 9 Mar 2025 14:58:19 +0100 Subject: [PATCH] Prepare release 1.5.0 --- CHANGELOG.md | 10 +++++ cli/Cargo.lock | 94 ++++++++++++++++++++--------------------- cli/Cargo.toml | 19 ++++++--- cli/src/cli.rs | 13 ++++++ cli/src/command.rs | 1 + cli/src/command/port.rs | 75 ++++++++++++++++++++++++++++++++ cli/src/utils/docker.rs | 31 ++++++++++++++ collection/.env.dist | 6 +-- 8 files changed, 193 insertions(+), 56 deletions(-) create mode 100644 cli/src/command/port.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index ace0ff9..0d8bde8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 1.5.0 release (2025-03-10) + +* Add support for docker compose: + * **port** command. +* Update libraries (deps). +* Update version of docker image used in Collection : + * Grafana 11.5.2 + * Loki 3.4.2 + * Promtail 3.4.2 + ## 1.4.11 release (2025-02-08) * Update libraries (deps). diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 983a428..5ace09d 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97" dependencies = [ "proc-macro2", "quote", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bytecount" @@ -113,9 +113,9 @@ checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" [[package]] name = "bytes" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cfg-if" @@ -125,18 +125,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.28" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstream", "anstyle", @@ -146,9 +146,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.44" +version = "4.5.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375f9d8255adeeedd51053574fd8d4ba875ea5fa558e86617b07f09f1680c8b6" +checksum = "f5c5508ea23c5366f77e53f5a0070e5a84e51687ec3ef9e0464c86dc8d13ce98" dependencies = [ "clap", ] @@ -167,7 +167,7 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "dctl" -version = "1.4.11" +version = "1.5.0" dependencies = [ "async-trait", "clap", @@ -219,9 +219,9 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "eyre" @@ -298,15 +298,15 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "libredox" @@ -336,9 +336,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", ] @@ -491,27 +491,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ "bitflags", ] @@ -535,9 +535,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "scopeguard" @@ -547,18 +547,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -567,9 +567,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -606,9 +606,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" @@ -628,9 +628,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.98" +version = "2.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2" dependencies = [ "proc-macro2", "quote", @@ -688,9 +688,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a" dependencies = [ "backtrace", "bytes", @@ -738,9 +738,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -751,9 +751,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-width" @@ -929,9 +929,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" +checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" dependencies = [ "memchr", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b11fae7..b8ea3b6 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,21 +1,28 @@ [package] name = "dctl" -version = "1.4.11" +version = "1.5.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tokio = { version = "1.43.0", features = ["full"] } -async-trait = { version = "0.1.86" } +tokio = { version = "1.44.0", features = ["full"] } +async-trait = { version = "0.1.87" } eyre = { version = "0.6.12" } -clap = { version = "4.5.28", features = ["cargo"] } -clap_complete = { version = "4.5.44" } +clap = { version = "4.5.31", features = ["cargo"] } +clap_complete = { version = "4.5.46" } toml = { version = "0.8.20" } dotenv = { version = "0.15.0" } -serde = { version = "1.0.217", features = ["derive"] } +serde = { version = "1.0.218", features = ["derive"] } serde_json = { version = "1.0.138" } shellexpand = { version = "3.1.0" } tabled = { version = "0.18.0" } mockall = { version = "0.13.1" } version = { version = "3.0.0" } + + +[profile.release] +lto = "thin" +opt-level = "z" +panic = "abort" +strip = "debuginfo" \ No newline at end of file diff --git a/cli/src/cli.rs b/cli/src/cli.rs index fc40af2..0087db6 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -20,6 +20,7 @@ use crate::command::kill::compose_kill; use crate::command::logs::compose_logs; use crate::command::ls::compose_ls; use crate::command::pause::compose_pause; +use crate::command::port::compose_port; use crate::command::ps::compose_ps; use crate::command::pull::compose_pull; use crate::command::push::compose_push; @@ -54,6 +55,7 @@ fn cli() -> Command { .subcommand(compose_ls()) .subcommand(compose_ps()) .subcommand(compose_pause()) + .subcommand(compose_port()) .subcommand(compose_pull()) .subcommand(compose_push()) .subcommand(compose_restart()) @@ -225,6 +227,17 @@ pub async fn run(container: &dyn Container, config: &mut dyn CliConfig) -> Resul ) .await? } + "port" => { + container + .compose( + CommandType::Port, + &default_arg, + &default_command_arg, + args, + None, + ) + .await? + } "pull" => { container .compose( diff --git a/cli/src/command.rs b/cli/src/command.rs index 43208b1..270b306 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -9,6 +9,7 @@ pub mod kill; pub mod logs; pub mod ls; pub mod pause; +pub mod port; pub mod ps; pub mod pull; pub mod push; diff --git a/cli/src/command/port.rs b/cli/src/command/port.rs new file mode 100644 index 0000000..aafc139 --- /dev/null +++ b/cli/src/command/port.rs @@ -0,0 +1,75 @@ +use clap::{Arg, ArgAction, ArgMatches, Command}; +use eyre::Result; +use std::ffi::OsStr; + +pub fn compose_port() -> Command { + Command::new("port") + .about("Print the public port for a port binding for a service of the project") + .arg( + Arg::new("PROJECT") + .help("The name of the docker-compose file alias") + .required(true) + ) + .arg( + Arg::new("SERVICE") + .help("The name of the service(s) to display public port") + ) + .arg( + Arg::new("PRIVATE_PORT") + .help("Private port") + ) + .arg( + Arg::new("PROTOCOL") + .help("Service protocol.") + .long("protocol") + .value_parser(["tcp", "udp"]) + ) + .arg( + Arg::new("INDEX") + .help("Index of the container if service has multiple replicas.") + .long("index") + .action(ArgAction::SetTrue) + ) +} + +pub fn prepare_command_port(args_matches: &ArgMatches) -> Result> { + let mut args: Vec<&OsStr> = vec![]; + + args.push(OsStr::new("port")); + + if let Some(services) = args_matches.get_occurrences::("SERVICE") { + for service in services { + for s in service { + args.push(OsStr::new(s)); + } + } + } + + if args_matches.get_flag("INDEX") { + args.push(OsStr::new("--index")); + } + + if let Some(protocol) = args_matches.get_one::("PROTOCOL") { + args.push(OsStr::new("--protocol")); + args.push(OsStr::new(protocol)); + } + + if let Some(port) = args_matches.get_one::("PRIVATE_PORT") { + args.push(OsStr::new(port)); + } + + Ok(args) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_returns_a_complete_vec_of_osstr_for_command_port() { + let args_matches = + compose_port().get_matches_from(vec!["port", "PROJECT", "service1", "--index", "--protocol", "tcp", "8080"]); + let args = prepare_command_port(&args_matches).unwrap(); + assert_eq!(args, vec!["port", "service1", "--index", "--protocol", "tcp", "8080"]); + } +} \ No newline at end of file diff --git a/cli/src/utils/docker.rs b/cli/src/utils/docker.rs index 7f6c8c1..6336a3c 100644 --- a/cli/src/utils/docker.rs +++ b/cli/src/utils/docker.rs @@ -14,6 +14,7 @@ use crate::command::kill::prepare_command_kill; use crate::command::logs::prepare_command_logs; use crate::command::ls::prepare_command_ls; use crate::command::pause::prepare_command_pause; +use crate::command::port::prepare_command_port; use crate::command::ps::prepare_command_ps; use crate::command::pull::prepare_command_pull; use crate::command::push::prepare_command_push; @@ -41,6 +42,7 @@ pub enum CommandType { Ls, Logs, Pause, + Port, Pull, Push, Ps, @@ -132,6 +134,7 @@ impl Docker { CommandType::Ls => prepare_command_ls(match_args).unwrap(), CommandType::Logs => prepare_command_logs(match_args).unwrap(), CommandType::Pause => prepare_command_pause(match_args).unwrap(), + CommandType::Port => prepare_command_port(match_args).unwrap(), CommandType::Pull => prepare_command_pull(match_args).unwrap(), CommandType::Push => prepare_command_push(match_args).unwrap(), CommandType::Ps => prepare_command_ps(match_args).unwrap(), @@ -173,6 +176,7 @@ mod tests { use crate::command::logs::compose_logs; use crate::command::ls::compose_ls; use crate::command::pause::compose_pause; + use crate::command::port::compose_port; use crate::command::ps::compose_ps; use crate::command::pull::compose_pull; use crate::command::push::compose_push; @@ -458,6 +462,33 @@ mod tests { assert_eq!(cmd_args, expected_args); } + #[test] + fn it_prepare_docker_compose_port() { + let bin_path = "docker".to_string(); + let docker: Docker = Container::init(bin_path.to_owned()); + + let config_args = vec![OsStr::new("-f"), OsStr::new("docker-compose.yml")]; + let default_command_args = vec![]; + + let matches = compose_port().get_matches_from(vec!["port", "PROJECT_NAME"]); + + let cmd_args = docker.prepare_command( + CommandType::Port, + &config_args, + &default_command_args, + &matches, + ); + + let expected_args = vec![ + OsStr::new("compose"), + OsStr::new("-f"), + OsStr::new("docker-compose.yml"), + OsStr::new("port"), + ]; + + assert_eq!(cmd_args, expected_args); + } + #[test] fn it_prepare_docker_compose_ps() { let bin_path = "docker".to_string(); diff --git a/collection/.env.dist b/collection/.env.dist index 3b87e06..d5e228a 100644 --- a/collection/.env.dist +++ b/collection/.env.dist @@ -30,14 +30,14 @@ MYSQL_USER=stack MYSQL_PASSWORD=stack # Loki -LOKI_VERSION=3.3.2 -PROMTAIL_VERSION=3.3.2 +LOKI_VERSION=3.4.2 +PROMTAIL_VERSION=3.4.2 # Rsyslog RSYSLOG_VERSION=latest # Grafana -GRAFANA_VERSION=11.5.1 +GRAFANA_VERSION=11.5.2 # Portainer PORTAINER_VERSION=latest