Skip to content

[dmt] Validate package.yaml requirements#359

Open
diyliv wants to merge 2 commits into
mainfrom
feature/package-yaml-requirements-validation
Open

[dmt] Validate package.yaml requirements#359
diyliv wants to merge 2 commits into
mainfrom
feature/package-yaml-requirements-validation

Conversation

@diyliv
Copy link
Copy Markdown
Contributor

@diyliv diyliv commented May 14, 2026

Summary

Add package.yaml requirements validation for the new module requirements schema:

  • Parse package.yaml metadata and subscribe sections: Read apiVersion, name, requirements, and subscribe fields used by module package validation.
  • Validate package.yaml requirements constraints as-is: Parse all non-empty Kubernetes, Deckhouse, mandatory, conditional, and anyOf module constraints with semver without stripping legacy markers such as !optional.
  • Require Deckhouse >= 1.77 for new requirements schema: When the new requirements structure is used, require requirements.deckhouse.constraint and ensure its lower bound starts no lower than 1.77.0.

Example

apiVersion: v2
name: stronghold

requirements:
  kubernetes:
    constraint: ">= 1.26"
  deckhouse:
    constraint: ">= 1.77.0"
  modules:
    mandatory:
      - name: cloud-provider-yandex
        constraint: ">= 1.5.0"
    conditional:
      - name: observability
        constraint: ">= 1.0.0"
    anyOf:
      - description: "One of the following cloud providers must be installed"
        modules:
          - name: cloud-provider-gcp
            constraint: ">= 1.5.0"
          - name: cloud-provider-aws
            constraint: ">= 2.0.0"

Legacy markers in constraint fields are rejected:

requirements:
  modules:
    conditional:
      - name: observability
        constraint: ">= 1.0.0 !optional"

@diyliv diyliv requested review from ipaqsa and ldmonster May 14, 2026 09:44
@diyliv diyliv self-assigned this May 14, 2026
@diyliv diyliv force-pushed the feature/package-yaml-requirements-validation branch 3 times, most recently from f7d70d7 to 3eb672f Compare May 14, 2026 19:47
Signed-off-by: diyliv <onlogn081@gmail.com>
@diyliv diyliv force-pushed the feature/package-yaml-requirements-validation branch from 3eb672f to abda470 Compare May 16, 2026 14:07
@diyliv diyliv added enhancement New feature or request go Pull requests that update go code labels May 17, 2026
@diyliv diyliv changed the title [dmt] Validate package.yaml requirements [dmt] Validate package.yaml and module.yaml consistency May 19, 2026
@diyliv diyliv changed the title [dmt] Validate package.yaml and module.yaml consistency [dmt] Validate package.yaml requirements May 19, 2026
@ldmonster ldmonster requested a review from Copilot May 21, 2026 07:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Module linter rule to validate optional package.yaml metadata and enforce constraints for the new module requirements schema (including a minimum Deckhouse version when the new schema is detected).

Changes:

  • Introduces package-yaml rule: parses package.yaml, validates required metadata, validates semver constraints “as-is”, and enforces requirements.deckhouse.constraint >= 1.77.0 when the new schema is used.
  • Adds unit tests covering parsing, metadata validation, constraint validation, and the Deckhouse-minimum requirement logic.
  • Wires the new rule into module linter execution and global rule configuration, and documents the new rule in the module linter README.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/linters/module/rules/package_yaml.go Implements the new package.yaml parsing + validation rule, including Deckhouse >= 1.77.0 enforcement for the new schema.
pkg/linters/module/rules/package_yaml_test.go Adds test coverage for parsing and validation behaviors of the new rule.
pkg/linters/module/README.md Documents the new package-yaml rule and updates the rules list/count and examples.
pkg/linters/module/module.go Registers and runs the new package-yaml rule during module linting.
pkg/config/global/global.go Adds package-yaml to global module rule configs (impact mapping).
pkg/config.go Adds PackageYAMLRule to the runtime module linter rules config struct.
internal/module/module.go Maps global rule impact configuration into the runtime PackageYAMLRule level.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +245 to +252
constraint, err := semver.NewConstraint(deckhouseConstraint)
if err != nil {
return
}

minAllowed := findMinimalAllowedVersion(constraint)

minimalVersion, err := semver.NewVersion(MinimalDeckhouseVersionForPackageRequirements)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread pkg/linters/module/README.md Outdated
Comment on lines +528 to +530
rules:
package-yaml:
impact: error # Override package.yaml validation level
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@diyliv diyliv marked this pull request as draft May 21, 2026 09:04
… rules section from README

Signed-off-by: diyliv <onlogn081@gmail.com>
@diyliv diyliv force-pushed the feature/package-yaml-requirements-validation branch from 515b434 to 0b895cd Compare May 21, 2026 13:18
@diyliv diyliv marked this pull request as ready for review May 22, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants