package main import ( "fmt" "os" ) func init() { register(Check{ Seq: 21, ID: "2b", Title: "Plugin proto ownership", Run: func(ctx *ScanContext, rep *Reporter) { // Check 2b: Plugin proto ownership fmt.Println("=== Check 2b: Plugin proto ownership ===") var protoOwnershipViolations []protoOwnershipViolation for _, target := range ctx.backendTargets { if !isPluginModuleRoot(target.root) { continue } violations, err := checkPluginProtoOwnership(target.root, target.displayOrRoot()) if err != nil { fmt.Printf(" ERROR: failed to check proto ownership for %s: %v\n", target.displayOrRoot(), err) os.Exit(2) } protoOwnershipViolations = append(protoOwnershipViolations, violations...) } for _, target := range ctx.pluginTargets { violations, err := checkPluginProtoOwnership(target.root, target.display) if err != nil { fmt.Printf(" ERROR: failed to check proto ownership for %s: %v\n", target.display, err) os.Exit(2) } protoOwnershipViolations = append(protoOwnershipViolations, violations...) } if len(protoOwnershipViolations) > 0 { fmt.Printf(" FAIL: %d plugin proto ownership violation(s):\n", len(protoOwnershipViolations)) for _, v := range protoOwnershipViolations { fmt.Printf(" %s [%s] local proto missing; matching proto exists in %s\n", v.root, v.namespace, v.coreProto) } fmt.Println("\n Fix: move plugin proto sources into the plugin repo and generate api/ from there.") rep.Fail() } else { fmt.Println(" OK: Plugin proto ownership is clean") printPerTargetOKLines(pluginTargetLabels(ctx.pluginTargets)) } fmt.Println() }, }) }