Skip to content
Merged
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: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ remote:
release: # ... the same command, <repo>/release:<tag>
module:
rules:
release-layout:
impact: error
changelog-valid:
impact: error
```
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestRunReportsTheSourceError(t *testing.T) {
// Both paths go through this function now, so one test covers both.
//
// The bundle scope over an empty directory is the fixture: none of the files that scope
// looks for are there, so both of its linters report — module via bundle-layout,
// looks for are there, so both of its linters report — module via has-changelog,
// documentation via readme. The unfiltered case is what makes the filtered one mean
// something; without it the filter would look correct even if nothing reported at all.
func TestLintModuleHonoursTheLinterFilter(t *testing.T) {
Expand Down
6 changes: 2 additions & 4 deletions internal/modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ func mapModuleRules(linterSettings *pkg.LintersSettings, configSettings *config.
rules.ModulePackageConsistencyRule.SetLevel(globalRules.ModulePackageConsistencyRule.Impact, fallbackImpact)
rules.LegacyReleaseFileRule.SetLevel(globalRules.LegacyReleaseFileRule.Impact, fallbackImpact)
rules.EnabledScriptRule.SetLevel(globalRules.EnabledScriptRule.Impact, fallbackImpact)
rules.ReleaseLayoutRule.SetLevel(globalRules.ReleaseLayoutRule.Impact, fallbackImpact)
rules.BundleLayoutRule.SetLevel(globalRules.BundleLayoutRule.Impact, fallbackImpact)
rules.HelmignoreCoverageRule.SetLevel(globalRules.HelmignoreCoverageRule.Impact, fallbackImpact)
rules.HasChangelogRule.SetLevel(globalRules.HasChangelogRule.Impact, fallbackImpact)
rules.ChangelogValidRule.SetLevel(globalRules.ChangelogValidRule.Impact, fallbackImpact)
Expand Down Expand Up @@ -651,8 +649,8 @@ func NewModule(path string, vals *chartutil.Values, globalSchema *spec.Schema, r
//
// The invariant that buys is one those scope tables have to keep — a rule reaching
// for GetChart, GetObjectStore or GetValues here finds nil. name comes from the
// image reference rather than module.yaml, because a module.yaml missing from the
// image is one of the things the layout rules are there to report.
// image reference rather than module.yaml, because the image may ship no module.yaml
// at all and the module still has to be named in the findings.
func NewRemoteModule(path, name string, linters *global.Linters) *Module {
// The image ships no .dmtlint.yaml of its own, and a remote scope is configured
// independently of the source tree: severities come from its own `remote.<scope>`
Expand Down
2 changes: 1 addition & 1 deletion internal/sources/static/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
// validateModule is the source tree's pre-flight check. It reports through the
// `module`/`definition-file` rule rather than under its own name, because what it
// checks is what that rule checks — the remote scopes reach the same ground through
// the bundle-layout and release-layout rules instead.
// the definition-file rule itself, which runs over the unpacked image.
func validateModule(path string, errorList *dmtErrors.LintRuleErrorsList) error {
var errs error

Expand Down
2 changes: 0 additions & 2 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ type ModuleLinterRules struct {
ModulePackageConsistencyRule RuleConfig
LegacyReleaseFileRule RuleConfig
EnabledScriptRule RuleConfig
ReleaseLayoutRule RuleConfig
BundleLayoutRule RuleConfig
HelmignoreCoverageRule RuleConfig
HasChangelogRule RuleConfig
ChangelogValidRule RuleConfig
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ type ModuleLinterRules struct {
ModulePackageConsistencyRule RuleConfig `mapstructure:"module-package-consistency"`
LegacyReleaseFileRule RuleConfig `mapstructure:"legacy-release-file"`
EnabledScriptRule RuleConfig `mapstructure:"enabled-script"`
ReleaseLayoutRule RuleConfig `mapstructure:"release-layout"`
BundleLayoutRule RuleConfig `mapstructure:"bundle-layout"`
HelmignoreCoverageRule RuleConfig `mapstructure:"helmignore-coverage"`
HasChangelogRule RuleConfig `mapstructure:"has-changelog"`
ChangelogValidRule RuleConfig `mapstructure:"changelog-valid"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/linters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ list** — deliberately.

The tempting check is "a scope must ask every linter for all of its rules". It
held while `static` was alone and stopped holding the moment `release` and
`bundle` landed: `release-layout` belongs to a built image and never runs over a
source tree, `markdownlint` is the other way round. A check like that would push
`bundle` landed: `helmignore-coverage` belongs to a built image and never runs over
a source tree, `markdownlint` is the other way round. A check like that would push
back against the very thing scopes exist to express, so the tables are written
out by hand and trusted.

Expand Down
4 changes: 2 additions & 2 deletions pkg/linters/module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Validates that a published image carries a `changelog.yaml` and that it is not e

**Scope:** `release` and `bundle` — the published images are where a changelog has to be, and the source tree is not checked for one. Whether it parses is checked by [changelog-valid](#changelog-valid), which runs in the same two scopes.

The layout rules already report the file missing in both scopes, so this rule's own contribution is the empty-file case.
This is the only rule in either scope that reports a missing file at all, which is why it covers both the absent and the empty case.

A module built into the Deckhouse monorepo needs no exemption here: it publishes no images of its own — it rides the platform release, and its changes are described by the repo-level `CHANGELOG/` — so neither scope ever runs over it.

Expand All @@ -58,7 +58,7 @@ Validates the `changelog.yaml` a published image ships.

**Scope:** `release` and `bundle` — both published images carry `changelog.yaml`.

A missing `changelog.yaml` is not this rule's finding: the layout rules own presence and [has-changelog](#has-changelog) owns emptiness, and this rule stays quiet when the file is absent — the same split [definition-file](#definition-file) and [package-yaml](#package-yaml) follow.
A missing `changelog.yaml` is not this rule's finding: [has-changelog](#has-changelog) owns both presence and emptiness, and this rule stays quiet when the file is absent — the same split [definition-file](#definition-file) and [package-yaml](#package-yaml) follow.

---

Expand Down
2 changes: 0 additions & 2 deletions pkg/linters/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func (l *Module) rules() []pkg.Rule {
rules.NewModulePackageConsistencyRule(m, level(cfg.Rules.ModulePackageConsistencyRule)),
rules.NewLegacyReleaseFileRule(m, level(cfg.Rules.LegacyReleaseFileRule)),
rules.NewEnabledScriptRule(m, level(cfg.Rules.EnabledScriptRule)),
rules.NewReleaseLayoutRule(m, level(cfg.Rules.ReleaseLayoutRule)),
rules.NewBundleLayoutRule(m, level(cfg.Rules.BundleLayoutRule)),
rules.NewHelmignoreCoverageRule(m, level(cfg.Rules.HelmignoreCoverageRule)),
rules.NewHasChangelogRule(m, level(cfg.Rules.HasChangelogRule)),
rules.NewChangelogValidRule(m, level(cfg.Rules.ChangelogValidRule)),
Expand Down
2 changes: 1 addition & 1 deletion pkg/linters/module/rules/changelog_valid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestChangelogYAMLRule(t *testing.T) {
content: "",
},
{
// release-layout owns presence; this rule must stay quiet, which is what
// has-changelog owns presence; this rule must stay quiet, which is what
// lets a scope whose image carries no changelog ask for it.
name: "no changelog at all",
write: false,
Expand Down
5 changes: 3 additions & 2 deletions pkg/linters/module/rules/helmignore_coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ func (r *CoverageRule) Check(_ context.Context) {

raw, err := os.ReadFile(filepath.Join(root, helmignoreFile))
if err != nil {
// A missing .helmignore leaves nothing to compare the tree against. Its absence
// is bundle-layout's finding to report, not a second copy of it here.
// A missing .helmignore leaves nothing to compare the tree against, and reporting
// the absence is not this rule's job — the helmignore rule owns it over the source
// tree, and the bundle scope does not ask for that check at all.
if os.IsNotExist(err) {
return
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/linters/module/rules/helmignore_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestCoverageRule(t *testing.T) {
wantFilePaths []string
}{
{
name: "no .helmignore is bundle-layout's finding, not ours",
name: "a missing .helmignore is not this rule's finding",
helmignore: "",
dirs: []string{"images"},
},
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestCoverageRuleReportsAtWarn(t *testing.T) {
}

// TestCoverageRuleSkipsHelmignoreItself pins the entry a broad pattern would otherwise
// leave uncovered against itself: bundle-layout requires .helmignore in the package root,
// leave uncovered against itself: a bundle carries .helmignore in the package root,
// and no .helmignore lists itself.
func TestCoverageRuleSkipsHelmignoreItself(t *testing.T) {
root := t.TempDir()
Expand Down
124 changes: 0 additions & 124 deletions pkg/linters/module/rules/layout.go

This file was deleted.

99 changes: 0 additions & 99 deletions pkg/linters/module/rules/layout_test.go

This file was deleted.

1 change: 0 additions & 1 deletion pkg/scopes/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
// would work off a chart that was never loaded.
var bundleRules = map[string]set.Set{
moduleLinter.ID: set.New(
modulerules.BundleLayoutRuleName,
modulerules.HelmignoreCoverageRuleName,
modulerules.HasChangelogRuleName,
modulerules.ChangelogValidRuleName,
Expand Down
11 changes: 5 additions & 6 deletions pkg/scopes/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ import (
// and for nothing that needs a chart or a rendered object — the module behind this
// scope is built by modules.NewRemoteModule and has neither.
//
// release-layout is what makes a missing file a finding. definition-file,
// package-yaml and changelog-valid validate the contents of module.yaml, package.yaml
// and changelog.yaml and stay quiet when the file is absent, which is why the presence
// check is a rule of its own. package.yaml is not in the layout list on purpose: it is
// validated when the image ships one, and its absence is not an error.
// No rule here turns a missing file into an error. definition-file, package-yaml and
// changelog-valid validate the contents of module.yaml, package.yaml and changelog.yaml
// and stay quiet when the file is absent; has-changelog is the only one that reports an
// absence at all, and it warns. So this scope checks what the image ships, not what it
// forgot to ship — an empty release image comes back with a single changelog warning.
var releaseRules = map[string]set.Set{
moduleLinter.ID: set.New(
modulerules.ReleaseLayoutRuleName,
modulerules.DefinitionFileRuleName,
modulerules.PackageYAMLRuleName,
modulerules.HasChangelogRuleName,
Expand Down
Loading
Loading