fix docker credential helper when credentials are not found
This commit is contained in:
		@@ -29,11 +29,20 @@ pub fn docker_get(global_args: GlobalArgs) -> anyhow::Result<()> {
 | 
			
		||||
       server_url: server_url.trim().to_owned()
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    match super::make_request(global_args.server_addr, &req)?? {
 | 
			
		||||
        CliResponse::Credential(CliCredential::Docker(d)) => {
 | 
			
		||||
    let server_resp = super::make_request(global_args.server_addr, &req)?;
 | 
			
		||||
    match server_resp {
 | 
			
		||||
        Ok(CliResponse::Credential(CliCredential::Docker(d))) => {
 | 
			
		||||
            println!("{}", serde_json::to_string(&d)?);
 | 
			
		||||
        },
 | 
			
		||||
        r => bail!("Unexpected response from server: {r}"),
 | 
			
		||||
        Err(e) if e.code == "NoCredentials" => {
 | 
			
		||||
            // To indicate credentials are not found, a credential helper *must* print
 | 
			
		||||
            // this message to stdout, then exit 1. Any other message/status will cause
 | 
			
		||||
            // some builds to fail. This is, of course, not documented anywhere.
 | 
			
		||||
            println!("credentials not found in native keychain");
 | 
			
		||||
            std::process::exit(1);
 | 
			
		||||
        },
 | 
			
		||||
        Err(e) => Err(e)?,
 | 
			
		||||
        Ok(r) => bail!("Unexpected response from server: {r}"),
 | 
			
		||||
    }
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,8 +27,7 @@ mod platform {
 | 
			
		||||
    use tokio::net::UnixStream;
 | 
			
		||||
 | 
			
		||||
    pub async fn connect(addr: Option<PathBuf>) -> Result<UnixStream, std::io::Error> {
 | 
			
		||||
        let default = if cfg!(debug_assertions) { "creddy-server-dev" } else { "creddy-server" };
 | 
			
		||||
        let path = addr.unwrap_or_else(|| server_addr(default));
 | 
			
		||||
        let path = addr.unwrap_or_else(|| server_addr("creddy-server"));
 | 
			
		||||
        UnixStream::connect(&path).await
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -99,8 +99,8 @@ pub struct DockerCredential {
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Serialize, Deserialize)]
 | 
			
		||||
pub struct ServerError {
 | 
			
		||||
    code: String,
 | 
			
		||||
    msg: String,
 | 
			
		||||
    pub code: String,
 | 
			
		||||
    pub msg: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Display for ServerError {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user