Documentation
¶
Index ¶
- type BumpStep
- type BumpStepSpec
- type GoPackagePin
- type Loader
- func (l *Loader) FindBumpSteps(yamlContent []byte) ([]BumpStep, error)
- func (l *Loader) FindGoPackagePins(yamlContent []byte) ([]GoPackagePin, error)
- func (l *Loader) FindPipelinesByUse(yamlContent []byte, useType string) ([]int, error)
- func (l *Loader) GetBumpModroots(yamlContent []byte, pipelineIndex int) ([]string, error)
- func (l *Loader) GetBumpReplaces(yamlContent []byte, pipelineIndex int) ([]string, error)
- func (l *Loader) GetGoBumpDeps(yamlContent []byte, pipelineIndex int) ([]string, error)
- func (l *Loader) GetPackageInfo(yamlContent []byte) (name, version string, epoch int64, err error)
- func (l *Loader) GetPipelineWithField(yamlContent []byte, pipelineIndex int) (map[string]string, error)
- func (l *Loader) HasBlankLinesBetweenPipelineSteps(yamlContent []byte) bool
- func (l *Loader) IncrementEpoch(yamlContent []byte) ([]byte, error)
- func (l *Loader) InsertBumpPipelineStep(yamlContent []byte, pipelineIndex int, spec BumpStepSpec, ...) ([]byte, error)
- func (l *Loader) InsertPipelineStep(yamlContent []byte, pipelineIndex int, pipelineStep map[string]any) ([]byte, error)
- func (l *Loader) LoadWithPreservation(path string) (*config.Configuration, []byte, error)
- func (l *Loader) RemovePipelineStep(yamlContent []byte, pipelineIndex int) ([]byte, error)
- func (l *Loader) RemovePipelineWithField(yamlContent []byte, pipelineIndex int, field string) ([]byte, error)
- func (l *Loader) Save(path string, content []byte, backupSuffix string) error
- func (l *Loader) SaveWithBackup(path string, content []byte) error
- func (l *Loader) SetEpoch(yamlContent []byte, newEpoch int64) ([]byte, error)
- func (l *Loader) SetEpochWithComment(yamlContent []byte, newEpoch int64, comment string) ([]byte, error)
- func (l *Loader) UpdateField(yamlContent []byte, path, newValue string) ([]byte, error)
- func (l *Loader) UpdateFieldAsQuotedString(yamlContent []byte, path string, newValue string) ([]byte, error)
- func (l *Loader) UpdateFieldWithBlockScalar(yamlContent []byte, path string, newValue string) ([]byte, error)
- func (l *Loader) UpdateGoBumpDeps(yamlContent []byte, pipelineIndex int, newDeps []string) ([]byte, error)
- func (l *Loader) UpdateGoBumpStep(yamlContent []byte, pipelineIndex int, deps, replaces []string, ...) ([]byte, error)
- func (l *Loader) UpdateIntField(yamlContent []byte, path string, newValue int64) ([]byte, error)
- func (l *Loader) UpdatePackageVersion(yamlContent []byte, newVersion string) ([]byte, error)
- func (l *Loader) UpdatePipelineField(yamlContent []byte, pipelineIndex int, field, newValue string) ([]byte, error)
- func (l *Loader) UpsertPipelineWithBlockScalar(yamlContent []byte, pipelineIndex int, field, value string) ([]byte, error)
- func (l *Loader) UpsertPipelineWithQuotedString(yamlContent []byte, pipelineIndex int, field, value string) ([]byte, error)
- func (l *Loader) ValidateUpdatedConfig(content []byte, tempPath string) error
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BumpStep ¶ added in v0.3.0
type BumpStep struct {
Index int // pipeline index
Action string // "bump" or "go/bump"
Language string // parsed with.language entry ("" when absent)
GoVersion string // parsed with.go-version entry ("" when absent)
Modroots []string // parsed with.modroot entries; defaults to ["."] when absent
Deps []string // parsed with.deps entries ("module@version")
Replaces []string // parsed with.replaces entries ("old=new@version")
}
BumpStep describes a bump or go/bump pipeline step and its parsed with-fields.
type BumpStepSpec ¶ added in v0.3.0
type BumpStepSpec struct {
Action string // "bump" or "go/bump"
Language string // omitted from YAML when empty
GoVersion string // omitted when empty; rendered as a quoted scalar
Modroots []string // omitted when just ["."]; block scalar list otherwise
Deps []string // block scalar list
Replaces []string // block scalar list
}
BumpStepSpec describes a bump/go-bump pipeline step to insert via InsertBumpPipelineStep. String/slice fields that are empty (or, for Modroots, just ["."] - the pipeline's own default) are omitted from the emitted YAML entirely rather than written as empty/default values.
type GoPackagePin ¶ added in v0.3.0
type GoPackagePin struct {
Path string // goccy yaml path, e.g. "$.pipeline[3].with.go-package" or "$.subpackages[2].pipeline[0].with.go-package"
Subpackage string // subpackage name for messages; "" for top-level
Value string // raw string value (possibly templated)
Uses string // the step's uses: value ("go/build" or "go/install")
Modroot string // raw with.modroot (possibly templated); "." when absent - go/build only, go/install has none
}
GoPackagePin locates one go/build|go/install step's with.go-package value.
type Loader ¶
type Loader struct{}
Loader handles loading and saving melange configurations while preserving YAML structure
func (*Loader) FindBumpSteps ¶ added in v0.3.0
FindBumpSteps finds all bump and go/bump pipeline steps, in pipeline order, with their modroot and deps fields parsed.
func (*Loader) FindGoPackagePins ¶ added in v0.3.0
func (l *Loader) FindGoPackagePins(yamlContent []byte) ([]GoPackagePin, error)
FindGoPackagePins walks the top-level pipeline and every subpackage's pipeline for go/build and go/install steps carrying a string with.go-package pin, returning one GoPackagePin per pin found - in top-level-then-subpackage, then pipeline order. Steps without a go-package field are not returned; there's nothing to edit. Each pin's Path is a goccy yaml path directly usable with UpdateField to rewrite it in place.
func (*Loader) FindPipelinesByUse ¶
FindPipelinesByUse finds pipeline indices that use a specific pipeline type
func (*Loader) GetBumpModroots ¶ added in v0.3.0
GetBumpModroots extracts the modroot field from a bump/go-bump pipeline step. When the field is absent, it defaults to ["."], matching the pipeline's own default (the current directory).
func (*Loader) GetBumpReplaces ¶ added in v0.3.0
GetBumpReplaces extracts the replaces field ("old=new@version" entries) from a bump or go/bump pipeline step.
func (*Loader) GetGoBumpDeps ¶
GetGoBumpDeps extracts the deps field from a bump or go/bump pipeline
func (*Loader) GetPackageInfo ¶
GetPackageInfo extracts package name and version from YAML content
func (*Loader) GetPipelineWithField ¶
func (l *Loader) GetPipelineWithField(yamlContent []byte, pipelineIndex int) (map[string]string, error)
GetPipelineWithField gets the with field map for a specific pipeline.
It reads the with block off the comment-preserving AST (rather than via yaml.Unmarshal) so that non-string scalars surface their raw token text instead of being dropped or coerced. An UNQUOTED "go-version: 1.30" parses as a YAML float; unmarshalling would either drop it (map[string]string only keeps string values) or, worse, coerce it through float64 to "1.3" - a 27-minor corruption of a pinned toolchain. Reading the AST token keeps the text exactly as written ("1.30"). Values with no meaningful scalar text (null, sequences, nested mappings) are skipped, matching the prior reader.
func (*Loader) HasBlankLinesBetweenPipelineSteps ¶ added in v0.3.0
HasBlankLinesBetweenPipelineSteps reports whether the YAML separates pipeline steps with blank lines. Callers that remove steps before re-inserting must capture this from the ORIGINAL content - a stripped pipeline may no longer have two adjacent steps to detect the convention from.
func (*Loader) IncrementEpoch ¶
IncrementEpoch increments the epoch field by 1
func (*Loader) InsertBumpPipelineStep ¶ added in v0.3.0
func (l *Loader) InsertBumpPipelineStep(yamlContent []byte, pipelineIndex int, spec BumpStepSpec, blankLineBetweenSteps bool) ([]byte, error)
InsertBumpPipelineStep inserts a bump or go/bump step with block-scalar deps and replaces lists and, for multi-root bumps, a block-scalar modroot list. blankLineBetweenSteps says whether the file's convention separates pipeline steps with a blank line (see HasBlankLinesBetweenPipelineSteps) - it's the caller's to supply because yamlContent may already have had steps removed, leaving nothing to detect the original convention from.
func (*Loader) InsertPipelineStep ¶
func (l *Loader) InsertPipelineStep(yamlContent []byte, pipelineIndex int, pipelineStep map[string]any) ([]byte, error)
InsertPipelineStep inserts a new pipeline step at the specified index
func (*Loader) LoadWithPreservation ¶
LoadWithPreservation loads a melange config while preserving YAML structure and comments
func (*Loader) RemovePipelineStep ¶
RemovePipelineStep removes a single pipeline step by index while preserving formatting
func (*Loader) RemovePipelineWithField ¶ added in v0.3.0
func (l *Loader) RemovePipelineWithField(yamlContent []byte, pipelineIndex int, field string) ([]byte, error)
RemovePipelineWithField removes a single field from a pipeline step's with map, preserving the rest of the step and surrounding formatting.
func (*Loader) Save ¶
Save saves the updated YAML content to file, optionally creating a backup backupSuffix: suffix for backup files (empty = no backup) Returns error if save failed, nil if no changes needed or save successful
func (*Loader) SaveWithBackup ¶
SaveWithBackup saves the updated YAML content to file with backup
func (*Loader) SetEpochWithComment ¶ added in v0.3.0
func (l *Loader) SetEpochWithComment(yamlContent []byte, newEpoch int64, comment string) ([]byte, error)
SetEpochWithComment sets the epoch field and attaches an inline intent comment on the same line (`epoch: 2 # <comment>`), replacing any existing inline comment there. The value write goes through the same ReplaceWithReader path as SetEpoch - which discards the old value node and its inline comment - so the comment is attached to the freshly written value node afterwards, within the same parse/render cycle. An empty comment behaves exactly like SetEpoch.
func (*Loader) UpdateField ¶
UpdateField updates a specific field in the YAML while preserving structure
func (*Loader) UpdateFieldAsQuotedString ¶
func (l *Loader) UpdateFieldAsQuotedString(yamlContent []byte, path string, newValue string) ([]byte, error)
UpdateFieldAsQuotedString updates a field with a double-quoted string value This is essential for fields like package.version where values like "1.0" must be rendered as strings to prevent YAML from interpreting them as numbers
func (*Loader) UpdateFieldWithBlockScalar ¶
func (l *Loader) UpdateFieldWithBlockScalar(yamlContent []byte, path string, newValue string) ([]byte, error)
UpdateFieldWithBlockScalar updates a field to use block scalar format (|-)
func (*Loader) UpdateGoBumpDeps ¶
func (l *Loader) UpdateGoBumpDeps(yamlContent []byte, pipelineIndex int, newDeps []string) ([]byte, error)
UpdateGoBumpDeps updates the deps field in a go/bump pipeline
func (*Loader) UpdateGoBumpStep ¶ added in v0.3.0
func (l *Loader) UpdateGoBumpStep(yamlContent []byte, pipelineIndex int, deps, replaces []string, goVersion string) ([]byte, error)
UpdateGoBumpStep updates a bump/go-bump step's deps, replaces and go-version fields in place. Both deps and replaces empty removes the whole step; deps empty with replaces present keeps the step (gobump accepts a replaces-only invocation) and removes just the deps field; an empty replaces list removes just that field. goVersion == "" leaves any existing go-version field untouched (it is never removed by this call); a non-empty goVersion upserts go-version as a quoted scalar so it can never round-trip as a YAML float.
func (*Loader) UpdateIntField ¶
UpdateIntField updates an integer field in the YAML
func (*Loader) UpdatePackageVersion ¶
UpdatePackageVersion updates the package version (epoch handling moved to EpochApplier)
func (*Loader) UpdatePipelineField ¶
func (l *Loader) UpdatePipelineField(yamlContent []byte, pipelineIndex int, field, newValue string) ([]byte, error)
UpdatePipelineField updates a field within a specific pipeline
func (*Loader) UpsertPipelineWithBlockScalar ¶ added in v0.3.0
func (l *Loader) UpsertPipelineWithBlockScalar(yamlContent []byte, pipelineIndex int, field, value string) ([]byte, error)
UpsertPipelineWithBlockScalar sets a pipeline step's with.<field> to a block scalar (|-) value, creating the field when it doesn't exist yet. UpdateFieldWithBlockScalar alone can't create fields (yamlPath. ReplaceWithNode fails on a missing path), and goccy's renderer does not reliably emit AST nodes appended to an existing mapping - so the append case locates the end of the with block via the AST and splices correctly indented lines into the source text directly.
func (*Loader) UpsertPipelineWithQuotedString ¶ added in v0.3.0
func (l *Loader) UpsertPipelineWithQuotedString(yamlContent []byte, pipelineIndex int, field, value string) ([]byte, error)
UpsertPipelineWithQuotedString sets a pipeline step's with.<field> to a double-quoted scalar value, creating the field when it doesn't exist yet. Modeled on UpsertPipelineWithBlockScalar: yamlPath.ReplaceWithNode is a silent no-op on a missing path, so field existence is probed first via the type-blind pipelineWithHasField; when the field already exists, UpdateFieldAsQuotedString replaces it in place, otherwise the `field: "value"` line is spliced into the source text directly, since goccy's renderer does not reliably emit AST nodes appended to an existing mapping. Both paths embed value literally between double quotes (the replace path via createQuotedStringNode's rendered Origin, the splice path in the text itself), so value is validated up front either way.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer provides variable rendering for melange configurations It builds a complete variable context and can render strings or entire configs
func NewRenderer ¶
func NewRenderer(cfg *melange.Configuration) (*Renderer, error)
NewRenderer creates a new renderer for the given melange configuration
func (*Renderer) GetVariable ¶
GetVariable gets the value of a specific variable
func (*Renderer) GetVariableMap ¶
GetVariableMap returns a copy of the complete variable map
func (*Renderer) RenderConfig ¶
func (r *Renderer) RenderConfig() (*melange.Configuration, error)
RenderConfig creates a new configuration with all variables resolved This is useful when you need a fully rendered config for processing