Added first take on how to get and deserialize a github release. I dont know if it works yet, but i will guard it by a test with httpmock.
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
907e2e658a
commit
de1478daf9
|
@ -1,5 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::configuration::VcsType;
|
||||
use crate::request::models::Current;
|
||||
use crate::request::models::{Current, GithubRelease};
|
||||
use crate::{Print, Settings};
|
||||
|
||||
pub fn init<'a>(settings: &'a Settings, console: &'a dyn Print) -> RequestHandler<'a> {
|
||||
|
@ -25,12 +27,22 @@ impl<'a> RequestHandler<'a> {
|
|||
pub fn execute(&self) {
|
||||
let currents = self.request_gateway.get_currents();
|
||||
|
||||
// fetch release page from provider
|
||||
let response = reqwest::blocking::get("").unwrap();
|
||||
for current in currents.iter() {
|
||||
let releases_api_url = format!(
|
||||
"{}/repos/{}/{}/releases", // api_root_url contains protocol - this is very much hard coded to Github right now, so i wont make any fancy factory or something. When there is added another provider i will think on how to do this the correct way
|
||||
current.api_root_url, current.owner_name, current.repo_name
|
||||
);
|
||||
|
||||
// convert to obj
|
||||
// compare
|
||||
// send alert
|
||||
let release = reqwest::blocking::get(releases_api_url)
|
||||
.unwrap()
|
||||
.json::<GithubRelease>()
|
||||
.unwrap();
|
||||
|
||||
// compare
|
||||
println!("Got release {:?}", release);
|
||||
}
|
||||
|
||||
// send alerts
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +85,12 @@ impl<'a> RequestGateway<'a> {
|
|||
pub mod models {
|
||||
use crate::configuration::VcsType;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||
pub struct GithubRelease {
|
||||
pub tag_name: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub struct Current {
|
||||
pub name: String,
|
||||
pub owner_name: String,
|
||||
|
|
Loading…
Reference in New Issue