commit 32b0846d719e8a715b7b75099e05436888193d89 from: murilo ijanc date: Fri Nov 28 19:45:50 2025 UTC Start login command commit - c24534f48bd40f77b3bdd778f000fd5ea8cbc329 commit + 32b0846d719e8a715b7b75099e05436888193d89 blob - f6839467a2ffed8caef19be09290661776f05464 blob + 67012d53d2e0050150e27f10dbbbb755ee53f201 --- crates/kops_protocol/src/lib.rs +++ crates/kops_protocol/src/lib.rs @@ -27,6 +27,8 @@ pub enum Request { /// Health-check: the daemon must reply with `Response::Pong`. Ping, + Login, + Pods(PodsRequest), Env(EnvRequest), @@ -40,6 +42,8 @@ pub enum Response { /// Response for `Request::Ping`, Pong, + LoginOk, + Version(VersionInfo), Pods { blob - 2290418a26cc58733d8baefe2ed74d065d9e575b blob + 794353c3a1a5d37fb0b61f2410f3696184a8ef88 --- kopsctl/src/cmd/mod.rs +++ kopsctl/src/cmd/mod.rs @@ -15,6 +15,7 @@ // pub mod env; +pub mod login; pub mod ping; pub mod pods; pub mod version; blob - /dev/null blob + 1d33f4409dbe65886df7591f74bef53c64dbaa1c (mode 644) --- /dev/null +++ kopsctl/src/cmd/login.rs @@ -0,0 +1,37 @@ +// +// Copyright (c) 2025 murilo ijanc' +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +use anyhow::{Result, bail}; + +use kops_protocol::{Request, Response}; + +use crate::helper::send_request; + +pub async fn execute() -> Result<()> { + let resp = send_request(Request::Login).await?; + + match resp { + Response::LoginOk => print_login_info(), + Response::Error { message } => bail!("reponse error {message}"), + _ => bail!("unexpected response to version"), + } + + Ok(()) +} + +fn print_login_info() { + println!("login ok"); +} blob - 60135e699db3e9f9a522939f5b0493df3222775c blob + 8afcb435a3252d9616c2cdd15312e411aea7d5e4 --- kopsctl/src/main.rs +++ kopsctl/src/main.rs @@ -34,6 +34,9 @@ enum Command { /// Ping the daemon and expect a Pong response. Ping, + /// Login to the aws + Login, + /// Show daemon and protocol version Version, @@ -94,6 +97,7 @@ async fn main() -> Result<()> { match args.command { Command::Ping => cmd::ping::execute().await?, + Command::Login => cmd::login::execute().await?, Command::Version => cmd::version::execute().await?, Command::Pods { cluster, namespace, failed_only } => { cmd::pods::execute(cluster, namespace, failed_only).await? blob - 70299a96755ff0ef3ec3a50f2ddf87c87106c2e8 blob + 804f99b9964ceb3f4a37a5da2acd641deab88d4d --- kopsd/src/handler.rs +++ kopsd/src/handler.rs @@ -36,6 +36,7 @@ impl Handler { pub async fn handle(&self, req: Request) -> Response { match req { Request::Ping => Response::Pong, + Request::Login => Response::LoginOk, Request::Version => self.handle_version().await, Request::Pods(p) => self.handle_pods(p).await, Request::Env(r) => self.handle_env(r).await, @@ -189,9 +190,7 @@ impl Handler { let mut pods: Vec = pods_snapshot .into_iter() - .filter_map(|p| { - PodSummary::from_pod(cluster_name, &p) - }) + .filter_map(|p| PodSummary::from_pod(cluster_name, &p)) .filter(|p| { if let Some(ns) = &req.namespace { if &p.namespace != ns {