Skip to content

Commit

Permalink
Merge pull request #234 from r-Techsupport/assets
Browse files Browse the repository at this point in the history
Add asset management
  • Loading branch information
zleyyij authored Nov 6, 2024
2 parents a5d179f + cfed625 commit b007c4b
Show file tree
Hide file tree
Showing 43 changed files with 1,537 additions and 447 deletions.
11 changes: 11 additions & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ chrono = "0.4.38"
clap = { version = "4.5.20", features = ["derive"] }
color-eyre = "0.6.3"
dotenvy = "0.15.7"
fs-err = { version = "3.0.0", features = ["tokio"] }
git2 = "0.19.0"
jsonwebtoken = "9.3.0"
oauth2 = "4.4.2"
Expand Down
14 changes: 7 additions & 7 deletions backend/src/app_conf.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::Deserialize;
use std::fs;
use std::process::exit;
use std::sync::Arc;
use serde::Deserialize;
use tracing::{info, error, trace};
use tracing::{error, info, trace};

#[derive(Deserialize, Debug, Clone, Default, PartialEq, Eq)]
pub struct AppConf {
Expand Down Expand Up @@ -98,21 +98,21 @@ impl ValidateFields for AppConf {
}
}
impl AppConf {

pub fn load(file: &str) -> Arc<Self> {
info!("Loading configuration file: {}", file);
info!("Loading configuration file: {:?}", file);

if fs::metadata(file).is_err() {
error!("Configuration file {} does not exist", file);
error!("Configuration file {:?} does not exist", file);
exit(1)
}

let config: Self = toml::from_str(&fs::read_to_string(file).unwrap()).expect("Unable to parse config");
let config: Self =
toml::from_str(&fs::read_to_string(file).unwrap()).expect("Unable to parse config");

trace!("Loaded config: {:#?}", config);

config.validate("config").expect("Invalid config");

Arc::new(config)
}
}
4 changes: 2 additions & 2 deletions backend/src/gh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use chrono::DateTime;
use color_eyre::eyre::{bail, Context};
use color_eyre::Result;
use fs_err as fs;
use jsonwebtoken::{encode, Algorithm, EncodingKey, Header};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::Read;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
Expand Down Expand Up @@ -151,7 +151,7 @@ async fn get_installation_id(req_client: &Client, client_id: &str) -> Result<Str

/// Generate a new JWT token for use with github api interactions.
fn gen_jwt_token(client_id: &str) -> Result<String> {
let mut private_key_file = File::open("hyde-data/key.pem")
let mut private_key_file = fs::File::open("hyde-data/key.pem")
.wrap_err("Failed to read private key from `hyde-data/key.pem`")?;
let mut private_key = Vec::new();
private_key_file.read_to_end(&mut private_key)?;
Expand Down
Loading

0 comments on commit b007c4b

Please sign in to comment.