Compare commits
2 Commits
e4a7c62828
...
8b51a09a78
Author | SHA1 | Date | |
---|---|---|---|
8b51a09a78 | |||
5ab5fe9c0a |
@ -1,27 +1,10 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use anyhow::bail;
|
use crate::proto::DockerCredential;
|
||||||
|
|
||||||
use crate::proto::{CliResponse, DockerCredential};
|
|
||||||
use super::{
|
|
||||||
CliCredential,
|
|
||||||
CliRequest,
|
|
||||||
GlobalArgs
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
pub fn docker_store(global_args: GlobalArgs) -> anyhow::Result<()> {
|
pub fn docker_store() -> anyhow::Result<()> {
|
||||||
let input: DockerCredential = serde_json::from_reader(io::stdin())?;
|
let input: DockerCredential = serde_json::from_reader(io::stdin())?;
|
||||||
dbg!(&input);
|
dbg!(input);
|
||||||
|
Ok(())
|
||||||
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}"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
match cmd {
|
||||||
DockerCmd::Get => todo!(),
|
DockerCmd::Get => todo!(),
|
||||||
DockerCmd::Store => docker::docker_store(global_args),
|
DockerCmd::Store => docker::docker_store(),
|
||||||
DockerCmd::Erase => todo!(),
|
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.
|
// to indicate when the operation succeeded or failed, which we deserialize.
|
||||||
// However, the operation may fail to even communicate with the server, in
|
// However, the operation may fail to even communicate with the server, in
|
||||||
// which case we return the outer Result
|
// which case we return the outer Result
|
||||||
// (probably this should be modeled differently)
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn make_request(
|
async fn make_request(
|
||||||
addr: Option<PathBuf>,
|
addr: Option<PathBuf>,
|
||||||
|
@ -11,7 +11,7 @@ fn main() {
|
|||||||
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
|
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
|
||||||
Some(Action::Exec(args)) => creddy_cli::exec(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::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 {
|
if let Err(e) = res {
|
||||||
|
@ -21,7 +21,7 @@ fn main() {
|
|||||||
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
|
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
|
||||||
Some(Action::Exec(args)) => creddy_cli::exec(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::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 {
|
if let Err(e) = res {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
let alert;
|
let alert;
|
||||||
let passphrase = '';
|
let passphrase = '';
|
||||||
|
|
||||||
let saving = false;
|
let saving = false;
|
||||||
async function unlock() {
|
async function unlock() {
|
||||||
saving = true;
|
saving = true;
|
||||||
@ -40,8 +40,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<svelte:window on:focus={input.focus} />
|
|
||||||
|
|
||||||
<div class="fixed top-0 w-full p-2 text-center">
|
<div class="fixed top-0 w-full p-2 text-center">
|
||||||
<h1 class="text-3xl font-bold">Creddy is locked</h1>
|
<h1 class="text-3xl font-bold">Creddy is locked</h1>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user