Documentation
¶
Overview ¶
Package handlers provides ecosystem-specific package management functionality.
This package implements the ecosystem handler pattern, where each supported package ecosystem (NPM, Go, Helm, etc.) has its own handler that implements the EcosystemHandler interface.
The handlers are responsible for:
- Loading package information from manifest files
- Updating package versions in manifest files
- Providing ecosystem-specific metadata
Usage:
handler, ok := handlers.GetHandler(config.EcosystemNPM)
if !ok {
return fmt.Errorf("unsupported ecosystem")
}
pkg, err := handler.LoadPackage("/path/to/package")
Supported ecosystems:
- NPM (package.json)
- Go (go.mod)
- Helm (Chart.yaml)
New ecosystems can be added by implementing the EcosystemHandler interface and registering with RegisterEcosystemHandler.
Index ¶
- func GetRegisteredEcosystems() []config.PackageEcosystem
- func LoadPackage(ecosystem config.PackageEcosystem, path string) (*config.Package, error)
- func RegisterEcosystemHandler(handler EcosystemHandler)
- func ScanForPackages(root string) ([]*config.Package, error)
- func UpdatePackageVersion(pkg *config.Package, version string) error
- func ValidatePackage(pkg *config.Package) error
- type ChartYAML
- type EcosystemHandler
- type EcosystemPackage
- type GoHandler
- type HelmHandler
- type NPMHandler
- type PackageJSON
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRegisteredEcosystems ¶
func GetRegisteredEcosystems() []config.PackageEcosystem
GetRegisteredEcosystems returns all registered ecosystem types. This is useful for validation and UI display purposes.
func LoadPackage ¶
LoadPackage loads package information using the appropriate handler. This is a convenience function that looks up the handler by ecosystem type and delegates to the handler's LoadPackage method.
func RegisterEcosystemHandler ¶
func RegisterEcosystemHandler(handler EcosystemHandler)
RegisterEcosystemHandler registers a new ecosystem handler. This allows for dynamic registration of new ecosystem types at runtime.
func ScanForPackages ¶
ScanForPackages scans the given root directory for package configurations. It walks the directory tree and identifies packages based on manifest files. This is useful for auto-discovery of packages in a monorepo structure.
func UpdatePackageVersion ¶
UpdatePackageVersion updates the version of a package using its ecosystem handler. This is a convenience function that looks up the handler and delegates to UpdateVersion.
func ValidatePackage ¶
ValidatePackage validates that a package configuration is valid for its ecosystem. It checks if the manifest file exists and can be loaded successfully.
Types ¶
type ChartYAML ¶
type ChartYAML struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
// contains filtered or unexported fields
}
ChartYAML represents the structure of a Chart.yaml file. We use a minimal structure with a rest field to preserve unknown fields.
type EcosystemHandler ¶
type EcosystemHandler interface {
// GetManifestFile returns the expected manifest file name for this ecosystem
// (e.g., "package.json" for NPM, "go.mod" for Go, "Chart.yaml" for Helm)
GetManifestFile() string
// GetEcosystem returns the ecosystem type this handler supports
GetEcosystem() config.PackageEcosystem
// LoadPackage loads package information from the given path
// The path should point to a directory containing the manifest file
LoadPackage(path string) (*EcosystemPackage, error)
// UpdateVersion updates the package version in the manifest file
// This is used during release operations to bump versions
UpdateVersion(path string, version string) error
}
EcosystemHandler defines the interface for handling different package ecosystems. Each ecosystem (NPM, Go, Helm, etc.) should implement this interface to provide standardized package management operations.
func GetHandler ¶
func GetHandler(ecosystem config.PackageEcosystem) (EcosystemHandler, bool)
GetHandler returns the handler for the given ecosystem. Returns the handler and a boolean indicating if the ecosystem is supported.
type EcosystemPackage ¶
type EcosystemPackage struct {
Name string `json:"name"`
Path string `json:"path"`
Ecosystem config.PackageEcosystem `json:"ecosystem"`
Manifest string `json:"manifest"`
Version string `json:"version,omitempty"` // Optional version field
}
EcosystemPackage represents a package in a specific ecosystem with metadata
func (*EcosystemPackage) ToConfigPackage ¶
func (p *EcosystemPackage) ToConfigPackage() *config.Package
ToConfigPackage converts an EcosystemPackage to a config.Package
type GoHandler ¶
type GoHandler struct{}
GoHandler handles Go module ecosystems. It manages Go modules by parsing go.mod files and handling version through .version files.
func (*GoHandler) GetEcosystem ¶
func (h *GoHandler) GetEcosystem() config.PackageEcosystem
GetEcosystem returns the ecosystem type for Go modules
func (*GoHandler) GetManifestFile ¶
GetManifestFile returns the manifest file name for Go modules
func (*GoHandler) LoadPackage ¶
func (h *GoHandler) LoadPackage(path string) (*EcosystemPackage, error)
LoadPackage loads Go module information from the given path. It parses the go.mod file to extract the module name and retrieves version information.
type HelmHandler ¶
type HelmHandler struct{}
HelmHandler handles Helm chart ecosystems. It manages Helm charts by parsing Chart.yaml files and updating versions.
func (*HelmHandler) GetEcosystem ¶
func (h *HelmHandler) GetEcosystem() config.PackageEcosystem
GetEcosystem returns the ecosystem type for Helm charts
func (*HelmHandler) GetManifestFile ¶
func (h *HelmHandler) GetManifestFile() string
GetManifestFile returns the manifest file name for Helm charts
func (*HelmHandler) LoadPackage ¶
func (h *HelmHandler) LoadPackage(path string) (*EcosystemPackage, error)
LoadPackage loads Helm chart information from the given path. It parses the Chart.yaml file to extract chart name and version.
func (*HelmHandler) UpdateVersion ¶
func (h *HelmHandler) UpdateVersion(path string, version string) error
UpdateVersion updates the version in a Helm chart's Chart.yaml file
type NPMHandler ¶
type NPMHandler struct{}
NPMHandler handles NPM package ecosystems. It manages NPM packages by parsing package.json files and updating versions.
func (*NPMHandler) GetEcosystem ¶
func (h *NPMHandler) GetEcosystem() config.PackageEcosystem
GetEcosystem returns the ecosystem type for NPM packages
func (*NPMHandler) GetManifestFile ¶
func (h *NPMHandler) GetManifestFile() string
GetManifestFile returns the manifest file name for NPM packages
func (*NPMHandler) LoadPackage ¶
func (h *NPMHandler) LoadPackage(path string) (*EcosystemPackage, error)
LoadPackage loads NPM package information from the given path. It parses the package.json file to extract package name and version.
func (*NPMHandler) UpdateVersion ¶
func (h *NPMHandler) UpdateVersion(path string, version string) error
UpdateVersion updates the version in an NPM package's package.json file
type PackageJSON ¶
type PackageJSON struct {
Name string `json:"name"`
Version string `json:"version"`
// contains filtered or unexported fields
}
PackageJSON represents the structure of a package.json file. We use a minimal structure with a rest field to preserve unknown fields.