Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: refuse configuration files with unknown fields
Merged liw opened 1 year ago

Signed-off-by: Lars Wirzenius liw@liw.fi

2 files changed +38 -0 a3dbd8f8 14ad23cc
modified ci-broker.md
@@ -307,6 +307,43 @@ then command is successful
~~~


+
## Refuses config with an unknown field
+

+
_Want:_ The CI broker refused to load a configuration file that has
+
unknown fields.
+

+
_Why:_ This is helpful for detecting typos and other mistakes in
+
configuration files instead of ignoring them silently.
+

+
_Who:_ `cib-devs`, `node-ops`
+

+
~~~scenario
+
given a Radicle node, with CI configured with buggy.yaml and adapter dummy.sh
+
when I try to run cib --config buggy.yaml config
+
then command fails
+
then stderr contains "xyzzy"
+
then stderr contains "unknown field"
+
~~~
+

+
~~~{#buggy.yaml .file .yaml}
+
db: ci-broker.db
+
report_dir: reports
+
queue_len_interval: 1min
+
adapters:
+
  mcadapterface:
+
    command: ./adapter.sh
+
    env:
+
      RADICLE_NATIVE_CI: native-ci.yaml
+
    sensitive_env:
+
      API_KEY: xyzzy
+
triggers:
+
  - adapter: mcadapterface
+
    filters:
+
      - !Branch "main"
+
xyzzy: "this field is unknown"
+
~~~
+

+

## Smoke test: Runs adapter

_Want:_ CI broker can run its adapter.
modified src/config.rs
@@ -20,6 +20,7 @@ const DEFAULT_QUEUE_LEN_INTERVAL: Duration = Duration::from_secs(3600);
const DEFAULT_STATUS_PAGE_UPDATE_INTERVAL: u64 = 10;

#[derive(Debug, Serialize, Deserialize)]
+
#[serde(deny_unknown_fields)]
pub struct Config {
    default_adapter: Option<String>,
    adapters: HashMap<String, AdapterConfig>,