Compare commits

..

2 Commits

Author SHA1 Message Date
8b51a09a78 add Docker credentials to app and CLI 2024-09-19 11:14:34 -04:00
5ab5fe9c0a start working on docker helper 2024-09-18 09:14:28 -04:00
5 changed files with 9 additions and 29 deletions

View File

@ -1,27 +1,10 @@
use std::io;
use anyhow::bail;
use crate::proto::{CliResponse, DockerCredential};
use super::{
CliCredential,
CliRequest,
GlobalArgs
};
use crate::proto::DockerCredential;
pub fn docker_store(global_args: GlobalArgs) -> anyhow::Result<()> {
pub fn docker_store() -> anyhow::Result<()> {
let input: DockerCredential = serde_json::from_reader(io::stdin())?;
dbg!(&input);
let req = CliRequest::SaveCredential {
name: input.username.clone(),
is_default: false, // is_default doesn't really mean anything for Docker credentials
credential: CliCredential::Docker(input),
};
match super::make_request(global_args.server_addr, &req)?? {
CliResponse::Empty => Ok(()),
r => bail!("Unexpected response from server: {r}"),
}
dbg!(input);
Ok(())
}

View File

@ -201,10 +201,10 @@ pub fn invoke_shortcut(args: InvokeArgs, global: GlobalArgs) -> anyhow::Result<(
}
pub fn docker_credential_helper(cmd: DockerCmd, global_args: GlobalArgs) -> anyhow::Result<()> {
pub fn docker_credential_helper(cmd: DockerCmd) -> anyhow::Result<()> {
match cmd {
DockerCmd::Get => todo!(),
DockerCmd::Store => docker::docker_store(global_args),
DockerCmd::Store => docker::docker_store(),
DockerCmd::Erase => todo!(),
}
}
@ -214,7 +214,6 @@ pub fn docker_credential_helper(cmd: DockerCmd, global_args: GlobalArgs) -> anyh
// to indicate when the operation succeeded or failed, which we deserialize.
// However, the operation may fail to even communicate with the server, in
// which case we return the outer Result
// (probably this should be modeled differently)
#[tokio::main]
async fn make_request(
addr: Option<PathBuf>,

View File

@ -11,7 +11,7 @@ fn main() {
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
Some(Action::Exec(args)) => creddy_cli::exec(args, cli.global_args),
Some(Action::Shortcut(args)) => creddy_cli::invoke_shortcut(args, cli.global_args),
Some(Action::Docker(cmd)) => creddy_cli::docker_credential_helper(cmd, cli.global_args),
Some(Action::Docker(cmd)) => creddy_cli::docker_credential_helper(cmd),
};
if let Err(e) = res {

View File

@ -21,7 +21,7 @@ fn main() {
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
Some(Action::Exec(args)) => creddy_cli::exec(args, cli.global_args),
Some(Action::Shortcut(args)) => creddy_cli::invoke_shortcut(args, cli.global_args),
Some(Action::Docker(cmd)) => creddy_cli::docker_credential_helper(cmd, cli.global_args),
Some(Action::Docker(cmd)) => creddy_cli::docker_credential_helper(cmd),
};
if let Err(e) = res {

View File

@ -40,8 +40,6 @@
</script>
<svelte:window on:focus={input.focus} />
<div class="fixed top-0 w-full p-2 text-center">
<h1 class="text-3xl font-bold">Creddy is locked</h1>
</div>