finish extremely basic implementation of docker credentials
This commit is contained in:
@ -13,11 +13,7 @@ use super::{
|
||||
pub fn docker_store(global_args: GlobalArgs) -> anyhow::Result<()> {
|
||||
let input: DockerCredential = serde_json::from_reader(io::stdin())?;
|
||||
|
||||
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),
|
||||
};
|
||||
let req = CliRequest::StoreDockerCredential(input);
|
||||
|
||||
match super::make_request(global_args.server_addr, &req)?? {
|
||||
CliResponse::Empty => Ok(()),
|
||||
@ -41,3 +37,17 @@ pub fn docker_get(global_args: GlobalArgs) -> anyhow::Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
pub fn docker_erase(global_args: GlobalArgs) -> anyhow::Result<()> {
|
||||
let mut server_url = String::new();
|
||||
io::stdin().read_to_string(&mut server_url)?;
|
||||
let req = CliRequest::EraseDockerCredential {
|
||||
server_url: server_url.trim().to_owned()
|
||||
};
|
||||
|
||||
match super::make_request(global_args.server_addr, &req)?? {
|
||||
CliResponse::Empty => Ok(()),
|
||||
r => bail!("Unexpected response from server: {r}"),
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ pub fn exec(args: ExecArgs, global: GlobalArgs) -> anyhow::Result<()> {
|
||||
|
||||
|
||||
pub fn invoke_shortcut(args: InvokeArgs, global: GlobalArgs) -> anyhow::Result<()> {
|
||||
let req = CliRequest::InvokeShortcut(args.shortcut_action);
|
||||
let req = CliRequest::InvokeShortcut{action: args.shortcut_action};
|
||||
match make_request(global.server_addr, &req)?? {
|
||||
CliResponse::Empty => Ok(()),
|
||||
r => bail!("Unexpected response from server: {r}"),
|
||||
@ -205,7 +205,7 @@ pub fn docker_credential_helper(cmd: DockerCmd, global_args: GlobalArgs) -> anyh
|
||||
match cmd {
|
||||
DockerCmd::Get => docker::docker_get(global_args),
|
||||
DockerCmd::Store => docker::docker_store(global_args),
|
||||
DockerCmd::Erase => todo!(),
|
||||
DockerCmd::Erase => docker::docker_erase(global_args),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user