Expand description
Dclint-RS: Native Rust Docker Compose Linter
A Rust translation of the docker-compose-linter project.
§Attribution
This module is a derivative work based on docker-compose-linter, originally written in TypeScript by Sergey Kupletsky.
Original Project: https://github.com/zavoloklom/docker-compose-linter Original License: MIT
§Features
- Docker Compose YAML parsing with position tracking
- 15 configurable linting rules (DCL001-DCL015)
- Auto-fix capability for 8 rules
- Multiple output formats (JSON, Stylish, GitHub Actions, etc.)
- Comment-based rule disabling
§Example
ⓘ
use syncable_cli::analyzer::dclint::{lint, DclintConfig, LintResult};
let compose = r#"
services:
web:
image: nginx:latest
ports:
- "8080:80"
"#;
let config = DclintConfig::default();
let result = lint(compose, &config);
for failure in result.failures {
println!("{}: {} - {}", failure.line, failure.code, failure.message);
}§Rules
| Code | Name | Fixable | Description |
|---|---|---|---|
| DCL001 | no-build-and-image | No | Service cannot have both build and image |
| DCL002 | no-duplicate-container-names | No | Container names must be unique |
| DCL003 | no-duplicate-exported-ports | No | Exported ports must be unique |
| DCL004 | no-quotes-in-volumes | Yes | Volume paths should not be quoted |
| DCL005 | no-unbound-port-interfaces | No | Ports should bind to specific interface |
| DCL006 | no-version-field | Yes | Version field is deprecated |
| DCL007 | require-project-name-field | No | Require top-level name field |
| DCL008 | require-quotes-in-ports | Yes | Port mappings should be quoted |
| DCL009 | service-container-name-regex | No | Container name format validation |
| DCL010 | service-dependencies-alphabetical-order | Yes | Sort depends_on alphabetically |
| DCL011 | service-image-require-explicit-tag | No | Images need explicit tags |
| DCL012 | service-keys-order | Yes | Service keys in standard order |
| DCL013 | service-ports-alphabetical-order | Yes | Sort ports alphabetically |
| DCL014 | services-alphabetical-order | Yes | Sort services alphabetically |
| DCL015 | top-level-properties-order | Yes | Top-level keys in standard order |
Re-exports§
pub use config::DclintConfig;pub use formatter::OutputFormat;pub use formatter::format_result;pub use formatter::format_result_to_string;pub use formatter::format_results;pub use lint::LintResult;pub use lint::fix_content;pub use lint::fix_file;pub use lint::lint;pub use lint::lint_file;pub use lint::lint_with_path;pub use types::CheckFailure;pub use types::ConfigLevel;pub use types::RuleCategory;pub use types::RuleCode;pub use types::RuleMeta;pub use types::Severity;
Modules§
- config
- Configuration for the dclint Docker Compose linter.
- formatter
- Output formatters for dclint results.
- lint
- Main linting orchestration for dclint.
- parser
- YAML parser for Docker Compose files.
- pragma
- Pragma handling for inline rule disabling.
- rules
- Rule system framework for dclint.
- types
- Core types for the dclint Docker Compose linter.