Move .env configuration to config.toml

This commit is contained in:
Neshura 2023-12-29 00:36:01 +01:00
parent 4ba04706b5
commit f78f735b2c
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
5 changed files with 128 additions and 40 deletions

View file

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::env;
use std::env::VarError;
use std::error::Error;
use std::net::{Ipv4Addr, Ipv6Addr};
@ -11,7 +10,7 @@ use serde_derive::{Deserialize, Serialize};
use strum_macros::{Display, IntoStaticStr};
use systemd_journal_logger::connected_to_journal;
use url::ParseError;
use crate::config::{ZoneConfig, ZoneEntry};
use crate::config::{AppConfig, ZoneConfig, ZoneEntry};
const API_BASE: &str = "https://api.cloudflare.com/client/v4";
@ -34,8 +33,8 @@ pub(crate) struct CloudflareZone {
}
impl CloudflareZone {
pub(crate) fn new(zone: &ZoneConfig) -> Result<Self, VarError> {
let key = env::var("CF_API_TOKEN")?;
pub(crate) fn new(zone: &ZoneConfig, config: &AppConfig) -> Result<Self, VarError> {
let key = config.cloudflare_api_token.clone();
Ok(Self {
name: zone.name.clone(),
email: zone.email.clone(),