-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use std::collections::HashSet; | ||
use std::future::Future; | ||
use std::pin::Pin; | ||
|
||
use crate::executor::{AppInput, Download, Executor, ExecutorCmd, GgVersion}; | ||
use crate::target::{Arch, Os, Variant}; | ||
use crate::target::Os::Windows; | ||
|
||
pub struct Caddy { | ||
pub executor_cmd: ExecutorCmd, | ||
} | ||
|
||
impl Executor for Caddy { | ||
fn get_executor_cmd(&self) -> &ExecutorCmd { | ||
&self.executor_cmd | ||
} | ||
|
||
fn get_download_urls<'a>(&self, _input: &'a AppInput) -> Pin<Box<dyn Future<Output=Vec<Download>> + 'a>> { | ||
Box::pin(async move { | ||
let mut downloads: Vec<Download> = vec!(); | ||
let octocrab = octocrab::Octocrab::builder().build().unwrap(); | ||
let mut page: u32 = 1; | ||
loop { | ||
let releases = octocrab.repos("caddyserver", "caddy") | ||
.releases().list().page(page).per_page(100).send().await.unwrap(); | ||
for release in releases.items { | ||
for asset in release.assets { | ||
let os = if asset.name.contains("windows") { | ||
Some(Windows) | ||
} else if asset.name.contains("linux") { | ||
Some(Os::Linux) | ||
} else if asset.name.contains("apple") { | ||
Some(Os::Mac) | ||
} else { | ||
None | ||
}; | ||
let arch = if asset.name.contains("amd64") { | ||
Some(Arch::X86_64) | ||
} else { | ||
None | ||
}; | ||
if os.is_some() && arch.is_some() { | ||
downloads.push(Download { | ||
download_url: asset.browser_download_url.to_string(), | ||
version: GgVersion::new(release.tag_name.as_str()), | ||
os, | ||
arch, | ||
tags: HashSet::new(), | ||
variant: Some(Variant::Any), | ||
}); | ||
} | ||
} | ||
} | ||
if releases.next == None { | ||
break; | ||
} | ||
page += 1; | ||
} | ||
downloads | ||
}) | ||
} | ||
|
||
fn get_bins(&self, input: &AppInput) -> Vec<String> { | ||
vec!(match &input.target.os { | ||
Windows => "caddy.exe", | ||
_ => "caddy" | ||
}.to_string()) | ||
} | ||
|
||
fn get_name(&self) -> &str { | ||
"caddy" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ pub mod node; | |
pub mod deno; | ||
pub mod gradle_properties; | ||
pub mod go; | ||
pub mod caddy; |