Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ DMT includes **9 specialized linters** to validate different aspects of your Dec
| [**NoCyrillic**](pkg/linters/no-cyrillic/README.md) | Character encoding | Cyrillic characters in code/config files |
| [**OpenAPI**](pkg/linters/openapi/README.md) | OpenAPI schemas | Schema validation, CRD definitions, naming conventions |
| [**RBAC**](pkg/linters/rbac/README.md) | Security policies | Role bindings, service accounts, wildcards |
| [**Templates**](pkg/linters/templates/README.md) | Kubernetes templates | VPA/PDB settings, Prometheus rules, Grafana dashboards, service ports, mount-points |
| [**Templates**](pkg/linters/templates/README.md) | Kubernetes templates | VPA/PDB settings, Prometheus rules, Grafana dashboards, service ports, mount-points, Ingress/Gateway API enablement, deprecated annotations |

### 🚀 Module Bootstrapping

Expand Down
9 changes: 9 additions & 0 deletions internal/modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ func mapTemplatesRules(linterSettings *pkg.LintersSettings, configSettings *conf
rules.HelmRenderRule.SetLevel(globalRules.HelmRenderRule.Impact, fallbackImpact)
rules.OpenAPIValuesQuoteRule.SetLevel(globalRules.OpenAPIValuesQuoteRule.Impact, fallbackImpact)
rules.SchemaValidationRule.SetLevel(globalRules.SchemaValidationRule.Impact, fallbackImpact)
rules.DeprecatedHTTPRouteAnnotationsRule.SetLevel(globalRules.DeprecatedHTTPRouteAnnotationsRule.Impact, fallbackImpact)
rules.IngressEnablementRule.SetLevel(globalRules.IngressEnablementRule.Impact, fallbackImpact)
rules.GatewayEnablementRule.SetLevel(globalRules.GatewayEnablementRule.Impact, fallbackImpact)
}

// mapOpenAPIRules configures OpenAPI linter rules
Expand Down Expand Up @@ -552,6 +555,12 @@ func mapTemplatesExclusionsAndSettings(linterSettings *pkg.LintersSettings, conf
excludes.MountPoints = pkg.StringRuleExcludeList(configExcludes.MountPoints)
excludes.OpenAPIValuesQuote = pkg.StringRuleExcludeList(configExcludes.OpenAPIValuesQuote)
excludes.SchemaValidation = configExcludes.SchemaValidation.Get()
excludes.DeprecatedHTTPRouteAnnotations.Files = pkg.StringRuleExcludeList(configExcludes.DeprecatedHTTPRouteAnnotations.Files)
excludes.DeprecatedHTTPRouteAnnotations.Directories = pkg.DirectoryRuleExcludeList(configExcludes.DeprecatedHTTPRouteAnnotations.Directories)
excludes.IngressEnablement.Files = pkg.StringRuleExcludeList(configExcludes.IngressEnablement.Files)
excludes.IngressEnablement.Directories = pkg.DirectoryRuleExcludeList(configExcludes.IngressEnablement.Directories)
excludes.GatewayEnablement.Files = pkg.StringRuleExcludeList(configExcludes.GatewayEnablement.Files)
excludes.GatewayEnablement.Directories = pkg.DirectoryRuleExcludeList(configExcludes.GatewayEnablement.Directories)

// Additional settings
linterSettings.Templates.PrometheusRuleSettings.Disable = configSettings.Templates.PrometheusRules.Disable
Expand Down
69 changes: 41 additions & 28 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,26 @@ type TemplatesLinterConfig struct {
GrafanaDashboardsSettings GrafanaDashboardsSettings
}
type TemplatesLinterRules struct {
VPARule RuleConfig
PDBRule RuleConfig
IngressRule RuleConfig
PrometheusRule RuleConfig
GrafanaRule RuleConfig
KubeRBACProxyRule RuleConfig
ServicePortRule RuleConfig
ClusterDomainRule RuleConfig
RegistryRule RuleConfig
HTTPRouteRule RuleConfig
EnabledModulesRule RuleConfig
CRDEnabledModulesRule RuleConfig
WebhookConfigurationRule RuleConfig
MountPointsRule RuleConfig
HelmRenderRule RuleConfig
OpenAPIValuesQuoteRule RuleConfig
SchemaValidationRule RuleConfig
VPARule RuleConfig
PDBRule RuleConfig
IngressRule RuleConfig
PrometheusRule RuleConfig
GrafanaRule RuleConfig
KubeRBACProxyRule RuleConfig
ServicePortRule RuleConfig
ClusterDomainRule RuleConfig
RegistryRule RuleConfig
HTTPRouteRule RuleConfig
EnabledModulesRule RuleConfig
CRDEnabledModulesRule RuleConfig
WebhookConfigurationRule RuleConfig
MountPointsRule RuleConfig
HelmRenderRule RuleConfig
OpenAPIValuesQuoteRule RuleConfig
SchemaValidationRule RuleConfig
DeprecatedHTTPRouteAnnotationsRule RuleConfig
IngressEnablementRule RuleConfig
GatewayEnablementRule RuleConfig
}

type PrometheusRuleSettings struct {
Expand All @@ -164,17 +167,27 @@ type GrafanaDashboardsSettings struct {
Disable bool
}
type TemplatesExcludeRules struct {
VPAAbsent KindRuleExcludeList
PDBAbsent KindRuleExcludeList
ServicePort ServicePortExcludeList
KubeRBACProxy StringRuleExcludeList
Ingress KindRuleExcludeList
HTTPRoute KindRuleExcludeList
EnabledModules EnabledModulesExcludeRule
WebhookConfiguration KindRuleExcludeList
MountPoints StringRuleExcludeList
OpenAPIValuesQuote StringRuleExcludeList
SchemaValidation KindRuleExcludeList
VPAAbsent KindRuleExcludeList
PDBAbsent KindRuleExcludeList
ServicePort ServicePortExcludeList
KubeRBACProxy StringRuleExcludeList
Ingress KindRuleExcludeList
HTTPRoute KindRuleExcludeList
EnabledModules EnabledModulesExcludeRule
WebhookConfiguration KindRuleExcludeList
MountPoints StringRuleExcludeList
OpenAPIValuesQuote StringRuleExcludeList
SchemaValidation KindRuleExcludeList
DeprecatedHTTPRouteAnnotations PathRuleExclude
IngressEnablement PathRuleExclude
GatewayEnablement PathRuleExclude
}

// PathRuleExclude excludes specific files and whole directories (both relative
// to the module root) from a rule that scans template source files.
type PathRuleExclude struct {
Files StringRuleExcludeList
Directories DirectoryRuleExcludeList
}

type EnabledModulesExcludeRule struct {
Expand Down
37 changes: 20 additions & 17 deletions pkg/config/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,26 @@ type TemplatesLinterConfig struct {
}

type TemplatesLinterRules struct {
VPARule RuleConfig `mapstructure:"vpa"`
PDBRule RuleConfig `mapstructure:"pdb"`
IngressRule RuleConfig `mapstructure:"ingress"`
HTTPRouteRule RuleConfig `mapstructure:"httproute"`
PrometheusRule RuleConfig `mapstructure:"prometheus-rules"`
GrafanaRule RuleConfig `mapstructure:"grafana-dashboards"`
KubeRBACProxyRule RuleConfig `mapstructure:"kube-rbac-proxy"`
ServicePortRule RuleConfig `mapstructure:"service-port"`
ClusterDomainRule RuleConfig `mapstructure:"cluster-domain"`
RegistryRule RuleConfig `mapstructure:"registry"`
EnabledModulesRule RuleConfig `mapstructure:"enabled-modules"`
CRDEnabledModulesRule RuleConfig `mapstructure:"crd-enabled-modules"`
WebhookConfigurationRule RuleConfig `mapstructure:"webhook-configuration-annotations"`
MountPointsRule RuleConfig `mapstructure:"mount-points"`
HelmRenderRule RuleConfig `mapstructure:"helm-render"`
OpenAPIValuesQuoteRule RuleConfig `mapstructure:"openapi-values-quote"`
SchemaValidationRule RuleConfig `mapstructure:"schema-validation"`
VPARule RuleConfig `mapstructure:"vpa"`
PDBRule RuleConfig `mapstructure:"pdb"`
IngressRule RuleConfig `mapstructure:"ingress"`
HTTPRouteRule RuleConfig `mapstructure:"httproute"`
PrometheusRule RuleConfig `mapstructure:"prometheus-rules"`
GrafanaRule RuleConfig `mapstructure:"grafana-dashboards"`
KubeRBACProxyRule RuleConfig `mapstructure:"kube-rbac-proxy"`
ServicePortRule RuleConfig `mapstructure:"service-port"`
ClusterDomainRule RuleConfig `mapstructure:"cluster-domain"`
RegistryRule RuleConfig `mapstructure:"registry"`
EnabledModulesRule RuleConfig `mapstructure:"enabled-modules"`
CRDEnabledModulesRule RuleConfig `mapstructure:"crd-enabled-modules"`
WebhookConfigurationRule RuleConfig `mapstructure:"webhook-configuration-annotations"`
MountPointsRule RuleConfig `mapstructure:"mount-points"`
HelmRenderRule RuleConfig `mapstructure:"helm-render"`
OpenAPIValuesQuoteRule RuleConfig `mapstructure:"openapi-values-quote"`
SchemaValidationRule RuleConfig `mapstructure:"schema-validation"`
DeprecatedHTTPRouteAnnotationsRule RuleConfig `mapstructure:"deprecated-httproute-annotations"`
IngressEnablementRule RuleConfig `mapstructure:"ingress-enablement"`
GatewayEnablementRule RuleConfig `mapstructure:"gateway-enablement"`
}

func (c LinterConfig) IsWarn() bool {
Expand Down
69 changes: 41 additions & 28 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,44 +234,57 @@ type TemplatesSettings struct {
}

type TemplatesLinterRules struct {
VPARule RuleConfig `mapstructure:"vpa"`
PDBRule RuleConfig `mapstructure:"pdb"`
IngressRule RuleConfig `mapstructure:"ingress"`
HTTPRouteRule RuleConfig `mapstructure:"httproute"`
PrometheusRule RuleConfig `mapstructure:"prometheus-rules"`
GrafanaRule RuleConfig `mapstructure:"grafana-dashboards"`
KubeRBACProxyRule RuleConfig `mapstructure:"kube-rbac-proxy"`
ServicePortRule RuleConfig `mapstructure:"service-port"`
ClusterDomainRule RuleConfig `mapstructure:"cluster-domain"`
RegistryRule RuleConfig `mapstructure:"registry"`
EnabledModulesRule RuleConfig `mapstructure:"enabled-modules"`
CRDEnabledModulesRule RuleConfig `mapstructure:"crd-enabled-modules"`
WebhookConfigurationRule RuleConfig `mapstructure:"webhook-configuration-annotations"`
MountPointsRule RuleConfig `mapstructure:"mount-points"`
HelmRenderRule RuleConfig `mapstructure:"helm-render"`
OpenAPIValuesQuoteRule RuleConfig `mapstructure:"openapi-values-quote"`
SchemaValidationRule RuleConfig `mapstructure:"schema-validation"`
VPARule RuleConfig `mapstructure:"vpa"`
PDBRule RuleConfig `mapstructure:"pdb"`
IngressRule RuleConfig `mapstructure:"ingress"`
HTTPRouteRule RuleConfig `mapstructure:"httproute"`
PrometheusRule RuleConfig `mapstructure:"prometheus-rules"`
GrafanaRule RuleConfig `mapstructure:"grafana-dashboards"`
KubeRBACProxyRule RuleConfig `mapstructure:"kube-rbac-proxy"`
ServicePortRule RuleConfig `mapstructure:"service-port"`
ClusterDomainRule RuleConfig `mapstructure:"cluster-domain"`
RegistryRule RuleConfig `mapstructure:"registry"`
EnabledModulesRule RuleConfig `mapstructure:"enabled-modules"`
CRDEnabledModulesRule RuleConfig `mapstructure:"crd-enabled-modules"`
WebhookConfigurationRule RuleConfig `mapstructure:"webhook-configuration-annotations"`
MountPointsRule RuleConfig `mapstructure:"mount-points"`
HelmRenderRule RuleConfig `mapstructure:"helm-render"`
OpenAPIValuesQuoteRule RuleConfig `mapstructure:"openapi-values-quote"`
SchemaValidationRule RuleConfig `mapstructure:"schema-validation"`
DeprecatedHTTPRouteAnnotationsRule RuleConfig `mapstructure:"deprecated-httproute-annotations"`
IngressEnablementRule RuleConfig `mapstructure:"ingress-enablement"`
GatewayEnablementRule RuleConfig `mapstructure:"gateway-enablement"`
}

type TemplatesExcludeRules struct {
VPAAbsent KindRuleExcludeList `mapstructure:"vpa"`
PDBAbsent KindRuleExcludeList `mapstructure:"pdb"`
ServicePort ServicePortExcludeList `mapstructure:"service-port"`
KubeRBACProxy StringRuleExcludeList `mapstructure:"kube-rbac-proxy"`
Ingress KindRuleExcludeList `mapstructure:"ingress"`
HTTPRoute KindRuleExcludeList `mapstructure:"httproute"`
EnabledModules EnabledModulesExcludeRule `mapstructure:"enabled-modules"`
WebhookConfiguration KindRuleExcludeList `mapstructure:"webhook-configuration-annotations"`
MountPoints StringRuleExcludeList `mapstructure:"mount-points"`
OpenAPIValuesQuote StringRuleExcludeList `mapstructure:"openapi-values-quote"`
SchemaValidation KindRuleExcludeList `mapstructure:"schema-validation"`
VPAAbsent KindRuleExcludeList `mapstructure:"vpa"`
PDBAbsent KindRuleExcludeList `mapstructure:"pdb"`
ServicePort ServicePortExcludeList `mapstructure:"service-port"`
KubeRBACProxy StringRuleExcludeList `mapstructure:"kube-rbac-proxy"`
Ingress KindRuleExcludeList `mapstructure:"ingress"`
HTTPRoute KindRuleExcludeList `mapstructure:"httproute"`
EnabledModules EnabledModulesExcludeRule `mapstructure:"enabled-modules"`
WebhookConfiguration KindRuleExcludeList `mapstructure:"webhook-configuration-annotations"`
MountPoints StringRuleExcludeList `mapstructure:"mount-points"`
OpenAPIValuesQuote StringRuleExcludeList `mapstructure:"openapi-values-quote"`
SchemaValidation KindRuleExcludeList `mapstructure:"schema-validation"`
DeprecatedHTTPRouteAnnotations PathRuleExclude `mapstructure:"deprecated-httproute-annotations"`
IngressEnablement PathRuleExclude `mapstructure:"ingress-enablement"`
GatewayEnablement PathRuleExclude `mapstructure:"gateway-enablement"`
}

type EnabledModulesExcludeRule struct {
Files StringRuleExcludeList `mapstructure:"files"`
Directories DirectoryRuleExcludeList `mapstructure:"directories"`
}

// PathRuleExclude excludes specific files and whole directories (both relative
// to the module root) from a rule that scans template source files.
type PathRuleExclude struct {
Files StringRuleExcludeList `mapstructure:"files"`
Directories DirectoryRuleExcludeList `mapstructure:"directories"`
}

type GrafanaDashboardsExcludeList struct {
Disable bool `mapstructure:"disable"`
}
Expand Down
Loading
Loading