feat: woodpecker support (hopefully)
This commit is contained in:
parent
6e654f4910
commit
15dc36f337
3 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue