Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
refactor(src/config.rs): rename Adapter to AdapterConfig
Lars Wirzenius committed 1 year ago
commit b8171031f6e44db7159c40b2fd66b0da7830fba0
parent 3ca4462e5ab1c99e5a93c921ddd711f726a557e8
2 files changed +6 -6
modified src/bin/cib.rs
@@ -266,7 +266,7 @@ impl ProcessEventsCmd {

        let mut broker =
            Broker::new(config.db(), config.max_run_time()).map_err(CibError::new_broker)?;
-
        let spec = config.default_adapter().map_err(CibError::DefaultAdapter)?;
+
        let spec = config.default_adapter()?;
        let adapter = Adapter::new(&spec.command)
            .with_environment(spec.envs())
            .with_sensitive_environment(spec.sensitive_envs());
modified src/config.rs
@@ -18,7 +18,7 @@ const DEFAULT_STATUS_PAGE_UPDATE_INTERVAL: u64 = 10;
#[derive(Debug, Serialize, Deserialize)]
pub struct Config {
    default_adapter: String,
-
    adapters: HashMap<String, Adapter>,
+
    adapters: HashMap<String, AdapterConfig>,
    filters: Vec<EventFilter>,
    report_dir: Option<PathBuf>,
    status_update_interval_seconds: Option<u64>,
@@ -60,7 +60,7 @@ impl Config {
        &self.default_adapter
    }

-
    pub fn default_adapter(&self) -> Result<&Adapter, ConfigError> {
+
    pub fn default_adapter(&self) -> Result<&AdapterConfig, ConfigError> {
        self.adapters
            .get(&self.default_adapter)
            .ok_or(ConfigError::NoDefaultAdapter)
@@ -88,7 +88,7 @@ impl Config {
    }
}

-
impl fmt::Debug for Adapter {
+
impl fmt::Debug for AdapterConfig {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
@@ -104,14 +104,14 @@ impl fmt::Debug for Adapter {
}

#[derive(Serialize, Deserialize)]
-
pub struct Adapter {
+
pub struct AdapterConfig {
    pub command: PathBuf,
    pub env: HashMap<String, String>,
    #[serde(default)]
    pub sensitive_env: HashMap<String, Sensitive>,
}

-
impl Adapter {
+
impl AdapterConfig {
    pub fn envs(&self) -> &HashMap<String, String> {
        &self.env
    }