generated from PlexSheep/rs-base
Compare commits
No commits in common. "b2bd3a9dde5aeae80b653d23dba82db5cb203653" and "48008c4d7a9e98bcdeaebaef2c6e1a351a4f4027" have entirely different histories.
b2bd3a9dde
...
48008c4d7a
9 changed files with 6 additions and 130 deletions
|
@ -21,7 +21,6 @@ keywords = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.79"
|
anyhow = "1.0.79"
|
||||||
async-trait = "0.1.77"
|
|
||||||
cargo = "0.76.0"
|
cargo = "0.76.0"
|
||||||
clap = { version = "4.4.18", features = ["derive", "help"] }
|
clap = { version = "4.4.18", features = ["derive", "help"] }
|
||||||
clap-verbosity-flag = "2.1.2"
|
clap-verbosity-flag = "2.1.2"
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl YamlConfigSection for ApiAuth {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct Api {
|
pub struct Api {
|
||||||
pub server_type: ApiType,
|
pub r#type: ApiType,
|
||||||
pub endpoint: Url,
|
pub endpoint: Url,
|
||||||
/// May be left empty if the Api does not need auth or the auth is part of the
|
/// May be left empty if the Api does not need auth or the auth is part of the
|
||||||
/// [endpoint](Api::endpoint) [Url].
|
/// [endpoint](Api::endpoint) [Url].
|
||||||
|
@ -81,7 +81,7 @@ pub struct Api {
|
||||||
}
|
}
|
||||||
impl YamlConfigSection for Api {
|
impl YamlConfigSection for Api {
|
||||||
fn check(&self) -> Result<()> {
|
fn check(&self) -> Result<()> {
|
||||||
self.server_type.check()?;
|
self.r#type.check()?;
|
||||||
match self.endpoint.socket_addrs(|| None) {
|
match self.endpoint.socket_addrs(|| None) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
|
|
|
@ -4,9 +4,6 @@ use autocrate::{
|
||||||
cli::{Cli, Commands},
|
cli::{Cli, Commands},
|
||||||
Config,
|
Config,
|
||||||
},
|
},
|
||||||
release::release,
|
|
||||||
serverapi::init_servers,
|
|
||||||
publish::publish,
|
|
||||||
error::*,
|
error::*,
|
||||||
publish::publish,
|
publish::publish,
|
||||||
release::release,
|
release::release,
|
||||||
|
@ -22,11 +19,10 @@ async fn main() -> Result<()> {
|
||||||
println!("{}", Changelog::build(&cfg)?);
|
println!("{}", Changelog::build(&cfg)?);
|
||||||
}
|
}
|
||||||
Commands::Release { .. } => {
|
Commands::Release { .. } => {
|
||||||
init_servers(&cfg).await?;
|
release(&cfg)?;
|
||||||
release(&cfg).await?;
|
|
||||||
}
|
}
|
||||||
Commands::Publish { .. } => {
|
Commands::Publish { .. } => {
|
||||||
publish(&cfg).await?;
|
publish(&cfg)?;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{config::Config, error::*};
|
use crate::{config::Config, error::*};
|
||||||
pub async fn publish(cfg: &Config) -> Result<()> {
|
pub fn publish(_cfg: &Config) -> Result<()> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
use crate::{config::Config, error::*};
|
use crate::{config::Config, error::*};
|
||||||
|
|
||||||
pub async fn release(cfg: &Config) -> Result<()> {
|
pub fn release(_cfg: &Config) -> Result<()> {
|
||||||
// TODO: git tag
|
|
||||||
// TODO: version bump
|
|
||||||
// TODO: version select interactive
|
|
||||||
// TODO: version select automated
|
|
||||||
// TODO: push to each server
|
|
||||||
// TODO: release to each server
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
use async_trait::async_trait;
|
|
||||||
|
|
||||||
use super::ServerApi;
|
|
||||||
use crate::{
|
|
||||||
config::{ApiType, Config},
|
|
||||||
error::*,
|
|
||||||
};
|
|
||||||
pub struct Gitea;
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl ServerApi for Gitea {
|
|
||||||
async fn init(&mut self, cfg: &Config) -> Result<()> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
async fn push_release(&mut self) -> Result<()> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Gitea {
|
|
||||||
pub async fn build(cfg: &Config) -> Result<Self> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
use async_trait::async_trait;
|
|
||||||
|
|
||||||
use super::ServerApi;
|
|
||||||
use crate::{
|
|
||||||
config::{ApiType, Config},
|
|
||||||
error::*,
|
|
||||||
};
|
|
||||||
pub struct Github;
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl ServerApi for Github {
|
|
||||||
async fn init(&mut self, cfg: &Config) -> Result<()> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
async fn push_release(&mut self) -> Result<()> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Github {
|
|
||||||
pub async fn build(cfg: &Config) -> Result<Self> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
use async_trait::async_trait;
|
|
||||||
|
|
||||||
use super::ServerApi;
|
|
||||||
use crate::{
|
|
||||||
config::{ApiType, Config},
|
|
||||||
error::*,
|
|
||||||
};
|
|
||||||
pub struct Gitlab;
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl ServerApi for Gitlab {
|
|
||||||
async fn init(&mut self, cfg: &Config) -> Result<()> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
async fn push_release(&mut self) -> Result<()> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Gitlab {
|
|
||||||
pub async fn build(cfg: &Config) -> Result<Self> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +1 @@
|
||||||
use async_trait::async_trait;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
config::{ApiType, Config},
|
|
||||||
error::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod gitea;
|
|
||||||
pub mod github;
|
|
||||||
pub mod gitlab;
|
|
||||||
use gitea::*;
|
|
||||||
use github::*;
|
|
||||||
use gitlab::*;
|
|
||||||
|
|
||||||
pub type ApiCollection = Vec<Box<dyn ServerApi>>;
|
|
||||||
|
|
||||||
// NOTE: in stable rust, traits can normally not contain async methods,
|
|
||||||
// see [here](https://stackoverflow.com/questions/65921581/how-can-i-define-an-async-method-in-a-trait).
|
|
||||||
// The `async_trait` crate can be used to work around this limitation.
|
|
||||||
#[async_trait]
|
|
||||||
pub trait ServerApi {
|
|
||||||
async fn init(&mut self, cfg: &Config) -> Result<()>;
|
|
||||||
async fn push_release(&mut self) -> Result<()>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn init_servers(cfg: &Config) -> Result<ApiCollection> {
|
|
||||||
let mut collection: ApiCollection = ApiCollection::new();
|
|
||||||
for api in &cfg.yaml.api {
|
|
||||||
match api.1.server_type {
|
|
||||||
ApiType::Gitea => {
|
|
||||||
collection.push(Box::new(Gitea::build(cfg).await?));
|
|
||||||
}
|
|
||||||
ApiType::Gitlab => {
|
|
||||||
collection.push(Box::new(Gitlab::build(cfg).await?));
|
|
||||||
}
|
|
||||||
ApiType::Github => {
|
|
||||||
collection.push(Box::new(Github::build(cfg).await?));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(collection)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue