config

package
v0.23.7 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config handles configuration loading and normalization across different formats.

Index

Constants

View Source
const (
	// MaxConfigFileSize limits configuration file size to prevent resource exhaustion.
	MaxConfigFileSize = 10 * 1024 * 1024 // 10 MB
)

Variables

View Source
var (
	// ErrConfigNotFound is returned when a configuration file is not found.
	ErrConfigNotFound = errors.New("configuration file not found")

	// ErrConfigTooLarge is returned when a configuration file exceeds size limits.
	ErrConfigTooLarge = errors.New("configuration file too large")

	// ErrConflictingLanguage is returned when merging configs with different language specs.
	ErrConflictingLanguage = errors.New("conflicting language specifications")

	// ErrConflictingManager is returned when merging configs with
	// different manager lists.
	ErrConflictingManager = errors.New("conflicting manager specifications")

	// ErrInvalidPackageFormat is returned when a package string has invalid format.
	ErrInvalidPackageFormat = errors.New("invalid package format")
)
View Source
var StandardFileNames = map[string]string{
	"cargobump-deps.yaml":     "deps.yaml",
	"gobump-deps.yaml":        "deps.yaml",
	"pombump-deps.yaml":       "deps.yaml",
	"pombump-properties.yaml": "properties.yaml",
	"gobump-replaces.yaml":    "replaces.yaml",
}

StandardFileNames maps old configuration file names to the new standard names.

Functions

func DiscoverConfigFiles

func DiscoverConfigFiles(ctx context.Context, dir string) ([]string, error)

DiscoverConfigFiles searches for configuration files in a directory. Returns paths to all found configuration files (both old and new formats).

Types

type Config

type Config struct {
	// Language specifies the language ecosystem (auto, maven, go, rust, js)
	Language string `json:"language,omitempty" yaml:"language,omitempty"`

	// Manager names the build tool(s) within a language where the
	// language alone is ambiguous. Currently used by JS to choose between
	// pnpm/yarn/npm/bun.
	//
	// In YAML this may be a scalar or a sequence: `manager: pnpm` is
	// equivalent to `manager: [pnpm]`. A sequence is meaningful when a
	// single package.json needs overrides written under more than one
	// manager's field (for example, pnpm reads both .pnpm.overrides and
	// .resolutions, so a project mid-migration may want both kept in
	// sync).
	Manager js.Managers `json:"manager,omitempty" yaml:"manager,omitempty"`

	// Features lists Cargo features to activate when resolving the dependency
	// graph during discovery (Rust only). It should mirror the feature set the
	// melange package builds with (e.g. the crate's `cargo build --features ...`),
	// so omnibump sees crates reachable only through non-default features and does
	// not silently skip their pins. When empty, omnibump falls back to
	// --all-features.
	Features []string `json:"features,omitempty" yaml:"features,omitempty"`

	// Packages lists dependencies to update
	Packages []Package `json:"packages,omitempty" yaml:"packages,omitempty"`

	// Properties lists properties to update (Maven, etc.)
	Properties []Property `json:"properties,omitempty" yaml:"properties,omitempty"`

	// Replaces lists module replacements (Go-specific)
	Replaces []Replace `json:"replaces,omitempty" yaml:"replaces,omitempty"`
}

Config represents the unified configuration for omnibump.

func LoadConfig

func LoadConfig(ctx context.Context, path string) (*Config, error)

LoadConfig loads configuration from a file, supporting both old and new naming conventions.

func LoadMultipleConfigs

func LoadMultipleConfigs(ctx context.Context, paths []string) (*Config, error)

LoadMultipleConfigs loads and merges multiple configuration files. This is useful for Maven projects that have separate deps and properties files.

func (*Config) Merge added in v0.15.1

func (c *Config) Merge(other *Config) error

Merge appends other's packages, properties and replaces into c and adopts its language and manager, erroring on conflicting specifications.

func (*Config) ToUpdateConfig added in v0.13.0

func (c *Config) ToUpdateConfig() *languages.UpdateConfig

ToUpdateConfig projects this Config into the UpdateConfig consumed by languages.Language.

type Package

type Package struct {
	// Common fields
	Name    string `json:"name,omitempty" yaml:"name,omitempty"`
	Version string `json:"version,omitempty" yaml:"version,omitempty"`

	// Reason is a free-form note (typically a CVE/GHSA list) recorded
	// in build logs alongside the update. It is not written to any
	// manifest file.
	Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`

	// Maven-specific
	GroupID    string `json:"groupId,omitempty" yaml:"groupId,omitempty"`
	ArtifactID string `json:"artifactId,omitempty" yaml:"artifactId,omitempty"`
	Scope      string `json:"scope,omitempty" yaml:"scope,omitempty"`
	Type       string `json:"type,omitempty" yaml:"type,omitempty"`
	// Classifier selects which classifier variants of a Maven artifact the pin
	// governs: unset matches every variant (the classifier-less dependency and
	// all classifier'd ones), "none" matches only the classifier-less
	// dependency, and a value (e.g. osx-x86_64) matches only that classifier.
	Classifier string `json:"classifier,omitempty" yaml:"classifier,omitempty"`
}

Package represents a dependency package to update.

func ParseInlinePackages

func ParseInlinePackages(packagesStr string) ([]Package, error)

ParseInlinePackages parses inline package specifications from command line.

Three input shapes are accepted:

  • Go/Rust: name@version
  • Maven: groupId@artifactId@version[@scope[@type]]
  • JS: selector=version (use this form when the selector contains '@' or '/', e.g. "@scope/name"=1.0.0 or "undici@^6"=6.24.0)

The input may span multiple lines and include shell-style line comments introduced by '#'. Each non-empty line is tokenised on whitespace; the JS form is identified by the presence of '=' in a token, in which case the token is split on its last '=' with the left-hand side optionally surrounded by double quotes.

type Property

type Property struct {
	Property string `json:"property" yaml:"property"`
	Value    string `json:"value" yaml:"value"`
}

Property represents a build property to update.

func ParseInlineProperties

func ParseInlineProperties(propsStr string) ([]Property, error)

ParseInlineProperties parses inline property specifications from command line. Format: "property=value" pairs separated by spaces.

type Replace

type Replace struct {
	OldName string `json:"oldName" yaml:"oldName"`
	Name    string `json:"name" yaml:"name"`
	Version string `json:"version" yaml:"version"`
}

Replace represents a module replacement (Go-specific).

func ParseInlineReplaces

func ParseInlineReplaces(replacesStr string) ([]Replace, error)

ParseInlineReplaces parses inline replace specifications from command line. Format: space-separated "oldpkg=newpkg@version" entries.

Jump to

Keyboard shortcuts

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