api2: read_remote: also return RemoteWithoutPassword
like for the index, instead of manually stripping it. this (and the previous change) is backwards-compatible since `Remote` already skipped serializing empty strings, so the returned JSON is identical. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
		@ -111,7 +111,7 @@ pub fn create_remote(name: String, config: RemoteConfig, password: String) -> Re
 | 
				
			|||||||
            },
 | 
					            },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    returns: { type: Remote },
 | 
					    returns: { type: RemoteWithoutPassword },
 | 
				
			||||||
    access: {
 | 
					    access: {
 | 
				
			||||||
        permission: &Permission::Privilege(&["remote", "{name}"], PRIV_REMOTE_AUDIT, false),
 | 
					        permission: &Permission::Privilege(&["remote", "{name}"], PRIV_REMOTE_AUDIT, false),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -121,10 +121,9 @@ pub fn read_remote(
 | 
				
			|||||||
    name: String,
 | 
					    name: String,
 | 
				
			||||||
    _info: &ApiMethod,
 | 
					    _info: &ApiMethod,
 | 
				
			||||||
    mut rpcenv: &mut dyn RpcEnvironment,
 | 
					    mut rpcenv: &mut dyn RpcEnvironment,
 | 
				
			||||||
) -> Result<Remote, Error> {
 | 
					) -> Result<RemoteWithoutPassword, Error> {
 | 
				
			||||||
    let (config, digest) = pbs_config::remote::config()?;
 | 
					    let (config, digest) = pbs_config::remote::config()?;
 | 
				
			||||||
    let mut data: Remote = config.lookup("remote", &name)?;
 | 
					    let data: RemoteWithoutPassword = config.lookup("remote", &name)?;
 | 
				
			||||||
    data.password = "".to_string(); // do not return password in api
 | 
					 | 
				
			||||||
    rpcenv["digest"] = hex::encode(&digest).into();
 | 
					    rpcenv["digest"] = hex::encode(&digest).into();
 | 
				
			||||||
    Ok(data)
 | 
					    Ok(data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user