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>
43 lines
849 B
Markdown
43 lines
849 B
Markdown
# 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(?);
|
|
```
|