drone config setting may contain config URL

This commit is contained in:
Timo Ley 2022-03-23 21:18:35 +01:00
parent 164aed4c7f
commit 1ba57ca22c
2 changed files with 12 additions and 0 deletions

View file

@ -56,6 +56,13 @@ async fn on_request(
.user_agent("curl")
.timeout(Duration::from_secs(30))
.build()?;
let conf = body.config();
if conf.starts_with("http://") || conf.starts_with("https://") {
let drone_config = client.get(conf).send().await?.text().await?;
let response = Response { data: drone_config };
return Ok(Json(response));
}
let auth = AuthQuery {
access_token: token,
};

View file

@ -10,6 +10,7 @@ pub struct Request {
pub struct Repository {
pub name: String,
pub namespace: String,
pub config_path: String,
}
#[derive(Serialize)]
@ -33,4 +34,8 @@ impl Request {
pub fn name(&self) -> String {
self.repo.name.clone()
}
pub fn config(&self) -> String {
self.repo.config_path.clone()
}
}