Skip to content

feat: corn source#384

Open
robjtede wants to merge 1 commit intomainfrom
corn-source
Open

feat: corn source#384
robjtede wants to merge 1 commit intomainfrom
corn-source

Conversation

@robjtede
Copy link
Copy Markdown
Member

@robjtede robjtede commented Mar 25, 2026

Noticed this was a file type supported by config and seems pretty cool actually.

Summary by CodeRabbit

  • New Features

    • Added optional CORN configuration support (gated by an off-by-default feature) to load settings from .corn files and CORN string literals.
  • Documentation

    • Updated configuration sources docs to include CORN format and feature gating notes.
  • Tests

    • Added tests covering CORN parsing and secret-field handling.
  • Chores

    • Adjusted private toolchain downgrade recipe for compatibility.

@robjtede robjtede force-pushed the corn-source branch 2 times, most recently from 55c2374 to 1da667d Compare April 1, 2026 03:06
@robjtede robjtede marked this pull request as ready for review April 1, 2026 04:28
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

Adds CORN format support behind a new corn-0_10 crate feature: introduces a CornSource type, wires a corn extension into FileSource parsing, adds feature-gated tests and docs, and registers an optional libcorn dependency in Cargo.toml.

Changes

Cohort / File(s) Summary
Cargo Manifest
confik/Cargo.toml
Added feature corn-0_10 = ["dep:libcorn-0_10"] and optional dependency libcorn-0_10 = { package = "libcorn", version = "0.10", optional = true }.
Docs
confik/src/lib.md, confik/CHANGELOG.md
Documented .corn support and new CornSource; added changelog entry under Unreleased.
Public API / Module Exports
confik/src/lib.rs, confik/src/sources/mod.rs
Added feature-gated pub use of CornSource and conditional pub(crate) mod corn_source;.
New Source Implementation
confik/src/sources/corn_source.rs
Added CornSource<'a> with new() and allow_secrets(); implemented Source<T> (parsing via libcorn_0_10::from_str), Debug, and unit tests.
FileSource Extension
confik/src/sources/file_source.rs
Added FileErrorKind::Corn (feature-gated); extended extension dispatch to parse .corn files when feature enabled; added feature-gated test.
Tests
confik/tests/main.rs, confik/tests/secret/mod.rs
Added feature-gated tests verifying CORN parsing and secret-field rejection behavior.
Build Tooling
justfile
Extended downgrade-for-msrv recipe to include additional cargo toolchain update commands for pest-related crates.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: RON support #379: Adds parallel feature-gated config source support (ron-0_12), with equivalent structural changes across Cargo.toml, lib.rs, sources/mod.rs, source implementations, and feature-gated tests.

Poem

🐰 In a meadow of bytes I scurry and spin,
A corn-string climbs in, and parsing begins.
With a hop and a nibble the config takes form,
Secrets stay guarded till you give them the norm.
Hooray for new sources — a crunchy new morn! 🌽

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: corn source' directly and clearly summarizes the main change: adding support for Corn as a configuration source.
Docstring Coverage ✅ Passed Docstring coverage is 93.75% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch corn-source

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
confik/src/sources/corn_source.rs (1)

57-94: Tests provide good coverage; verbose trait syntax is correct but could be simplified.

The tests adequately cover parsing, error propagation, and secrets flag functionality. The fully-qualified trait method syntax (e.g., <CornSource<'_> as Source<...>>::provide(&source)) works correctly but could be simplified to Source::<...>::provide(&source) or just source.provide() since the trait is in scope.

🔧 Optional: Simplify test method calls
     #[test]
     fn provides_corn_data() {
         let source = CornSource::new("{ value = 42 }");
 
-        let config =
-            <CornSource<'_> as Source<<TestConfig as crate::Configuration>::Builder>>::provide(
-                &source,
-            )
+        let config = source
+            .provide()
             .unwrap()
             .try_build()
             .unwrap();
 
         assert_eq!(config, TestConfig { value: 42 });
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@confik/src/sources/corn_source.rs` around lines 57 - 94, Tests use overly
verbose fully-qualified trait syntax when calling provide and allows_secrets;
simplify by calling the methods directly or with shorter turbofish forms.
Replace occurrences of `<CornSource<'_> as Source<<TestConfig as
crate::Configuration>::Builder>>::provide(&source)` with either
`source.provide()` or `Source::<TestConfig::Builder>::provide(&source)` and
similarly replace the long `allows_secrets` invocation with
`source.allows_secrets()` or
`Source::<TestConfig::Builder>::allows_secrets(&source)` while keeping the same
assertions; the relevant symbols are CornSource::new, provide, allows_secrets,
Source, and TestConfig.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@confik/src/sources/corn_source.rs`:
- Around line 57-94: Tests use overly verbose fully-qualified trait syntax when
calling provide and allows_secrets; simplify by calling the methods directly or
with shorter turbofish forms. Replace occurrences of `<CornSource<'_> as
Source<<TestConfig as crate::Configuration>::Builder>>::provide(&source)` with
either `source.provide()` or `Source::<TestConfig::Builder>::provide(&source)`
and similarly replace the long `allows_secrets` invocation with
`source.allows_secrets()` or
`Source::<TestConfig::Builder>::allows_secrets(&source)` while keeping the same
assertions; the relevant symbols are CornSource::new, provide, allows_secrets,
Source, and TestConfig.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: d7f04ec7-f33b-4bbe-869e-6dd07f5d6c7f

📥 Commits

Reviewing files that changed from the base of the PR and between 1da667d and 9d6044e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • confik/CHANGELOG.md
  • confik/Cargo.toml
  • confik/src/lib.md
  • confik/src/lib.rs
  • confik/src/sources/corn_source.rs
  • confik/src/sources/file_source.rs
  • confik/src/sources/mod.rs
  • confik/tests/main.rs
  • confik/tests/secret/mod.rs
  • justfile
✅ Files skipped from review due to trivial changes (6)
  • confik/CHANGELOG.md
  • confik/src/sources/mod.rs
  • confik/src/lib.md
  • confik/tests/secret/mod.rs
  • confik/tests/main.rs
  • confik/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • confik/src/lib.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant