package integration import "fmt" // AssertKeyMatch enforces design D7 (schema-hardening): every integration // declares its key twice — once from its own Key() method, once in the // Key field of the manifest its Provider() returns — and nothing but this // check enforces the two agree. A mismatch previously registered the // provider under one key while mounting its UI and settings under the // other, silently splitting the operator Integrations page into a // half-row (registry data, no settings) and a phantom row (settings, no // registry data). // // codeKey is the integration's Key() value; manifest is the Manifest // returned by that same integration's Provider().ProviderManifest(). Called // from cmd/start.go's registry loop, before provider registration, so a // mismatch fails boot instead of surfacing later as a UI defect. func AssertKeyMatch(codeKey string, manifest Manifest) error { if codeKey == manifest.Key { return nil } name := manifest.DisplayName if name == "" { name = codeKey } return fmt.Errorf( "integration %q: Key() returns %q but its provider manifest declares key %q; the two must match", name, codeKey, manifest.Key) }