repo

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 111 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetadataFileNotFound = errors.New("Could not identify metadata type")
View Source
var NotXMLError = errors.New("Could not parse as XML")

Functions

func AllowMissingXMLDeclaration

func AllowMissingXMLDeclaration() bool

AllowMissingXMLDeclaration reports whether XML declaration checks are disabled.

func GetCanonicalDirectoryName

func GetCanonicalDirectoryName(metadataType string) string

GetCanonicalDirectoryName returns the proper directory name for a metadata type considering both the type itself and any parent-child relationships

func GetMetadataDirectory

func GetMetadataDirectory(metadataType string) string

GetMetadataDirectory returns the canonical directory name for a given metadata type.

func GetMetadataSuffix

func GetMetadataSuffix(metadataType string) string

GetMetadataSuffix returns the file suffix for a given metadata type

func GetParentType

func GetParentType(childType string) string

GetParentType returns the parent metadata type for child types like CustomField

func IsChildType

func IsChildType(metadataType string) bool

IsChildType returns true if the metadata type is a child of another type

func IsMetadataFile

func IsMetadataFile(path string) bool

func MetadataFromPath

func MetadataFromPath(path string) (metadata.RegisterableMetadata, error)

If the file in path contains metadata, return it. Otherwise, try to find the corresponding file that contains metadata.

func RootElementName

func RootElementName(xmlData []byte) (string, error)

func SetAllowMissingXMLDeclaration

func SetAllowMissingXMLDeclaration(allow bool)

SetAllowMissingXMLDeclaration enables parsing XML files that omit the XML declaration. By default, RootElementName requires a declaration.

Types

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo() *Repo

func (*Repo) AddItem

func (o *Repo) AddItem(m metadata.RegisterableMetadata)

AddItem adds an already-loaded metadata item to the repo

func (*Repo) Items

Items returns all metadata items for a type as a slice

func (*Repo) Open

func (o *Repo) Open(file string) (metadata.MetadataPointer, error)

func (*Repo) OpenParallel added in v0.41.0

func (o *Repo) OpenParallel(paths []string) []error

OpenParallel parses the given files concurrently and registers each successfully parsed item in the repo. The expensive part of opening a metadata file is the XML decode in MetadataFromPath, which has no shared mutable state, so it is run across a pool of workers. Registration into the repo's maps is serialized after parsing because those maps are not safe for concurrent writes.

It returns a slice of errors parallel to paths: a nil entry means the file was parsed and registered successfully. The repo registration order is unspecified, matching the existing map-backed storage.

func (*Repo) Types

func (o *Repo) Types() []metadata.MetadataType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL