Skip to content

Add LocalFileProvider for custom domains#78

Merged
shilingwang merged 2 commits intomainfrom
shiling/local-file-provider
Feb 3, 2026
Merged

Add LocalFileProvider for custom domains#78
shilingwang merged 2 commits intomainfrom
shiling/local-file-provider

Conversation

@shilingwang
Copy link
Contributor

@shilingwang shilingwang commented Feb 3, 2026

#Node-1842

Summary

Adds a new LocalFileProvider that enables reading custom domain-to-canister mappings from local files, providing a simpler alternative to URL-based providers for development and testing scenarios.

Changes

  • New Provider: LocalFileProvider reads domain mappings from local files
  • File Format: Simple colon-separated format (domain:principal)
  • Robust Parsing: Validates FQDNs and principals with clear error messages
  • Comprehensive Tests: 9 unit tests covering valid inputs, error cases, and edge cases
  • Documentation: Clear docs with file format examples

Example File Format

example.com:aaaaa-aa
test.org:qoctq-giaaa-aaaaa-aaaea-cai
my-domain.net:ryjl3-tyaaa-aaaaa-aaaba-cai

Test Coverage

All tests pass (9/9):

  • ✅ Valid domain:principal pairs
  • ✅ Empty lines and whitespace handling
  • ✅ Invalid format detection (missing/multiple colons)
  • ✅ Invalid domain/principal validation
  • ✅ File not found error handling
  • ✅ Empty file handling

Introduces a new LocalFileProvider that reads custom domain-to-canister
mappings from a local file. The provider supports a simple colon-separated
format (domain:principal) and includes proper error handling for invalid
formats, malformed FQDNs, and invalid principals.

Key features:
- Reads domain:principal mappings from local files
- Skips empty lines and trims whitespace
- Validates domains as FQDNs and principals
- Comprehensive test coverage (9 unit tests)
- Clear documentation with file format examples
@shilingwang shilingwang requested a review from a team as a code owner February 3, 2026 12:33
- Replace String with PathBuf for file_path field (more idiomatic)
- Add fmt::{self, Debug} imports and use shorter references
- Update Debug implementations to use fmt:: prefix instead of std::fmt::
- Fix test to use sort_by instead of sorted_by_key for better performance
- Update test constructors to use PathBuf-friendly methods
- Clean up whitespace and formatting
@shilingwang shilingwang merged commit 37725fe into main Feb 3, 2026
6 checks passed
@shilingwang shilingwang deleted the shiling/local-file-provider branch February 3, 2026 13:22
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.

2 participants