Skip to content

Commit 042fa63

Browse files
authored
[dmt] bump docs (#314)
Signed-off-by: Pavel Okhlopkov <[email protected]>
1 parent aa5b586 commit 042fa63

File tree

11 files changed

+185
-78
lines changed

11 files changed

+185
-78
lines changed

pkg/linters/container/README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ Proper container configuration is critical for cluster stability, security, and
2323

2424
| Rule | Description | Configurable | Default |
2525
|------|-------------|--------------|---------|
26-
| [recommended-labels](#recommended-labels) | Validates required labels (module, heritage) | | enabled |
27-
| [namespace-labels](#namespace-labels) | Validates Prometheus watcher label on d8-* namespaces || enabled |
28-
| [api-version](#api-version) | Validates API versions are not deprecated || enabled |
29-
| [priority-class](#priority-class) | Validates PriorityClass is set and allowed || enabled |
26+
| [object-recommended-labels](#object-recommended-labels) | Validates required labels (module, heritage) | | enabled |
27+
| [object-namespace-labels](#object-namespace-labels) | Validates Prometheus watcher label on d8-* namespaces || enabled |
28+
| [object-api-version](#object-api-version) | Validates API versions are not deprecated || enabled |
29+
| [object-priority-class](#object-priority-class) | Validates PriorityClass is set and allowed || enabled |
3030
| [dns-policy](#dns-policy) | Validates DNS policy for hostNetwork pods || enabled |
3131
| [controller-security-context](#controller-security-context) | Validates Pod-level security context || enabled |
32-
| [revision-history-limit](#revision-history-limit) | Validates Deployment revision history limit ≤ 2 || enabled |
32+
| [object-revision-history-limit](#object-revision-history-limit) | Validates Deployment revision history limit ≤ 2 || enabled |
3333
| [name-duplicates](#name-duplicates) | Validates no duplicate container names || enabled |
3434
| [read-only-root-filesystem](#read-only-root-filesystem) | Validates containers use read-only root filesystem || enabled |
3535
| [host-network-ports](#host-network-ports) | Validates host network and host port usage || enabled |
@@ -46,7 +46,7 @@ Proper container configuration is critical for cluster stability, security, and
4646

4747
## Rule Details
4848

49-
### recommended-labels
49+
### object-recommended-labels
5050

5151
**Purpose:** Ensures all Kubernetes objects have required labels for proper identification, monitoring, and management within the Deckhouse platform. These labels are used for resource tracking, metrics collection, and operational automation.
5252

@@ -102,9 +102,7 @@ metadata:
102102
103103
---
104104
105-
**Configuration:**
106-
107-
### namespace-labels
105+
### object-namespace-labels
108106
109107
**Purpose:** Ensures Deckhouse namespaces (prefixed with `d8-`) have the Prometheus rules watcher label enabled. This allows Prometheus to automatically discover and apply monitoring rules for the namespace.
110108

@@ -178,7 +176,7 @@ metadata:
178176
179177
---
180178
181-
### api-version
179+
### object-api-version
182180
183181
**Purpose:** Prevents use of deprecated Kubernetes API versions that may be removed in future Kubernetes releases. This ensures module compatibility with current and future Kubernetes versions.
184182
@@ -230,7 +228,7 @@ metadata:
230228

231229
---
232230

233-
### priority-class
231+
### object-priority-class
234232

235233
**Purpose:** Ensures all workloads have appropriate priority classes assigned for proper pod scheduling and preemption behavior. This prevents workloads from running without priority, which can cause scheduling issues.
236234

@@ -474,7 +472,7 @@ linters-settings:
474472
475473
---
476474
477-
### revision-history-limit
475+
### object-revision-history-limit
478476
479477
**Purpose:** Limits the number of old ReplicaSets retained for each Deployment to reduce control plane resource consumption. Deckhouse doesn't use rollback functionality, so keeping many old ReplicaSets is wasteful.
480478

pkg/linters/images/README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ FROM $BASE_GOLANG_16_ALPINE
6868
linters-settings:
6969
images:
7070
exclude-rules:
71-
skip-image-file-path-prefix:
71+
skip-distroless-file-path-prefix:
7272
- "updater" # Skip images/updater/
7373
- "legacy" # Skip images/legacy/
7474
```
7575
76+
> Note: Currently, dockerfile rule uses the same exclusion list as distroless rule (`skip-distroless-file-path-prefix`).
77+
7678
---
7779

7880
### Distroless
@@ -247,7 +249,7 @@ Validates patch file organization, naming, and documentation.
247249
- ✅ Patch files are in `images/<image_name>/patches/` directory
248250
- ✅ Patch file names follow pattern: `XXX-<patch-name>.patch` (e.g., `001-fix-ssl.patch`)
249251
- ✅ Each patches directory has a `README.md` file
250-
- ✅ README.md documents each patch with `# XXX-<patch-name>.patch` header
252+
- ✅ README.md documents each patch with `# XXX-<patch-name>.patch` header (single `#`, not `##`)
251253

252254
**Patch Directory Structure:**
253255
```
@@ -271,17 +273,17 @@ images/
271273
```markdown
272274
# Patches
273275
274-
## 001-fix-ssl.patch
276+
# 001-fix-ssl.patch
275277
- **Issue**: SSL handshake fails with certain clients
276278
- **Upstream**: https://github.com/project/repo/issues/1234
277279
- **Status**: Waiting for upstream fix in v2.0
278280
279-
## 002-update-config.patch
281+
# 002-update-config.patch
280282
- **Issue**: Default config incompatible with Kubernetes
281283
- **Upstream**: PR submitted https://github.com/project/repo/pull/5678
282284
- **Status**: Merged, will be in next release
283285
284-
## 003-security-fix.patch
286+
# 003-security-fix.patch
285287
- **Issue**: CVE-2024-12345 vulnerability
286288
- **Upstream**: https://github.com/project/repo/security/advisories/GHSA-xxxx
287289
- **Status**: Backport from upstream fix
@@ -339,15 +341,11 @@ Configure the Images linter in `.dmtlint.yaml`:
339341
```yaml
340342
linters-settings:
341343
images:
342-
# Exclude specific image paths from dockerfile checks
344+
# Exclude specific image paths from dockerfile and distroless checks
343345
exclude-rules:
344-
skip-image-file-path-prefix:
345-
- "updater" # Skip images/updater/
346-
- "legacy" # Skip images/legacy/
347-
348-
# Exclude specific image paths from distroless checks
346+
# Note: Both dockerfile and distroless rules use this exclusion list
349347
skip-distroless-file-path-prefix:
350-
- "updater" # Skip distroless validation
348+
- "updater" # Skip images/updater/
351349
- "debug-tools" # Skip for debug images
352350
353351
# Rule-specific settings
@@ -426,11 +424,11 @@ final: false
426424

427425
**Error:** `README.md file does not contain # 001-fix-ssl.patch`
428426

429-
**Solution:** Add documentation to `patches/README.md`:
427+
**Solution:** Add documentation to `patches/README.md` with single `#` heading:
430428
```markdown
431429
# Patches
432430
433-
## 001-fix-ssl.patch
431+
# 001-fix-ssl.patch
434432
- **Issue**: Description of the issue
435433
- **Upstream**: Link to upstream issue/PR
436434
- **Status**: Current status

pkg/linters/images/rules/distroless.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func isDockerfileInstructionUnacceptable(from string, final bool) (bool, string)
125125
} else {
126126
matched, _ := regexp.MatchString("@sha256:[A-Fa-f0-9]{64}", from)
127127
if !strings.HasPrefix(from, "$BASE_") && !matched {
128-
return true, "Intermediate `FROM` instructions should use one of our $BASE_ images or have `@sha526:` checksum specified"
128+
return true, "Intermediate `FROM` instructions should use one of our $BASE_ images or have `@sha256:` checksum specified"
129129
}
130130
}
131131

pkg/linters/module/README.md

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,26 @@ Validates the `module.yaml` configuration file structure and content.
3232

3333
**Checks:**
3434
- ✅ File exists and is valid YAML
35-
- ✅ Required fields are present (name, namespace)
35+
- ✅ Required fields are present:
36+
- `name` - Module name (max 64 characters)
37+
- `stage` - Module stage (required)
38+
- `descriptions.en` - English description (required)
3639
- ✅ Optional fields are valid when present
3740
- ✅ Accessibility configuration is correct
3841
- ✅ Update section follows versioning rules
42+
-`weight` must not be zero for critical modules
43+
-`description` field is deprecated (use `descriptions.en` instead)
44+
45+
#### Stage Values
46+
47+
The `stage` field defines the module's lifecycle stage:
48+
49+
| Stage | Description |
50+
|-------|-------------|
51+
| `Experimental` | Early development, may have breaking changes |
52+
| `Preview` | Feature complete but not production-ready |
53+
| `General Availability` | Production-ready and stable |
54+
| `Deprecated` | Scheduled for removal |
3955

4056
#### Accessibility Validation
4157

@@ -69,6 +85,10 @@ namespace: d8-my-module
6985
weight: 100
7086
stage: "General Availability"
7187

88+
descriptions:
89+
en: "My module provides functionality for..."
90+
ru: "Мой модуль обеспечивает функциональность для..."
91+
7292
accessibility:
7393
editions:
7494
_default:
@@ -94,7 +114,7 @@ The `update` section defines version upgrade paths for the module.
94114
- `to` version must be greater than `from` version
95115
- Versions must use `major.minor` format (no patch versions)
96116
- Entries must be sorted: first by `from` version ascending, then by `to` version ascending
97-
- No duplicate `from` versions for the same `to` version
117+
- No duplicate `to` versions with different `from` versions (use the earliest `from` version instead)
98118

99119
**Example:**
100120
```yaml
@@ -125,22 +145,24 @@ Validates the `oss.yaml` file containing open-source software attribution.
125145
- ✅ At least one project is described
126146
- ✅ Each project has required fields:
127147
- `name` - Project name
128-
- `url` - Valid project URL
148+
- `description` - Project description
149+
- `link` - Valid project URL
129150
- `license` - Valid license identifier
130-
- `version` (optional) - Project version
151+
- `logo` (optional) - Valid logo URL
131152

132153
**Example:**
133154
```yaml
134155
# oss.yaml
135156
- name: nginx
136-
url: https://nginx.org/
157+
description: High performance web server
158+
link: https://nginx.org/
137159
license: BSD-2-Clause
138-
version: "1.25.3"
160+
logo: https://nginx.org/nginx.png
139161
140162
- name: prometheus
141-
url: https://prometheus.io/
163+
description: Monitoring system and time series database
164+
link: https://prometheus.io/
142165
license: Apache-2.0
143-
version: "2.48.0"
144166
```
145167

146168
---
@@ -153,19 +175,20 @@ Validates OpenAPI conversion files for configuration version upgrades.
153175

154176
**Checks:**
155177
- ✅ Conversion files in `openapi/conversions/` are valid
156-
- ✅ Version files follow naming convention: `v1.yaml`, `v2.yaml`, etc.
178+
- ✅ Version files follow naming convention: `v2.yaml`, `v3.yaml`, etc. (starting from v2)
157179
- ✅ Each conversion has human-readable descriptions (English and Russian)
158-
- ✅ Version numbers are sequential
180+
- ✅ Version numbers are sequential (starting from 2)
159181
- ✅ Descriptions are not empty
182+
- ✅ Version in filename matches version in file content
160183

161184
**File Structure:**
162185
```
163186
openapi/
164-
├── config-values.yaml # Current config version
187+
├── config-values.yaml # Current config version (must have x-config-version)
165188
└── conversions/
166-
├── v1.yaml # Conversion to version 1
167-
├── v2.yaml # Conversion to version 2
168-
└── v3.yaml # Conversion to version 3
189+
├── v2.yaml # Conversion to version 2 (first conversion)
190+
├── v3.yaml # Conversion to version 3
191+
└── v4.yaml # Conversion to version 4
169192
```
170193
171194
**Example:**
@@ -183,14 +206,17 @@ description:
183206

184207
Validates the `.helmignore` file in the module root.
185208

209+
**Purpose:** The `.helmignore` file prevents unnecessary files from being packaged in Helm charts, reducing chart size and improving performance.
210+
186211
**Checks:**
187212
- ✅ File exists in module root
213+
- ✅ File is not empty (contains at least one non-comment pattern)
214+
- ✅ Patterns don't contain unquoted spaces
215+
- ✅ Patterns are not too broad (`*` or `**`)
188216
- ✅ Critical Helm files are NOT excluded:
189217
- `templates/` - Helm template directory
190218
- `Chart.yaml` - Helm chart metadata
191219

192-
**Purpose:** The `.helmignore` file prevents unnecessary files from being packaged in Helm charts, reducing chart size and improving performance.
193-
194220
**Example:**
195221
```
196222
# .helmignore - Safe patterns
@@ -333,7 +359,8 @@ This rule automatically detects feature usage and ensures proper version constra
333359
| **Stage Field** | ≥ 1.68.0 | `stage` field present in `module.yaml` |
334360
| **Go Hooks** | ≥ 1.68.0 | `go.mod` with `module-sdk` + `app.Run()` calls |
335361
| **Readiness Probes** | ≥ 1.71.0 | `module-sdk ≥ 0.3` + `app.WithReadiness()` calls |
336-
| **Optional Modules** | ≥ 1.73.0 | `bootstrapped: false` in requirements |
362+
| **Module-SDK ≥ 1.3** | ≥ 1.71.0 | `module-sdk ≥ 1.3.0` in `go.mod` |
363+
| **Optional Modules** | ≥ 1.73.0 | `!optional` flag in module requirements |
337364

338365
**Validation:**
339366
- ✅ Minimum version constraints are declared
@@ -353,6 +380,7 @@ requirements:
353380
kubernetes: ">= 1.28.0" # Optional: Kubernetes requirement
354381
modules: # Optional: Module dependencies
355382
monitoring-ping: ">= 1.0.0"
383+
optional-module: ">= 1.0.0 !optional" # Optional module dependency (requires >= 1.73.0)
356384
```
357385

358386
**Supported Constraint Formats:**

pkg/linters/openapi/README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,18 @@ linters-settings:
294294
295295
### keys
296296
297-
**Purpose:** Prevents use of banned property names in OpenAPI schemas that could cause conflicts, confusion, or violate naming conventions. This ensures consistent and safe property naming across all module configurations.
297+
**Purpose:** Prevents use of banned names in enum values within OpenAPI schemas. This ensures enum values don't conflict with reserved keywords or cause confusion.
298298
299299
**Description:**
300300
301-
Validates that OpenAPI schema property names and enum values don't use banned keywords. Banned names are typically reserved words, common mistakes, or names that could cause conflicts with Kubernetes or Deckhouse internals.
301+
Validates that enum values in OpenAPI schema files (specifically in CRD files in `crds/` directory) don't use banned keywords. Banned names are typically reserved words that could cause conflicts with Kubernetes or Deckhouse internals.
302302

303303
**What it checks:**
304304

305-
1. Scans all property names in OpenAPI schemas
306-
2. Checks enum values for banned names
307-
3. Recursively validates nested properties and arrays
308-
4. Reports any usage of banned keywords
305+
1. Scans enum fields in CRD OpenAPI schemas
306+
2. Checks each enum value against the banned names list
307+
3. Recursively validates nested structures
308+
4. Reports any usage of banned keywords in enum values
309309

310310
**Why it matters:**
311311

@@ -372,16 +372,19 @@ properties:
372372
373373
**Configuration:**
374374
375+
Define which names should be banned in enum values:
376+
375377
```yaml
376378
# .dmt.yaml
377379
linters-settings:
378380
openapi:
379381
exclude-rules:
380382
key-banned-names:
381-
- "properties.legacy.properties.mode" # Exclude specific field
383+
- "default" # Ban "default" as an enum value
384+
- "type" # Ban "type" as an enum value
382385
```
383386
384-
**Note:** The list of banned names is configured in the linter settings. Common banned names typically include:
387+
**Note:** The `key-banned-names` list defines which names are **not allowed** as enum values. Common banned names typically include:
385388
- `default` - Reserved for schema defaults
386389
- `type` - Reserved for OpenAPI type definitions
387390
- Other context-specific reserved words
@@ -663,20 +666,23 @@ linters-settings:
663666
- "properties.internal.properties.highAvailability"
664667
```
665668

666-
#### Key Name Exclusions
669+
#### Key Banned Names Configuration
667670

668-
Configure banned property names:
671+
Define which property names are banned in enum values:
669672

670673
```yaml
671674
# .dmt.yaml
672675
linters-settings:
673676
openapi:
674677
exclude-rules:
675678
key-banned-names:
676-
- "properties.legacy.properties.default"
677-
- "properties.settings.properties.type"
679+
- "default" # Ban "default" as an enum value
680+
- "type" # Ban "type" as an enum value
681+
- "name" # Ban "name" as an enum value
678682
```
679683

684+
**Note:** This list defines which names are **not allowed** in enum values, not paths to exclude from validation.
685+
680686
#### CRD Exclusions
681687

682688
Exclude specific CRDs from validation:
@@ -703,7 +709,7 @@ linters-settings:
703709
704710
# Rule-specific exclusions
705711
exclude-rules:
706-
# Enum value exclusions
712+
# Enum value exclusions (paths to exclude from enum validation)
707713
enum:
708714
- "properties.storageClass.properties.provision.items.properties.type"
709715
- "properties.storageClass.properties.provision.items.oneOf[*].properties.type"
@@ -713,9 +719,10 @@ linters-settings:
713719
ha-absolute-keys:
714720
- "properties.internal.properties.highAvailability"
715721
716-
# Banned key name exclusions
722+
# Banned names in enum values (names that are not allowed)
717723
key-banned-names:
718-
- "properties.advanced.properties.default"
724+
- "default"
725+
- "type"
719726
720727
# CRD name exclusions
721728
crd-names:

0 commit comments

Comments
 (0)