core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

core/cache.go

core/command.go

core/config.go

core/constants.go

core/dependency.go

core/logger.go

core/plugin_registry.go

core/project.go

core/resolver.go

core/security.go

core/utils.go

Index

Constants

View Source
const (
	PluginAPIVersion = "1.0.0"
	MaxConcurrency   = 5 // Adjust as needed
)
View Source
const PluginAPIVersion = "1.0"

PluginAPIVersion defines the current version of the plugin API

Variables

This section is empty.

Functions

func CacheDependency

func CacheDependency(dep Dependency, data io.Reader) error

CacheDependency caches the downloaded package data.

func GenerateSecurityReport

func GenerateSecurityReport(reports []SecurityReport, format, outputPath string) error

GenerateSecurityReport generates a security report in the specified format.

func InitializeLogger

func InitializeLogger()

InitializeLogger sets up the global logger.

func InitializeProject

func InitializeProject(name, version, description string, authors []string) error

InitializeProject initializes a new pkgmgr project by creating a pkgmgr.yaml file.

func IsWindows

func IsWindows() bool

IsWindows checks if the current OS is Windows.

func LogFatal

func LogFatal(err error)

LogFatal logs the error and exits the application.

Types

type Author

type Author struct {
	Name  string `yaml:"name" validate:"required"`
	Email string `yaml:"email" validate:"required,email"`
}

Author represents a project author.

type Command

type Command struct {
	Name string
	Args []string
}

Command represents an external command to be executed.

type Config

type Config struct {
	Project        ProjectConfig                `yaml:"project" validate:"required,dive"`
	Environments   map[string]EnvironmentConfig `yaml:"environments" validate:"required,dive"`
	TrustedSources map[string][]string          `yaml:"trusted_sources" validate:"required,dive,dive,uri"`
}

Config represents the entire project configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate parses and validates the entire configuration.

type Dependency

type Dependency struct {
	Name       string              `yaml:"name" validate:"required"`
	Version    string              `yaml:"version" validate:"required"`
	Constraint *semver.Constraints `yaml:"-"`
}

Dependency represents a package dependency.

func (*Dependency) Validate

func (d *Dependency) Validate() error

Validate parses and validates the dependency.

type EnvironmentConfig

type EnvironmentConfig struct {
	Dependencies map[string][]Dependency `yaml:"dependencies" validate:"required,dive,dive"`
}

EnvironmentConfig holds dependencies for a specific environment.

type Executor

type Executor interface {
	Run(cmd *Command) error
	Output(cmd *Command) ([]byte, error)
}

Executor defines methods to execute commands.

type PackageManagerPlugin

type PackageManagerPlugin interface {
	APIVersion() string
	Language() string
	Initialize(config Config) error
	Install(deps []Dependency) error
	Update(deps []Dependency) error
	Remove(dep Dependency) error
	List() ([]Dependency, error)
	ListVersions(depName string) ([]string, error)
	GetTransitiveDependencies(depName, version string) ([]Dependency, error)
	GetVulnerabilities() ([]SecurityVulnerability, error)
	Cleanup() error
}

PackageManagerPlugin defines the interface that all language-specific plugins must implement.

type PluginRegistry

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

PluginRegistry manages all registered plugins.

func GetPluginRegistry

func GetPluginRegistry() *PluginRegistry

GetPluginRegistry returns the singleton instance of PluginRegistry.

func NewPluginRegistry

func NewPluginRegistry() *PluginRegistry

NewPluginRegistry creates a new PluginRegistry instance.

func (*PluginRegistry) GetAllPlugins

func (pr *PluginRegistry) GetAllPlugins() map[string]PackageManagerPlugin

GetAllPlugins retrieves all registered plugins.

func (*PluginRegistry) GetPlugin

func (pr *PluginRegistry) GetPlugin(lang string) (PackageManagerPlugin, bool)

GetPlugin retrieves a plugin by language.

func (*PluginRegistry) RegisterPlugin

func (pr *PluginRegistry) RegisterPlugin(lang string, plugin PackageManagerPlugin) error

RegisterPlugin registers a new plugin.

type ProjectConfig

type ProjectConfig struct {
	Name        string   `yaml:"name" validate:"required"`
	Version     string   `yaml:"version" validate:"required,semver"`
	Description string   `yaml:"description"`
	Authors     []Author `yaml:"authors" validate:"dive"`
}

ProjectConfig holds project metadata.

type RealExecutor

type RealExecutor struct{}

RealExecutor is the default implementation of Executor using exec.Command.

func (*RealExecutor) Output

func (e *RealExecutor) Output(cmd *Command) ([]byte, error)

func (*RealExecutor) Run

func (e *RealExecutor) Run(cmd *Command) error

type Resolver

type Resolver struct {
	Config         Config
	PluginRegistry *PluginRegistry
	// contains filtered or unexported fields
}

Resolver handles dependency resolution.

func NewResolver

func NewResolver(config Config, pr *PluginRegistry) *Resolver

NewResolver creates a new Resolver instance.

func (*Resolver) CollectSecurityReports

func (r *Resolver) CollectSecurityReports() error

CollectSecurityReports collects security vulnerabilities from each plugin and generates reports.

func (*Resolver) ResolveDependencies

func (r *Resolver) ResolveDependencies(env string) error

ResolveDependencies resolves all dependencies recursively for a given environment.

type SecurityReport

type SecurityReport struct {
	Language        string                  `json:"language"`
	Vulnerabilities []SecurityVulnerability `json:"vulnerabilities"`
}

SecurityReport represents a security report for a language.

type SecurityVulnerability

type SecurityVulnerability struct {
	Package       string `json:"package"`
	Vulnerability string `json:"vulnerability"`
	Severity      string `json:"severity,omitempty"`
	Description   string `json:"description,omitempty"`
}

SecurityVulnerability represents a security issue found in a dependency.

Jump to

Keyboard shortcuts

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