gitops_operator/git/
utils.rs

1use git2::Error as GitError;
2use git2::Signature;
3use std::env;
4use std::time::{SystemTime, UNIX_EPOCH};
5
6pub fn create_signature<'a>() -> Result<Signature<'a>, GitError> {
7    let name = env::var("DEFAULT_FROM_NAME").unwrap_or("GitOps Operator".to_owned());
8    let email = env::var("DEFAULT_FROM_EMAIL").unwrap_or("kainlite+gitops@gmail.com".to_owned());
9
10    // Get current timestamp
11    let time = SystemTime::now()
12        .duration_since(UNIX_EPOCH)
13        .unwrap()
14        .as_secs();
15
16    // Create signature with current timestamp
17    Signature::new(&name, &email, &git2::Time::new(time as i64, 0))
18}