Skip to content

Conversation

RottenRat
Copy link
Contributor

@RottenRat RottenRat commented Sep 10, 2025

Description

Added support for rule-specific impact configuration at the module level, allowing you to override the severity level (error/warn/ignored) for specific linter rules.

What's added

1. Rule-specific Impact in Linter Settings

  • Added the RulesSettings map[string]RuleSettings field to all linter settings structures
  • Added the GetRuleImpact(ruleName string) *pkg.Level and SetRuleImpact(ruleName string, impact *pkg.Level) methods for all linter settings
  • Support for rule-specific impact for all linters: module, container, hooks, images, no-cyrillic, openapi, rbac, templates

2. Rule Impact Function in Error System

  • Added type RuleImpactFunc func(linterID, ruleID string) *pkg.Level in pkg/errors/errors.go
  • Added the ruleImpactFunc RuleImpactFunc field to the LintRuleErrorsList structure
  • Updated the add method to apply rule-specific impact before maxLevel

3. Improved error display

  • Updated the emoji display logic in internal/manager/manager.go

4. DTO/Runtime Architecture Separation

  • Added Runtime structures in pkg/config/runtime.go:
    RuntimeRootConfig, RuntimeLintersSettings for execution

  • Added remapper functions in pkg/config/remapper.go:
    ToRuntime() methods for converting DTO -> Runtime with global settings merging

  • Added adapter functions in pkg/config/adapter.go:
    ToLintersSettings() for backward compatibility with existing linters

5. Configuration Loading Refactoring

  • Updated module loading in internal/module/module.go. Now loads configuration using DTO -> Runtime -> Legacy flow
  • Proper separation of concerns between data loading and business logic
  • Now uses RuleImpactFunc for applying rule-specific impact

Local module configuration (dmt-config.yaml in the module folder):

linters-settings:
  module:
    impact: error
    rules-settings:
      definition-file:
        impact: warn
      helmignore:
        impact: warn
      oss:
        impact: ignored
  container:
    impact: error
    rules-settings:
      api-version:
        impact: warn
      image-digest:
        impact: ignored

Tests

Linter No rule With rule Waiting for
object-api-version 🐒 (error) ⚠️ (warning) api-version: warn
definition-file 🐒 (error) ⚠️ (warning) definition-file: warn
helmignore 🐒 (error) ⚠️ (warning) helmignore: warn
image-digest 🐒 (error) ignored image-digest: ignored
oss 🐒 (error) ignored oss: ignored
no specific rules 🐒 (error) 🐒 (error) as in it

Signed-off-by: Sinelnikov Michail <[email protected]>
@RottenRat RottenRat self-assigned this Sep 10, 2025
Sinelnikov Michail added 6 commits September 10, 2025 17:24
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
@RottenRat RottenRat changed the title Add feature flag [dmt] Add feature flag Sep 11, 2025
Sinelnikov Michail and others added 12 commits September 11, 2025 18:20
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Pavel Okhlopkov <[email protected]>
Signed-off-by: Pavel Okhlopkov <[email protected]>
@ldmonster ldmonster closed this Sep 19, 2025
@ldmonster ldmonster deleted the add-feature-flag branch October 3, 2025 13:43
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