feat: woodpecker support (hopefully)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Timo Ley 2023-07-19 21:51:47 +02:00
parent 6e654f4910
commit 15dc36f337
3 changed files with 7 additions and 5 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "droneconf"
version = "0.1.0"
version = "1.0.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -59,7 +59,7 @@ async fn on_request(
Json(body): Json<Request>,
Extension(APIConfig(client)): Extension<APIConfig>,
) -> Result<impl IntoResponse, Error> {
let conf = body.config();
let conf = body.config().ok_or(Error::NoContent)?;
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 };

View file

@ -8,7 +8,9 @@ pub struct Request {
#[derive(Deserialize)]
pub struct Repository {
pub config_path: String,
pub config_path: Option<String>,
pub config_file: Option<String>,
pub config: Option<String>,
}
#[derive(Serialize)]
@ -20,7 +22,7 @@ pub struct Response {
pub struct APIConfig(pub Client);
impl Request {
pub fn config(&self) -> String {
self.repo.config_path.clone()
pub fn config(&self) -> Option<String> {
self.repo.config_path.clone().or(self.repo.config_file.clone()).or(self.repo.config.clone())
}
}