Files
go-sip/contracts/contracts.go
T

25 lines
691 B
Go

package contracts
import (
"embed"
"fmt"
"path"
)
// Files contains only the active local machine contract.
// Runtime code never reads a checkout or resolves schema refs online.
//
//go:embed local/*.json local/examples
var Files embed.FS
// ReadCurrent reads the sole active project-local contract, with no fallback
// to a historical bundle if a name is missing or invalid.
func ReadCurrent(name string) ([]byte, error) {
switch name {
case "config-read.schema.json", "task-discovery.schema.json", "mq.schema.json", "mq-topology.json", "manifest.json":
return Files.ReadFile(path.Join("local", name))
default:
return nil, fmt.Errorf("invalid current contract %q", name)
}
}