diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7b5483ef..1ea9ad72a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,13 +107,22 @@ jobs: run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools if: contains(matrix.platform.name, 'musl') - - name: Build release binary + - name: Build iggy-server release binary uses: houseabsolute/actions-rust-cross@v0 with: command: "build" target: ${{ matrix.platform.target }} toolchain: ${{ matrix.toolchain }} - args: "--verbose --release" + args: "--verbose --release --bin iggy-server" + if: ${{ matrix.toolchain }} == 'stable' + + - name: Build iggy-cli release binary + uses: houseabsolute/actions-rust-cross@v0 + with: + command: "build" + target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.toolchain }} + args: "--verbose --release --no-default-features --bin iggy" if: ${{ matrix.toolchain }} == 'stable' - name: Prepare artifacts diff --git a/Cargo.lock b/Cargo.lock index 1de1d6b84..675c443ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2335,7 +2335,7 @@ dependencies = [ [[package]] name = "iggy-cli" -version = "0.5.12" +version = "0.5.13" dependencies = [ "ahash 0.8.11", "anyhow", @@ -4301,7 +4301,7 @@ dependencies = [ [[package]] name = "server" -version = "0.4.14" +version = "0.4.20" dependencies = [ "ahash 0.8.11", "anyhow", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 07a92c604..8996b614a 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iggy-cli" -version = "0.5.12" +version = "0.5.13" edition = "2021" authors = ["bartosz.ciesla@gmail.com"] repository = "https://github.com/iggy-rs/iggy" @@ -9,6 +9,10 @@ description = "Iggy is the persistent message streaming platform written in Rust license = "MIT" keywords = ["iggy", "cli", "messaging", "streaming"] +[features] +default = ["login-session"] +login-session = ["dep:keyring"] + [dependencies] ahash = { version = "0.8.11", features = ["serde"] } anyhow = "1.0.86" @@ -16,7 +20,7 @@ clap = { version = "4.5.4", features = ["derive"] } clap_complete = "4.5.16" figlet-rs = "0.1.5" iggy = { path = "../sdk", features = ["iggy-cli"], version = "0.6.12" } -keyring = { version = "3.2.0", features = ["sync-secret-service", "vendored"] } +keyring = { version = "3.2.0", features = ["sync-secret-service", "vendored"], optional = true } passterm = "2.0.1" thiserror = "1.0.61" tokio = { version = "1.38.0", features = ["full"] } diff --git a/cli/src/args/mod.rs b/cli/src/args/mod.rs index 8bec02681..7aca43dd5 100644 --- a/cli/src/args/mod.rs +++ b/cli/src/args/mod.rs @@ -17,10 +17,13 @@ use crate::args::{ partition::PartitionAction, personal_access_token::PersonalAccessTokenAction, stream::StreamAction, - system::{LoginArgs, PingArgs, StatsArgs}, + system::{PingArgs, StatsArgs}, topic::TopicAction, }; +#[cfg(feature = "login-session")] +use crate::args::system::LoginArgs; + use self::user::UserAction; pub(crate) mod client; @@ -80,6 +83,7 @@ pub(crate) struct CliOptions { #[clap(short, long, group = "credentials")] pub(crate) token: Option, + #[cfg(feature = "login-session")] /// Iggy server personal access token name /// /// When personal access token is created using command line tool and stored @@ -154,6 +158,7 @@ pub(crate) enum Command { /// context operations #[command(subcommand, visible_alias = "ctx")] Context(ContextAction), + #[cfg(feature = "login-session")] /// login to Iggy server /// /// Command logs in to Iggy server using provided credentials and stores session token @@ -161,6 +166,7 @@ pub(crate) enum Command { /// subsequent commands until logout command is executed. #[clap(verbatim_doc_comment, visible_alias = "li")] Login(LoginArgs), + #[cfg(feature = "login-session")] /// logout from Iggy server /// /// Command logs out from Iggy server and removes session token from platform-specific @@ -218,6 +224,7 @@ impl IggyMergedConsoleArgs { username: args.cli.username.or(context.username), password: args.cli.password.or(context.password), token: args.cli.token.or(context.token), + #[cfg(feature = "login-session")] token_name: args.cli.token_name.or(context.token_name), generator: args.cli.generator, }; diff --git a/cli/src/credentials.rs b/cli/src/credentials.rs index 3b2e377b7..e345f20ef 100644 --- a/cli/src/credentials.rs +++ b/cli/src/credentials.rs @@ -3,14 +3,21 @@ use crate::error::{CmdToolError, IggyCmdError}; use anyhow::{bail, Context}; use iggy::args::Args; use iggy::cli::system::session::ServerSession; -use iggy::cli_command::PRINT_TARGET; use iggy::client::{PersonalAccessTokenClient, UserClient}; use iggy::clients::client::IggyClient; use iggy::error::IggyError; -use keyring::Entry; use passterm::{isatty, prompt_password_stdin, prompt_password_tty, Stream}; use std::env::var; -use tracing::{event, Level}; + +#[cfg(feature = "login-session")] +mod credentials_login_session { + pub(crate) use iggy::cli_command::PRINT_TARGET; + pub(crate) use keyring::Entry; + pub(crate) use tracing::{event, Level}; +} + +#[cfg(feature = "login-session")] +use credentials_login_session::*; static ENV_IGGY_USERNAME: &str = "IGGY_USERNAME"; static ENV_IGGY_PASSWORD: &str = "IGGY_PASSWORD"; @@ -57,8 +64,9 @@ impl<'a> IggyCredentials<'a> { } } + #[cfg(feature = "login-session")] if let Some(token_name) = &cli_options.token_name { - match iggy_args.get_server_address() { + return match iggy_args.get_server_address() { Some(server_address) => { let server_address = format!("iggy:{}", server_address); event!(target: PRINT_TARGET, Level::DEBUG,"Checking token presence under service: {} and name: {}", @@ -73,8 +81,10 @@ impl<'a> IggyCredentials<'a> { }) } None => Err(IggyCmdError::CmdToolError(CmdToolError::MissingServerAddress).into()), - } - } else if let Some(token) = &cli_options.token { + }; + } + + if let Some(token) = &cli_options.token { Ok(Self { credentials: Some(Credentials::PersonalAccessToken(token.clone())), iggy_client: None, diff --git a/cli/src/error.rs b/cli/src/error.rs index c93eed3d5..bee002646 100644 --- a/cli/src/error.rs +++ b/cli/src/error.rs @@ -4,6 +4,7 @@ use thiserror::Error; #[derive(Error, Debug)] pub(crate) enum CmdToolError { MissingCredentials, + #[cfg(feature = "login-session")] MissingServerAddress, } @@ -13,6 +14,7 @@ impl Display for CmdToolError { Self::MissingCredentials => { write!(f, "Missing iggy server credentials") } + #[cfg(feature = "login-session")] Self::MissingServerAddress => { write!(f, "Missing iggy server address") } diff --git a/cli/src/main.rs b/cli/src/main.rs index 38524e1b8..b8c318e85 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -21,7 +21,6 @@ use clap::Parser; use iggy::args::Args; use iggy::cli::context::common::ContextManager; use iggy::cli::context::use_context::UseContextCmd; -use iggy::cli::utils::login_session_expiry::LoginSessionExpiry; use iggy::cli::{ client::{get_client::GetClientCmd, get_clients::GetClientsCmd}, consumer_group::{ @@ -44,7 +43,7 @@ use iggy::cli::{ create_stream::CreateStreamCmd, delete_stream::DeleteStreamCmd, get_stream::GetStreamCmd, get_streams::GetStreamsCmd, purge_stream::PurgeStreamCmd, update_stream::UpdateStreamCmd, }, - system::{login::LoginCmd, logout::LogoutCmd, me::GetMeCmd, ping::PingCmd, stats::GetStatsCmd}, + system::{me::GetMeCmd, ping::PingCmd, stats::GetStatsCmd}, topics::{ create_topic::CreateTopicCmd, delete_topic::DeleteTopicCmd, get_topic::GetTopicCmd, get_topics::GetTopicsCmd, purge_topic::PurgeTopicCmd, update_topic::UpdateTopicCmd, @@ -67,6 +66,15 @@ use iggy::utils::personal_access_token_expiry::PersonalAccessTokenExpiry; use std::sync::Arc; use tracing::{event, Level}; +#[cfg(feature = "login-session")] +mod main_login_session { + pub(crate) use iggy::cli::system::{login::LoginCmd, logout::LogoutCmd}; + pub(crate) use iggy::cli::utils::login_session_expiry::LoginSessionExpiry; +} + +#[cfg(feature = "login-session")] +use main_login_session::*; + fn get_command( command: Command, cli_options: &CliOptions, @@ -272,10 +280,12 @@ fn get_command( Box::new(UseContextCmd::new(use_args.context_name.clone())) } }, + #[cfg(feature = "login-session")] Command::Login(login_args) => Box::new(LoginCmd::new( iggy_args.get_server_address().unwrap(), LoginSessionExpiry::new(login_args.expiry.clone()), )), + #[cfg(feature = "login-session")] Command::Logout => Box::new(LogoutCmd::new(iggy_args.get_server_address().unwrap())), } } diff --git a/server/Cargo.toml b/server/Cargo.toml index cd5defba6..5b54ee9e5 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "server" -version = "0.4.14" +version = "0.4.20" edition = "2021" build = "src/build.rs"