Move inline code examples out of normative contracts
identifier-normalization, no-hardcoded-vendors, vendor-installer-verification, and build-version-display follow the go-database split: rules in contract.md, snippets in README.md. Routed contract reads get cheaper; examples stay available on demand. Lint now also rejects stale kit/patterns references. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
42
rules/patterns/no-hardcoded-vendors/README.md
Normal file
42
rules/patterns/no-hardcoded-vendors/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# No Hardcoded Vendors Pattern Notes
|
||||
|
||||
This file keeps examples. The normative rules live in `contract.md`.
|
||||
|
||||
## Запрещено
|
||||
|
||||
```go
|
||||
if device.Vendor == "Dell" { ... }
|
||||
if strings.Contains(model, "PowerEdge") { ... }
|
||||
switch vendor {
|
||||
case "HP", "HPE", "Hewlett Packard": ...
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
// Запрещено — список вендоров в коде
|
||||
var knownVendors = []string{"Dell", "HP", "Cisco", "Lenovo"}
|
||||
```
|
||||
|
||||
## Правильно
|
||||
|
||||
```go
|
||||
// Смотрим на возможности объекта, не на имя вендора
|
||||
if device.HasIPMI { ... }
|
||||
if device.ParserType == "redfish" { ... }
|
||||
```
|
||||
|
||||
Маппинг в конфиге:
|
||||
|
||||
```yaml
|
||||
# config.yaml
|
||||
vendor_parsers:
|
||||
dell: redfish
|
||||
hp: ilo
|
||||
cisco: ucs
|
||||
```
|
||||
|
||||
Маппинг в БД:
|
||||
|
||||
```sql
|
||||
SELECT parser_type FROM vendor_registry WHERE LOWER(vendor) = LOWER(?);
|
||||
```
|
||||
Reference in New Issue
Block a user