dls config upload

This commit is contained in:
Mikaël Cluseau
2026-06-25 12:22:44 +02:00
parent 8246e237bf
commit ae6c62d5de
3 changed files with 166 additions and 363 deletions
+18
View File
@@ -22,6 +22,8 @@ struct Cli {
#[derive(Subcommand)]
enum Command {
#[command(subcommand)]
Config(Config),
Clusters,
Cluster {
cluster: String,
@@ -48,6 +50,11 @@ enum Command {
},
}
#[derive(Subcommand)]
enum Config {
Upload { config_path: PathBuf },
}
#[derive(Subcommand)]
enum DlSet {
Sign {
@@ -255,6 +262,17 @@ async fn main() -> eyre::Result<()> {
StoreOp::Set { data_path, value } => s.write(data_path, value.as_bytes()).await?,
}
}
C::Config(cmd) => match cmd {
Config::Upload { config_path } => {
let cfg = fs::read(&config_path).await?;
let cfg: dls::Config = if config_path.ends_with(".yaml") {
serde_yaml::from_slice(&cfg)?
} else {
serde_json::from_slice(&cfg)?
};
dls().upload_config(&cfg).await?;
}
},
};
Ok(())
+5
View File
@@ -77,6 +77,11 @@ impl Client {
Ok(resp.bytes_stream())
}
pub async fn upload_config(&self, config: &Config) -> Result<()> {
do_req(self.req(Method::POST, "configs")?.json(config), &self.token).await?;
Ok(())
}
pub async fn get_json<T: serde::de::DeserializeOwned>(&self, path: impl Display) -> Result<T> {
self.req_json(self.get(&path)?).await
}