aboutsummaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/args.rs23
-rw-r--r--src/config/mod.rs87
2 files changed, 110 insertions, 0 deletions
diff --git a/src/config/args.rs b/src/config/args.rs
new file mode 100644
index 0000000..1b0683d
--- /dev/null
+++ b/src/config/args.rs
@@ -0,0 +1,23 @@
+use structopt::StructOpt;
+
+#[derive(StructOpt, Clone, Debug)]
+/// Sync Gitlab Trees
+pub struct Args {
+ #[structopt(subcommand)]
+ pub command: Commands,
+
+ /// Only operate on this subtree
+ pub scope: Option<String>,
+}
+
+#[derive(PartialEq, Clone, Debug)]
+#[derive(StructOpt)]
+#[structopt(about = "the stupid content tracker")]
+pub enum Commands {
+ /// Download new repositories and delete old ones, also update
+ Sync,
+ /// Pull and Push new commits to and from the cloned repos
+ Update,
+ /// List Directories
+ List,
+}
diff --git a/src/config/mod.rs b/src/config/mod.rs
new file mode 100644
index 0000000..26d80f4
--- /dev/null
+++ b/src/config/mod.rs
@@ -0,0 +1,87 @@
+pub mod args;
+
+use serde::{Deserialize, Serialize};
+
+use std::{collections::BTreeMap, ops::Deref, path::Path};
+
+use figment::{
+ providers::{Format, Toml},
+ value::{Dict, Map},
+ Error, Figment, Metadata, Profile, Provider,
+};
+
+use anyhow::{Context, Result};
+
+/// Configuration for the Bot
+#[derive(Clone, Debug, Deserialize, Serialize)]
+// pub struct Config();
+
+// TODO make forge optional
+pub struct Config {
+ #[serde(flatten)]
+ config: BTreeMap<String, ForgeConfig>
+}
+
+impl Deref for Config {
+ type Target = BTreeMap<String, ForgeConfig>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.config
+ }
+}
+
+impl Config {
+ // Allow the configuration to be extracted from any `Provider`.
+ fn from<T: Provider>(provider: T) -> Result<Config, Error> {
+ Figment::from(provider).extract()
+ }
+
+ // Provide a default provider, a `Figment`.
+ pub fn figment() -> Result<Figment> {
+ use figment::providers::Env;
+
+ let dirs = xdg::BaseDirectories::with_prefix(env!("CARGO_PKG_NAME")).unwrap();
+
+ Ok(Figment::from(Toml::file(
+ dirs.place_config_file("config.toml")
+ .context("failed to create config directory")?,
+ ))
+ .merge(Toml::file(
+ dirs.place_config_file("config.yaml")
+ .context("failed to create config directory")?,
+ ))
+ .merge(Env::prefixed("GTREE_")))
+ }
+}
+
+// Make `Config` a provider itself for composability.
+impl Provider for Config {
+ fn metadata(&self) -> Metadata {
+ Metadata::named("Library Config")
+ }
+
+ fn data(&self) -> Result<Map<Profile, Dict>, Error> {
+ figment::providers::Serialized::defaults(self).data()
+ }
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(tag = "type")]
+pub enum ForgeConfig {
+ #[serde(alias = "gitlab")]
+ Gitlab(crate::forge::gitlab::config::Gitlab),
+}
+
+pub trait ForgeConfigTrait {
+ fn root(&self) -> &str;
+}
+
+impl Deref for ForgeConfig {
+ type Target = dyn ForgeConfigTrait;
+
+ fn deref(&self) -> &Self::Target {
+ match self {
+ ForgeConfig::Gitlab(conf) => conf,
+ }
+ }
+}
git/commit/modules/bgp/default.nix?id=f8a4a276474d0da7a047238c8cdb3c49b0580d4d&follow=1'>replace dns bgp anouncementMax Audron-2/+2 2025-09-15update flaresolverrMax Audron-1/+1 2025-09-07add audron windows wg keyMax Audron-0/+8 2025-09-02switch out vultr dns ipv4 ipMax Audron-1/+5 2025-08-11disable homepage trackersMax Audron-3/+3 2025-08-11add mail serverMax Audron-1/+245 2025-08-05add prometheus alerting rulesMax Audron-38/+144 2025-08-01add homepage dashboardMax Audron-3/+284 2025-08-01disable not used gameserversMax Audron-1/+2 2025-08-01add minecraft prometheus exporterMax Audron-3/+67 2025-08-01more monitoring & scrape config shortcutsMax Audron-68/+63 2025-08-01update garage to 2.0Max Audron-6/+10 2025-07-31fix authentik-ldap port bindingsMax Audron-0/+5 2025-07-31update to nixos 25.05Max Audron-113/+65 2025-07-31add more monitoring exporters and scrapersMax Audron-17/+57 2025-07-30try to run authentik nativelyMax Audron-26/+303 2025-07-30more metricsMax Audron-1/+41 2025-07-30enable firewallsMax Audron-1/+39