pub async fn sync_certificates(db: &Database, github: &Github, certificates: BTreeMap<String, NewCertificate>) {
    // Get all the certificates.
    let db_certificates = Certificates::get_from_db(db);
    // Create a BTreeMap
    let mut certificate_map: BTreeMap<String, Certificate> = Default::default();
    for u in db_certificates {
        certificate_map.insert(u.domain.to_string(), u);
    }
    // Sync certificates.
    for (_, mut certificate) in certificates {
        certificate.populate_from_github(github).await;

        // If the cert is going to expire in less than 7 days, renew it.
        // Otherwise, return early.
        if certificate.valid_days_left > 7 {
            println!("cert {} is valid for {} more days, skipping", certificate.domain, certificate.valid_days_left);
        } else {
            // Populate the certificate.
            certificate.populate().await;

            // Save the certificate to disk.
            certificate.save_to_github_repo(github).await;
        }

        // Update the database and Airtable.
        certificate.upsert(db).await;

        // Remove the certificate from the BTreeMap.
        certificate_map.remove(&certificate.domain);
    }
    // Remove any certificates that should no longer be in the database.
    // This is found by the remaining certificates that are in the map since we removed
    // the existing repos from the map above.
    for (_, cert) in certificate_map {
        cert.delete(db).await;
    }
    println!("updated configs certificates in the database");

    // Update certificates in airtable.
    Certificates::get_from_db(db).update_airtable().await;
}
/// Sync our certificates with our database and then update Airtable from the database.
Sync our certificates with our database and then update Airtable from the database.
Sync our certificates with our database and then update Airtable from the database .
pub async fn sync_certificates(db: &Database, github: &Github, certificates: BTreeMap<String, NewCertificate>) {
    // Get all the certificates.
    let db_certificates = Certificates::get_from_db(db);
    // Create a BTreeMap
    let mut certificate_map: BTreeMap<String, Certificate> = Default::default();
    for u in db_certificates {
        certificate_map.insert(u.domain.to_string(), u);
    }
    // Sync certificates.
    for (_, mut certificate) in certificates {
        certificate.populate_from_github(github).await;
        // If the cert is going to expire in less than 7 days, renew it.
        // Otherwise, return early.
        if certificate.valid_days_left > 7 {
            println!("cert {} is valid for {} more days, skipping", certificate.domain, certificate.valid_days_left);
        } else {
            // Populate the certificate.
            certificate.populate().await;
            // Save the certificate to disk.
            certificate.save_to_github_repo(github).await;
        }
        // Update the database and Airtable.
        certificate.upsert(db).await;
        // Remove the certificate from the BTreeMap.
        certificate_map.remove(&certificate.domain);
    }
    // Remove any certificates that should no longer be in the database.
    // This is found by the remaining certificates that are in the map since we removed
    // the existing repos from the map above.
    for (_, cert) in certificate_map {
        cert.delete(db).await;
    }
    println!("updated configs certificates in the database");
    // Update certificates in airtable.
    Certificates::get_from_db(db).update_airtable().await;
}
pub async fn sync_certificates ( db : & Database , github : & Github , certificates : BTreeMap < String , NewCertificate > ) { // Get all the certificates. let db_certificates = Certificates :: get_from_db ( db ) ; // Create a BTreeMap let mut certificate_map : BTreeMap < String , Certificate > = Default :: default ( ) ; for u in db_certificates { certificate_map . insert ( u . domain . to_string ( ) , u ) ; } // Sync certificates. for ( _ , mut certificate ) in certificates { certificate . populate_from_github ( github ) . await ; // If the cert is going to expire in less than 7 days, renew it. // Otherwise, return early. if certificate . valid_days_left > 7 { println ! ( " " certificate domain certificate valid_days_left ) ; } else { // Populate the certificate. certificate . populate ( ) . await ; // Save the certificate to disk. certificate . save_to_github_repo ( github ) . await ; } // Update the database and Airtable. certificate . upsert ( db ) . await ; // Remove the certificate from the BTreeMap. certificate_map . remove ( & certificate . domain ) ; } // Remove any certificates that should no longer be in the database. // This is found by the remaining certificates that are in the map since we removed // the existing repos from the map above. for ( _ , cert ) in certificate_map { cert . delete ( db ) . await ; } println ! ( " " ) ; // Update certificates in airtable. Certificates :: get_from_db ( db ) . update_airtable ( ) . await ; }
Sync our certificates with our database and then update Airtable from the database.
Sync our certificates with our database and then update Airtable from the database .
db
&Database
github
&Github
certificates
BTreeMap<String, NewCertificate>
db
&Database
github
&Github
certificates
BTreeMap<String, NewCertificate>