Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d87ece69da
|
||
|
|
f73ba4b1d6
|
||
|
|
d7845349e8
|
||
|
|
7bea78f194
|
||
|
|
87c1a1c09c
|
||
|
|
d781f3f97b
|
||
|
|
a4f27ce091
|
||
|
|
61b016775e
|
||
|
|
439ccd60d4
|
||
|
|
1c99387d6f
|
||
|
|
bf32d82ae7
|
||
|
|
34f61bba5f
|
||
|
|
d351a8b6be
|
||
|
|
a18eb13cbf
|
||
|
|
dd7c2d2390
|
||
|
|
107b18b461
|
||
|
|
506bf90cce
|
||
|
|
6d784b074b
|
||
|
|
8e1401439a
|
@@ -0,0 +1,9 @@
|
|||||||
|
[registry]
|
||||||
|
default = "gitea"
|
||||||
|
|
||||||
|
[registries.gitea]
|
||||||
|
index = "sparse+https://gitea.creative-dragonslayer.de/api/packages/Rust-Crates/cargo/" # Sparse index
|
||||||
|
# index = "https://gitea.creative-dragonslayer.de/Rust-Crates/_cargo-index.git" # Git
|
||||||
|
|
||||||
|
[net]
|
||||||
|
git-fetch-with-cli = true
|
||||||
@@ -58,12 +58,13 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_URL: ${{ gitea.server_url || github.server_url }}
|
GITEA_URL: ${{ gitea.server_url || github.server_url }}
|
||||||
REPO: ${{ gitea.repository || github.repository }}
|
REPO: ${{ gitea.repository || github.repository }}
|
||||||
|
REPO_NAME: ${{ gitea.repository_name || github.event.repository.name }}
|
||||||
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
|
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
|
||||||
TAG_NAME="v${VERSION}"
|
TAG_NAME="v${VERSION}"
|
||||||
RELEASE_TITLE="Release ${TAG_NAME}"
|
RELEASE_TITLE="Release ${TAG_NAME}"
|
||||||
RELEASE_NOTES="Automatisches Release für config Crate ${VERSION}."
|
RELEASE_NOTES="Automatisches Release für ${REPO_NAME} Crate ${VERSION}."
|
||||||
|
|
||||||
echo "Erstelle oder hole Release für Tag ${TAG_NAME} in ${REPO}..."
|
echo "Erstelle oder hole Release für Tag ${TAG_NAME} in ${REPO}..."
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,13 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_URL: ${{ gitea.server_url || github.server_url }}
|
GITEA_URL: ${{ gitea.server_url || github.server_url }}
|
||||||
REPO: ${{ gitea.repository || github.repository }}
|
REPO: ${{ gitea.repository || github.repository }}
|
||||||
|
REPO_NAME: ${{ gitea.repository_name || github.event.repository.name }}
|
||||||
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
|
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"
|
||||||
TAG_NAME="v${VERSION}-preview"
|
TAG_NAME="v${VERSION}-preview"
|
||||||
RELEASE_TITLE="Preview Release ${TAG_NAME}"
|
RELEASE_TITLE="Preview Release ${TAG_NAME}"
|
||||||
RELEASE_NOTES="Automatisches Preview-Release für config Crate ${VERSION} (Branch: Testing)."
|
RELEASE_NOTES="Automatisches Preview-Release für ${REPO_NAME} Crate ${VERSION} (Branch: Testing)."
|
||||||
|
|
||||||
echo "Erstelle oder hole Preview-Release für Tag ${TAG_NAME} in ${REPO}..."
|
echo "Erstelle oder hole Preview-Release für Tag ${TAG_NAME} in ${REPO}..."
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# AGENTS.md — Entwickler- und Agenten-Dokumentation für Config
|
# AGENTS.md — Entwickler- und Agenten-Dokumentation für Config (config-ctdra)
|
||||||
|
|
||||||
Diese Datei dient als Leitfaden und Kontextdokumentation für autonome Agenten und Entwickler, die an der Codebasis der Crate `config` arbeiten.
|
Diese Datei dient als Leitfaden und Kontextdokumentation für autonome Agenten und Entwickler, die an der Codebasis der Crate `config-ctdra` arbeiten.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. Projektübersicht
|
## 1. Projektübersicht
|
||||||
|
|
||||||
`config` ist eine leichtgewichtige, threadsichere Rust-Crate (Edition 2024) zur Konfigurationsverwaltung. Sie ermöglicht das Speichern, Laden und Modifizieren beliebiger Konfigurationsstrukturen mit automatischer Pfadermittlung für Root- und regulären Benutzermodus.
|
`config-ctdra` ist eine leichtgewichtige, threadsichere Rust-Crate (Edition 2024) zur Konfigurationsverwaltung. Sie ermöglicht das Speichern, Laden und Modifizieren beliebiger Konfigurationsstrukturen mit automatischer Pfadermittlung für Root- und regulären Benutzermodus.
|
||||||
|
|
||||||
### Wichtige Rahmenbedingungen & Prinzipien
|
### Wichtige Rahmenbedingungen & Prinzipien
|
||||||
|
|
||||||
|
|||||||
Generated
+12
-3
@@ -9,12 +9,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "config"
|
name = "config-ctdra"
|
||||||
version = "1.0.1"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"confy",
|
"confy",
|
||||||
"libc",
|
|
||||||
"serde",
|
"serde",
|
||||||
|
"sudo-ctdra",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -141,6 +141,15 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sudo-ctdra"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "sparse+https://gitea.creative-dragonslayer.de/api/packages/Rust-Crates/cargo/"
|
||||||
|
checksum = "2c2746122bbe36f821de70db3ca4ad24edfb77118fc6a6bc7693082b50d23e5f"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "3.0.4"
|
version = "3.0.4"
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "config"
|
name = "config-ctdra"
|
||||||
version = "1.0.1"
|
version = "1.0.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ['DragonSlayer_14']
|
authors = ['DragonSlayer_14']
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -11,7 +11,7 @@ description = "Einfache, threadsichere Konfigurationsverwaltung für Rust mit au
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
confy = "2.0.0"
|
confy = "2.0.0"
|
||||||
serde = { version = "1.0.229", features = ["derive"] }
|
serde = { version = "1.0.229", features = ["derive"] }
|
||||||
libc = "1.0.0-alpha.4"
|
sudo-ctdra = { version = "1.0.0", registry = "gitea" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = "none"
|
debug = "none"
|
||||||
|
|||||||
@@ -208,8 +208,8 @@ If you develop a new program, and you want it to be of the greatest possible use
|
|||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
DockerUpdater
|
config
|
||||||
Copyright (C) 2026 Linuxapps
|
Copyright (C) 2026 Rust-Crates
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
DockerUpdater Copyright (C) 2026 Linuxapps
|
config Copyright (C) 2026 Rust-Crates
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Config (`config`)
|
# Config (`config-ctdra`)
|
||||||
|
|
||||||
`config` ist eine leichtgewichtige, threadsichere Konfigurationsverwaltungs-Crate für Rust mit automatischer Pfadermittlung für Root- und regulären Benutzermodus sowie Unterstützung für beliebige benutzerdefinierte Datenstrukturen.
|
`config-ctdra` ist eine leichtgewichtige, threadsichere Konfigurationsverwaltungs-Crate für Rust mit automatischer Pfadermittlung für Root- und regulären Benutzermodus sowie Unterstützung für beliebige benutzerdefinierte Datenstrukturen.
|
||||||
|
|
||||||
## Merkmale
|
## Merkmale
|
||||||
|
|
||||||
@@ -29,16 +29,16 @@ Füge anschließend die Abhängigkeit in deiner `Cargo.toml` ein:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
config = { version = "1.0.0", registry = "gitea" }
|
config-ctdra = { version = "1.0.1", registry = "gitea" }
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternativ als Git- oder Pfad-Abhängigkeit:
|
Alternativ als Git- oder Pfad-Abhängigkeit:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
config = { git = "https://gitea.creative-dragonslayer.de/Rust-Crates/config.git", branch = "main" }
|
config-ctdra = { git = "https://gitea.creative-dragonslayer.de/Rust-Crates/config.git", branch = "main" }
|
||||||
# oder lokal:
|
# oder lokal:
|
||||||
# config = { path = "../Config" }
|
# config-ctdra = { path = "../Config" }
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -97,7 +97,7 @@ impl Default for Database {
|
|||||||
### 2. Globales Caching mit `get_config`
|
### 2. Globales Caching mit `get_config`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use config::{get_config, set_program_name};
|
use config_ctdra::{get_config, set_program_name};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
set_program_name("my-service");
|
set_program_name("my-service");
|
||||||
@@ -111,7 +111,7 @@ fn main() {
|
|||||||
### 3. Konfiguration modifizieren
|
### 3. Konfiguration modifizieren
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use config::modify_config;
|
use config_ctdra::modify_config;
|
||||||
|
|
||||||
fn update_settings() {
|
fn update_settings() {
|
||||||
modify_config::<AppConfig, _>(|cfg| {
|
modify_config::<AppConfig, _>(|cfg| {
|
||||||
@@ -123,9 +123,9 @@ fn update_settings() {
|
|||||||
### 4. Manuelles Laden und Speichern
|
### 4. Manuelles Laden und Speichern
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use config::{load, store};
|
use config_ctdra::{load, store};
|
||||||
|
|
||||||
fn custom_workflow() -> Result<(), config::ConfyError> {
|
fn custom_workflow() -> Result<(), config_ctdra::ConfyError> {
|
||||||
let mut cfg: AppConfig = load()?;
|
let mut cfg: AppConfig = load()?;
|
||||||
cfg.general.log_level = "debug".to_string();
|
cfg.general.log_level = "debug".to_string();
|
||||||
store(&cfg)?;
|
store(&cfg)?;
|
||||||
|
|||||||
+2
-23
@@ -11,7 +11,7 @@
|
|||||||
//!
|
//!
|
||||||
//! # Beispiel
|
//! # Beispiel
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use config::{get_config, modify_config, set_program_name};
|
//! use config_ctdra::{get_config, modify_config, set_program_name};
|
||||||
//! use serde::{Deserialize, Serialize};
|
//! use serde::{Deserialize, Serialize};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
|
//! #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
|
||||||
@@ -36,6 +36,7 @@ use std::sync::{OnceLock, RwLock};
|
|||||||
pub use confy::ConfyError;
|
pub use confy::ConfyError;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use sudo_ctdra::is_run_as_root;
|
||||||
|
|
||||||
/// Optionaler benutzerdefinierter Programmname für die Konfigurationspfade.
|
/// Optionaler benutzerdefinierter Programmname für die Konfigurationspfade.
|
||||||
static PROGRAM_NAME: OnceLock<RwLock<Option<String>>> = OnceLock::new();
|
static PROGRAM_NAME: OnceLock<RwLock<Option<String>>> = OnceLock::new();
|
||||||
@@ -56,28 +57,6 @@ static GLOBAL_CONFIGS: OnceLock<RwLock<HashMap<TypeId, &'static (dyn Any + Send
|
|||||||
/// Standardname für Konfigurationsdateien.
|
/// Standardname für Konfigurationsdateien.
|
||||||
const DEFAULT_CONFIG_NAME: &str = "config";
|
const DEFAULT_CONFIG_NAME: &str = "config";
|
||||||
|
|
||||||
/// Prüft, ob das Programm mit Root-/Administrator-Rechten ausgeführt wird.
|
|
||||||
///
|
|
||||||
/// # Returns
|
|
||||||
///
|
|
||||||
/// * `true` - Das Programm läuft mit erhöhten Rechten (z. B. UID 0 unter Linux/Unix)
|
|
||||||
/// * `false` - Das Programm läuft mit normalen Benutzerrechten
|
|
||||||
pub fn is_run_as_root() -> bool {
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
{
|
|
||||||
std::process::Command::new("net")
|
|
||||||
.args(["session"])
|
|
||||||
.output()
|
|
||||||
.map(|output| output.status.success())
|
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
{
|
|
||||||
unsafe { libc::geteuid() == 0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Setzt den Programmnamen für die Pfadermittlung explizit.
|
/// Setzt den Programmnamen für die Pfadermittlung explizit.
|
||||||
pub fn set_program_name(name: impl Into<String>) {
|
pub fn set_program_name(name: impl Into<String>) {
|
||||||
let lock = PROGRAM_NAME.get_or_init(|| RwLock::new(None));
|
let lock = PROGRAM_NAME.get_or_init(|| RwLock::new(None));
|
||||||
|
|||||||
Reference in New Issue
Block a user