Skip to content

Conversation

@juev
Copy link
Contributor

@juev juev commented Jul 2, 2025

This pull request introduces significant improvements to the werf linter by enhancing validation logic, refactoring existing methods, and adding comprehensive unit tests. Additionally, it modifies the WriteProto method in promremote.go to improve context handling. The most important changes are grouped below by theme:

Enhancements to werf linter:

  • Added new fields (FromImage and ImageSpec.Config.User) to the werfFile struct for more granular validation of werf.yaml files.
  • Refactored LintWerfFile to support module-specific validation, handle invalid YAML documents gracefully, and validate new fields such as fromImage and imageSpec.config.user.
  • Improved splitManifests function to correctly split YAML documents and return a slice instead of a map.
  • Enhanced isWerfImagesCorrect to validate image paths against stricter criteria (base or common).

Unit tests for werf linter:

  • Added comprehensive test coverage for LintWerfFile, including validation of fromImage, handling of deprecated directives, and multiple YAML documents.

Example:

🐒 [werf (#images)]
     Message:     `fromImage:` parameter should be one of our `base` images
     Module:      terraform-manager
     Object:      werf.yaml:manifest-175
     Value:       fromImage: terraform-manager/base-terraform-manager-opentofu

🐒 [werf (#images)]
     Message:     `fromImage:` parameter should be one of our `base` images
     Module:      terraform-manager
     Object:      werf.yaml:manifest-172
     Value:       fromImage: terraform-manager/base-terraform-manager

🐒 [werf (#images)]
     Message:     `imageSpec.config.user:` parameter should be empty
     Module:      ingress-nginx
     Object:      werf.yaml:manifest-163
     Value:       imageSpec.config.user: www-data

🐒 [werf (#images)]
     Message:     `imageSpec.config.user:` parameter should be empty
     Module:      istio
     Object:      werf.yaml:manifest-179
     Value:       imageSpec.config.user: 1337:1337

Added some excludes:

  • istio and ingress-nginx modules from imageSpec.config.user: checks. This checks produced warn. After fixing, these exceptions need to be removed.
  • permanent exclude terraform-manager from base images checks.

@juev juev self-assigned this Jul 2, 2025
@juev juev force-pushed the feature/werf-images branch from 65c6b55 to 1360cd4 Compare August 1, 2025 05:38
@juev juev requested a review from ldmonster August 1, 2025 05:50
@juev juev marked this pull request as ready for review August 1, 2025 05:59
…werf-images

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
@ldmonster ldmonster merged commit 4e4506c into main Aug 1, 2025
2 checks passed
@ldmonster ldmonster deleted the feature/werf-images branch August 1, 2025 13:55
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.

3 participants