[dmt] add webhook configuration annotations lint rule#412
Open
diyliv wants to merge 13 commits into
Open
Conversation
Check that ValidatingWebhookConfiguration and MutatingWebhookConfiguration resources have either werf.io/weight or werf.io/deploy-dependency annotation for proper deploy ordering. Signed-off-by: diyliv <onlogn081@gmail.com>
016450e to
d8cea88
Compare
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
…yaml Use Errorf in the rule so impact level can be escalated to error. Default to warn when neither global nor module config sets the rule level. Signed-off-by: diyliv <onlogn081@gmail.com>
… exclusions Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
9dc3168 to
3babd14
Compare
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
50a2f5b to
b62906b
Compare
Signed-off-by: diyliv <onlogn081@gmail.com>
Signed-off-by: diyliv <onlogn081@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
webhook_configuration.go): checks that everyValidatingWebhookConfiguration/MutatingWebhookConfigurationresource has at least one of the annotationswerf.io/weightorwerf.io/deploy-dependency. If neither annotation is present — error.GetStorage(), filters by kindValidatingWebhookConfigurationorMutatingWebhookConfiguration. Non-webhook resources are skipped.object.Unstructured.GetAnnotations()directly on the unstructured object. Presence of eitherwerf.io/weightorwerf.io/deploy-dependencysatisfies the rule.errorList.WithObjectID()and the source file viaerrorList.WithFilePath().WebhookConfigurationRule RuleConfig+WebhookConfiguration KindRuleExcludeListto runtime config (pkg/config.go), YAML config (pkg/config/linters_settings.go), and global overrides (pkg/config/global/global.go). Level mapping inmapTemplatesRules()and exclusion mapping inmapTemplatesExclusionsAndSettings()(internal/module/module.go).NewWebhookConfigurationRule(...).ValidateWebhookConfigurationAnnotations(...)call added to theRun()method of the templates linter (templates.go).Context
Without
werf.io/weightorwerf.io/deploy-dependencyannotations, webhook configurations may deploy in an undefined order or without proper dependency ordering. These annotations control werf's deploy sequencing:werf.io/weightsets explicit ordering priority, whilewerf.io/deploy-dependencydeclares a dependency on another resource. The rule ensures that every webhook configuration explicitly declares its place in the deploy order.Example
ValidatingWebhookConfiguration without annotations:
Result: error —
ValidatingWebhookConfiguration "my-webhook" must have either "werf.io/weight" or "werf.io/deploy-dependency" annotation.Fixed version:
Excluding resources
Per-resource exclusion via
KindRuleExclude(kind + name). Disable the rule entirely by setting impact toignored.