Skip to content

Commit

Permalink
feat(rust): Redesigned agama logs command to have functionality in th…
Browse files Browse the repository at this point in the history
…e backend and accessible via HTTP API (#1720)

## Problem

Agama's CLI logs command used to be implemented with idea CLI running on
same machine as real installation (the backend). As this is not true
anymore and we have installer's backend and frontend separated with HTTP
API, which makes remote access possible, the logs command had to be
updated to support this idea.

[Its trello
card](https://trello.com/c/3A7vCwfS/3867-agama-cli-move-collecting-logs-into-backend-design-http-api-and-put-it-to-use-in-the-cli)

## Solution

- the particular code which is in control of collecting logs was moved
into agama-lib
- agama's web server has contains http(s)://<server_ip>/api/logs piece
in its public API
- agama's CLI uses the above API for downloading the logs

## Testing

- *Tested manually*
  • Loading branch information
mchf authored Nov 6, 2024
2 parents 4e58df2 + 73ffc9e commit a714076
Show file tree
Hide file tree
Showing 15 changed files with 497 additions and 423 deletions.
6 changes: 5 additions & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rust/agama-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ indicatif= "0.17.8"
thiserror = "1.0.64"
console = "0.15.8"
anyhow = "1.0.89"
# tempdir, fs_extra, nix is for logs (sub)command
tempfile = "3.13.0"
fs_extra = "1.3.0"
nix = { version = "0.27.1", features = ["user"] }
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
async-trait = "0.1.83"
reqwest = { version = "0.11", features = ["json"] }
url = "2.5.2"
inquire = { version = "0.7.5", default-features = false, features = ["crossterm", "one-liners"] }
chrono = "0.4.38"

[[bin]]
name = "agama"
Expand Down
4 changes: 1 addition & 3 deletions rust/agama-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ pub async fn run_command(cli: Cli) -> Result<(), ServiceError> {
install(&manager, 3).await?
}
Commands::Questions(subcommand) => run_questions_cmd(client, subcommand).await?,
// TODO: logs command was originally designed with idea that agama's cli and agama
// installation runs on the same machine, so it is unable to do remote connection
Commands::Logs(subcommand) => run_logs_cmd(subcommand).await?,
Commands::Logs(subcommand) => run_logs_cmd(client, subcommand).await?,
Commands::Download { url } => Transfer::get(&url, std::io::stdout())?,
Commands::Auth(subcommand) => {
run_auth_cmd(client, subcommand).await?;
Expand Down
Loading

0 comments on commit a714076

Please sign in to comment.