Introduce a commercial license option alongside AGPL-3.0-only, require a CLA for contributors, and document the terms in COMMERCIAL.md and NOTICE. Add a script to stamp SPDX headers on Go files and apply it across the tree.
33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
|
|
|
|
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)
|
|
}
|