Documentation
¶
Index ¶
- Variables
- func PackageEntityName(name string) string
- func Register(p FileParser)
- type AuxEntity
- type CodeOwner
- type FileParser
- func AsyncAPIParser() FileParser
- func CatalogParser() FileParser
- func CodeownersParser() FileParser
- func GoModParser() FileParser
- func K8sServiceParser() FileParser
- func OpenAPIParser() FileParser
- func PackageJSONParser() FileParser
- func PomParser() FileParser
- func ProtoParser() FileParser
- func SpringKafkaParser() FileParser
- type MergeMode
- type ParsedCatalog
- type ParsedCodeowners
- type ParsedFile
- type ParsedGoMod
- type ParsedPackageJSON
- type ParsedPom
- type ParsedRelation
- type ParserRegistry
Constants ¶
This section is empty.
Variables ¶
var Default = NewRegistry()
Default is the global registry. Built-in parsers register here from main.go. Custom parsers may register here from their own init() functions.
Functions ¶
func PackageEntityName ¶
PackageEntityName normalizes an npm package name to a safe graph entity name. Scoped names like "@myorg/my-service" become "my-service". Names with remaining slashes take the last segment.
func Register ¶
func Register(p FileParser)
Register adds p to the global Default registry. Panics on duplicate FileType() or Filenames() overlap — fail-fast at startup.
Types ¶
type AuxEntity ¶
AuxEntity is an additional graph entity produced alongside the primary entity. Used by parsers that create multiple entities (e.g. CodeownersParser creates one team/person entity per owner).
type CodeOwner ¶
type CodeOwner struct {
// Raw is the original owner token as written in the file
// (e.g. "@myorg/backend-team", "@alice", "alice@example.com").
Raw string
// EntityName is the normalized identifier used as the knowledge-graph node name
// (e.g. "backend-team", "alice").
EntityName string
// EntityType is "team" for @org/team handles, "person" for @username or e-mail owners.
EntityType string
}
CodeOwner represents a single owner entry extracted from a CODEOWNERS file.
type FileParser ¶
type FileParser interface {
// FileType returns the classifier key used by classifyFile() and the indexer.
// Must be unique across the registry. Examples: "gomod", "catalog-info".
FileType() string
// Filenames returns the exact filenames (or suffix sentinels starting with ".")
// this parser handles. The scanner looks for these at the repo root.
// Examples: ["go.mod"], ["catalog-info.yaml"], [".proto"] (suffix match).
Filenames() []string
// Parse converts raw file bytes into a normalized graph-ready result.
Parse(data []byte) (ParsedFile, error)
}
FileParser is the extension point for manifest parsers. All methods must be safe for concurrent use (implementations are typically stateless).
func AsyncAPIParser ¶
func AsyncAPIParser() FileParser
AsyncAPIParser returns the FileParser for asyncapi.yaml and asyncapi.json files.
func CatalogParser ¶
func CatalogParser() FileParser
CatalogParser returns the FileParser for catalog-info.yaml files.
func CodeownersParser ¶
func CodeownersParser() FileParser
CodeownersParser returns the FileParser for CODEOWNERS files.
func GoModParser ¶
func GoModParser() FileParser
func K8sServiceParser ¶
func K8sServiceParser() FileParser
K8sServiceParser returns the FileParser for K8s-classified YAML files (k8s type).
func OpenAPIParser ¶
func OpenAPIParser() FileParser
OpenAPIParser returns the FileParser for openapi.yaml/json and swagger.json/yaml files.
func PackageJSONParser ¶
func PackageJSONParser() FileParser
PackageJSONParser returns the FileParser for package.json files.
func PomParser ¶
func PomParser() FileParser
func ProtoParser ¶
func ProtoParser() FileParser
ProtoParser returns the FileParser for *.proto files (suffix-matched by scanner).
func SpringKafkaParser ¶
func SpringKafkaParser() FileParser
SpringKafkaParser returns the FileParser for application.yml/yaml/properties files.
type MergeMode ¶
type MergeMode int
MergeMode controls how upsertParsedFile() handles existing graph entities.
type ParsedCatalog ¶
type ParsedCatalog struct {
EntityName string
EntityType string
Observations []string
Relations []ParsedRelation
}
ParsedCatalog holds the data extracted from a Backstage catalog-info.yaml.
func ParseCatalog ¶
func ParseCatalog(data []byte) (ParsedCatalog, error)
ParseCatalog parses raw catalog-info.yaml bytes into a ParsedCatalog. Returns an error only for YAML parse failures or missing metadata.name. Missing optional fields are silently skipped.
type ParsedCodeowners ¶
type ParsedCodeowners struct {
// UniqueOwners contains every distinct owner token found across all rules.
UniqueOwners []CodeOwner
}
ParsedCodeowners holds the deduplicated set of owners found in a CODEOWNERS file.
func ParseCodeowners ¶
func ParseCodeowners(data []byte) ParsedCodeowners
ParseCodeowners parses raw CODEOWNERS file bytes and returns the deduplicated set of owner entries. It supports the three GitHub CODEOWNERS owner formats:
- @org/team → EntityType "team", EntityName = team slug (last path segment)
- @username → EntityType "person", EntityName = username (without @)
- user@email → EntityType "person", EntityName = local part before @
Lines starting with '#' and blank lines are ignored. Patterns without owners (lone path entries) are silently skipped.
type ParsedFile ¶
type ParsedFile struct {
EntityName string
EntityType string
Observations []string
Relations []ParsedRelation
MergeMode MergeMode
// AuxEntities are created/updated before Relations. Used when a single file
// produces multiple graph entities (e.g. CODEOWNERS produces one per owner).
AuxEntities []AuxEntity
}
ParsedFile is the normalized, graph-ready output every FileParser must return. EntityName must be non-empty unless AuxEntities is non-empty (codeowners pattern). EntityType defaults to "service" if blank. Observations and Relations may be nil or empty. MergeMode defaults to MergeModeUpsert if zero. Relations with From == "" have their From field filled with the derived repo service name. Relations with To == "" have their To field filled with the derived repo service name.
type ParsedGoMod ¶
type ParsedGoMod struct {
ModulePath string
EntityName string
GoVersion string
DirectDeps []string
}
func ParseGoMod ¶
func ParseGoMod(data []byte) (ParsedGoMod, error)
type ParsedPackageJSON ¶
type ParsedPackageJSON struct {
// Name is the package name declared in package.json (e.g. "my-service").
Name string
// EntityName is the name sanitized for use as a knowledge graph node.
// Scoped packages like "@myorg/my-service" are normalized to "my-service".
EntityName string
// Version is the declared package version (e.g. "1.2.3").
Version string
// DirectDeps are the package names listed under "dependencies" (not devDependencies).
DirectDeps []string
}
ParsedPackageJSON holds data extracted from a package.json file.
func ParsePackageJSON ¶
func ParsePackageJSON(data []byte) (ParsedPackageJSON, error)
ParsePackageJSON parses raw package.json bytes and returns the extracted metadata. Only "dependencies" entries are included — "devDependencies" are excluded.
type ParsedPom ¶
type ParsedRelation ¶
type ParsedRelation struct {
From string
To string
RelationType string // e.g. "depends_on", "owns", "provides_api"
}
ParsedRelation is a directed edge produced by a parser. If To is empty (""), the indexer fills it with the derived repo service name — used by CodeownersParser where the target service is context-dependent.
type ParserRegistry ¶
type ParserRegistry struct {
// contains filtered or unexported fields
}
ParserRegistry is a thread-safe map of FileParser implementations keyed by FileType().
func (*ParserRegistry) All ¶
func (r *ParserRegistry) All() []FileParser
All returns a snapshot of all registered parsers in an unspecified order.
func (*ParserRegistry) Get ¶
func (r *ParserRegistry) Get(fileType string) (FileParser, bool)
Get returns the FileParser for the given fileType, or (nil, false) if not registered.
func (*ParserRegistry) Register ¶
func (r *ParserRegistry) Register(p FileParser)
Register adds p to the registry. Panics if p.FileType() is already registered. Panics if any entry in p.Filenames() is already claimed by another parser.
func (*ParserRegistry) TargetFilenames ¶
func (r *ParserRegistry) TargetFilenames() []string
TargetFilenames returns the union of all Filenames() across all registered parsers.