Documentation
¶
Index ¶
- Variables
- func ExtractPath(output string, extract *definitions.Extract, pkg string) (string, error)
- func ValidatePackageName(validatorName, name string) error
- type AddOptions
- type AllowAllPolicy
- type Capability
- type CommandInput
- type ConflictBehavior
- type DenyAllPolicy
- type DetectOptions
- type Detector
- type ErrCLINotFound
- type ErrConflictingLockfiles
- type ErrInvalidPackageName
- type ErrManifestNotInRoot
- type ErrMissingArgument
- type ErrNoManifest
- type ErrOrphanedWorkspaceMember
- type ErrPolicyCheck
- type ErrPolicyViolation
- type ErrUnsupportedVersion
- type ExecContext
- type ExecRunner
- type GenericManager
- func (m *GenericManager) Add(ctx context.Context, pkg string, opts AddOptions) (*Result, error)
- func (m *GenericManager) Capabilities() []Capability
- func (m *GenericManager) Dir() string
- func (m *GenericManager) Ecosystem() string
- func (m *GenericManager) Install(ctx context.Context, opts InstallOptions) (*Result, error)
- func (m *GenericManager) List(ctx context.Context) (*Result, error)
- func (m *GenericManager) Name() string
- func (m *GenericManager) Outdated(ctx context.Context) (*Result, error)
- func (m *GenericManager) Path(ctx context.Context, pkg string) (*PathResult, error)
- func (m *GenericManager) Remove(ctx context.Context, pkg string) (*Result, error)
- func (m *GenericManager) Resolve(ctx context.Context) (*Result, error)
- func (m *GenericManager) Supports(cap Capability) bool
- func (m *GenericManager) Update(ctx context.Context, pkg string) (*Result, error)
- func (m *GenericManager) Vendor(ctx context.Context) (*Result, error)
- func (m *GenericManager) Warnings() []string
- type InstallOptions
- type Manager
- type MockRunner
- type PackageBlocklistPolicy
- type PathResult
- type Policy
- type PolicyHandler
- type PolicyMode
- type PolicyOperation
- type PolicyResult
- type PolicyRunner
- type PolicyRunnerOption
- type Result
- type Runner
- type Translator
- func (t *Translator) BuildCommand(managerName, operation string, input CommandInput) ([]string, error)
- func (t *Translator) BuildCommands(managerName, operation string, input CommandInput) ([][]string, error)
- func (t *Translator) Definition(name string) (*definitions.Definition, bool)
- func (t *Translator) ExitCodeMeaning(managerName, operation string, exitCode int) string
- func (t *Translator) IsFatalExitCode(managerName, operation string, exitCode int) bool
- func (t *Translator) Register(def *definitions.Definition)
- func (t *Translator) RegisterValidator(name string, v *definitions.Validator)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ExtractPath ¶ added in v0.4.0
func ValidatePackageName ¶
Types ¶
type AllowAllPolicy ¶ added in v0.5.0
type AllowAllPolicy struct{}
AllowAllPolicy is a no-op policy that allows all operations. Useful as a placeholder or for testing.
func (AllowAllPolicy) Check ¶ added in v0.5.0
func (AllowAllPolicy) Check(ctx context.Context, op *PolicyOperation) (*PolicyResult, error)
func (AllowAllPolicy) Name ¶ added in v0.5.0
func (AllowAllPolicy) Name() string
type Capability ¶
type Capability int
const ( CapInstall Capability = iota CapInstallFrozen CapInstallClean CapAdd CapAddDev CapAddOptional CapRemove CapUpdate CapList CapOutdated CapAudit CapWorkspace CapJSONOutput CapSBOMCycloneDX CapSBOMSPDX CapPath CapVendor CapResolve )
func CapabilityFromString ¶
func CapabilityFromString(s string) (Capability, bool)
func (Capability) String ¶
func (c Capability) String() string
type CommandInput ¶
type ConflictBehavior ¶
type ConflictBehavior int
const ( ConflictError ConflictBehavior = iota ConflictUseFirst ConflictUseNewest )
type DenyAllPolicy ¶ added in v0.5.0
type DenyAllPolicy struct {
Reason string
}
DenyAllPolicy is a policy that denies all operations. Useful for testing or as a circuit breaker.
func (DenyAllPolicy) Check ¶ added in v0.5.0
func (p DenyAllPolicy) Check(ctx context.Context, op *PolicyOperation) (*PolicyResult, error)
func (DenyAllPolicy) Name ¶ added in v0.5.0
func (DenyAllPolicy) Name() string
type DetectOptions ¶
type DetectOptions struct {
RequireCLI bool
OnConflict ConflictBehavior
SearchParents bool
Manager string
}
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
func NewDetector ¶
func NewDetector(translator *Translator, runner Runner) *Detector
func (*Detector) Detect ¶
func (d *Detector) Detect(dir string, opts DetectOptions) (Manager, error)
func (*Detector) DetectVersion ¶
func (d *Detector) DetectVersion(def *definitions.Definition) (string, error)
func (*Detector) Register ¶
func (d *Detector) Register(def *definitions.Definition)
type ErrCLINotFound ¶
func (ErrCLINotFound) Error ¶
func (e ErrCLINotFound) Error() string
type ErrConflictingLockfiles ¶
func (ErrConflictingLockfiles) Error ¶
func (e ErrConflictingLockfiles) Error() string
type ErrInvalidPackageName ¶
func (ErrInvalidPackageName) Error ¶
func (e ErrInvalidPackageName) Error() string
type ErrManifestNotInRoot ¶
func (ErrManifestNotInRoot) Error ¶
func (e ErrManifestNotInRoot) Error() string
type ErrMissingArgument ¶
type ErrMissingArgument struct {
Argument string
}
func (ErrMissingArgument) Error ¶
func (e ErrMissingArgument) Error() string
type ErrNoManifest ¶
type ErrNoManifest struct {
Dir string
}
func (ErrNoManifest) Error ¶
func (e ErrNoManifest) Error() string
type ErrOrphanedWorkspaceMember ¶
func (ErrOrphanedWorkspaceMember) Error ¶
func (e ErrOrphanedWorkspaceMember) Error() string
type ErrPolicyCheck ¶ added in v0.5.0
func (ErrPolicyCheck) Error ¶ added in v0.5.0
func (e ErrPolicyCheck) Error() string
func (ErrPolicyCheck) Unwrap ¶ added in v0.5.0
func (e ErrPolicyCheck) Unwrap() error
type ErrPolicyViolation ¶ added in v0.5.0
func (ErrPolicyViolation) Error ¶ added in v0.5.0
func (e ErrPolicyViolation) Error() string
type ErrUnsupportedVersion ¶
func (ErrUnsupportedVersion) Error ¶
func (e ErrUnsupportedVersion) Error() string
type ExecContext ¶
type ExecContext int
const ( ContextProject ExecContext = iota ContextGlobal ContextWorkspace )
type GenericManager ¶
type GenericManager struct {
// contains filtered or unexported fields
}
func (*GenericManager) Add ¶
func (m *GenericManager) Add(ctx context.Context, pkg string, opts AddOptions) (*Result, error)
func (*GenericManager) Capabilities ¶
func (m *GenericManager) Capabilities() []Capability
func (*GenericManager) Dir ¶
func (m *GenericManager) Dir() string
func (*GenericManager) Ecosystem ¶
func (m *GenericManager) Ecosystem() string
func (*GenericManager) Install ¶
func (m *GenericManager) Install(ctx context.Context, opts InstallOptions) (*Result, error)
func (*GenericManager) Name ¶
func (m *GenericManager) Name() string
func (*GenericManager) Outdated ¶
func (m *GenericManager) Outdated(ctx context.Context) (*Result, error)
func (*GenericManager) Path ¶ added in v0.4.0
func (m *GenericManager) Path(ctx context.Context, pkg string) (*PathResult, error)
func (*GenericManager) Resolve ¶ added in v0.6.0
func (m *GenericManager) Resolve(ctx context.Context) (*Result, error)
func (*GenericManager) Supports ¶
func (m *GenericManager) Supports(cap Capability) bool
func (*GenericManager) Vendor ¶ added in v0.5.0
func (m *GenericManager) Vendor(ctx context.Context) (*Result, error)
func (*GenericManager) Warnings ¶
func (m *GenericManager) Warnings() []string
type InstallOptions ¶
type Manager ¶
type Manager interface {
Name() string
Ecosystem() string
Install(ctx context.Context, opts InstallOptions) (*Result, error)
Add(ctx context.Context, pkg string, opts AddOptions) (*Result, error)
Remove(ctx context.Context, pkg string) (*Result, error)
List(ctx context.Context) (*Result, error)
Outdated(ctx context.Context) (*Result, error)
Update(ctx context.Context, pkg string) (*Result, error)
Path(ctx context.Context, pkg string) (*PathResult, error)
Vendor(ctx context.Context) (*Result, error)
Resolve(ctx context.Context) (*Result, error)
Supports(cap Capability) bool
Capabilities() []Capability
}
type MockRunner ¶
type MockRunner struct {
Captured [][]string
Results []*Result
Errors []error
// contains filtered or unexported fields
}
func NewMockRunner ¶
func NewMockRunner() *MockRunner
func (*MockRunner) LastCaptured ¶
func (m *MockRunner) LastCaptured() []string
type PackageBlocklistPolicy ¶ added in v0.5.0
PackageBlocklistPolicy denies operations on specific packages.
func (PackageBlocklistPolicy) Check ¶ added in v0.5.0
func (p PackageBlocklistPolicy) Check(ctx context.Context, op *PolicyOperation) (*PolicyResult, error)
func (PackageBlocklistPolicy) Name ¶ added in v0.5.0
func (PackageBlocklistPolicy) Name() string
type PathResult ¶ added in v0.4.0
type Policy ¶ added in v0.5.0
type Policy interface {
// Name returns a unique identifier for this policy.
Name() string
// Check evaluates the policy against the given operation.
// Returns a PolicyResult indicating whether the operation should proceed.
Check(ctx context.Context, op *PolicyOperation) (*PolicyResult, error)
}
Policy defines an interface for checks that run before package operations. Policies can inspect the operation details and either allow or deny execution.
type PolicyHandler ¶ added in v0.5.0
type PolicyHandler interface {
OnPolicyResult(op *PolicyOperation, policy Policy, result *PolicyResult)
}
PolicyHandler receives policy check results for logging or custom handling.
type PolicyMode ¶ added in v0.5.0
type PolicyMode int
PolicyMode determines how policy violations are handled.
const ( // PolicyEnforce blocks operations that fail policy checks. PolicyEnforce PolicyMode = iota // PolicyWarn logs warnings but allows operations to proceed. PolicyWarn // PolicyDisabled skips all policy checks. PolicyDisabled )
func (PolicyMode) String ¶ added in v0.5.0
func (m PolicyMode) String() string
type PolicyOperation ¶ added in v0.5.0
type PolicyOperation struct {
// Manager is the package manager name (e.g., "npm", "bundler").
Manager string
// Operation is the command being run (e.g., "add", "install", "update").
Operation string
// Packages is the list of packages being operated on.
// Empty for operations like "install" that don't target specific packages.
Packages []string
// Args contains the raw arguments passed to the command.
Args map[string]string
// Flags contains the flags passed to the command.
Flags map[string]any
// WorkingDir is the directory where the operation will run.
WorkingDir string
// Command is the fully constructed command that will be executed.
Command []string
}
PolicyOperation contains details about the operation being checked.
type PolicyResult ¶ added in v0.5.0
type PolicyResult struct {
// Allowed indicates whether the operation should proceed.
Allowed bool
// Reason explains why the operation was allowed or denied.
Reason string
// Warnings contains non-blocking issues that should be reported.
Warnings []string
// Metadata contains policy-specific data for programmatic access.
Metadata map[string]any
}
PolicyResult contains the outcome of a policy check.
type PolicyRunner ¶ added in v0.5.0
type PolicyRunner struct {
// contains filtered or unexported fields
}
PolicyRunner wraps a Runner and applies policies before execution.
func NewPolicyRunner ¶ added in v0.5.0
func NewPolicyRunner(inner Runner, opts ...PolicyRunnerOption) *PolicyRunner
NewPolicyRunner creates a Runner that applies policies before execution.
func (*PolicyRunner) AddPolicy ¶ added in v0.5.0
func (pr *PolicyRunner) AddPolicy(p Policy)
AddPolicy registers a policy to be checked before operations.
func (*PolicyRunner) Run ¶ added in v0.5.0
Run executes the command after checking all registered policies.
func (*PolicyRunner) RunWithContext ¶ added in v0.5.0
func (pr *PolicyRunner) RunWithContext(ctx context.Context, op *PolicyOperation) (*Result, error)
RunWithContext executes the command with additional operation context. Use this when you have more information about the operation than just the command.
type PolicyRunnerOption ¶ added in v0.5.0
type PolicyRunnerOption func(*PolicyRunner)
PolicyRunnerOption configures a PolicyRunner.
func WithPolicies ¶ added in v0.5.0
func WithPolicies(policies ...Policy) PolicyRunnerOption
WithPolicies adds policies to the runner.
func WithPolicyHandler ¶ added in v0.5.0
func WithPolicyHandler(handler PolicyHandler) PolicyRunnerOption
WithPolicyHandler sets a handler for policy results.
func WithPolicyMode ¶ added in v0.5.0
func WithPolicyMode(mode PolicyMode) PolicyRunnerOption
WithPolicyMode sets the enforcement mode.
type Result ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
func NewTranslator ¶
func NewTranslator() *Translator
func (*Translator) BuildCommand ¶
func (t *Translator) BuildCommand(managerName, operation string, input CommandInput) ([]string, error)
func (*Translator) BuildCommands ¶
func (t *Translator) BuildCommands(managerName, operation string, input CommandInput) ([][]string, error)
BuildCommands returns all commands for an operation (including "then" chains)
func (*Translator) Definition ¶
func (t *Translator) Definition(name string) (*definitions.Definition, bool)
func (*Translator) ExitCodeMeaning ¶ added in v0.7.0
func (t *Translator) ExitCodeMeaning(managerName, operation string, exitCode int) string
ExitCodeMeaning returns the semantic meaning of an exit code for a manager/operation pair, as defined in the YAML. Returns "" if the manager, operation, or exit code is not defined.
func (*Translator) IsFatalExitCode ¶ added in v0.7.0
func (t *Translator) IsFatalExitCode(managerName, operation string, exitCode int) bool
IsFatalExitCode reports whether exitCode represents a fatal error for the given manager/operation. Exit code 0 is never fatal. For non-zero codes, the result is fatal unless the YAML definition assigns a non-"error" meaning.
func (*Translator) Register ¶
func (t *Translator) Register(def *definitions.Definition)
func (*Translator) RegisterValidator ¶
func (t *Translator) RegisterValidator(name string, v *definitions.Validator)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
docs
|
|
|
examples/dependabot-cron
command
|
|
|
examples/git-pkgs-integration
command
|