bazelmod

package
v0.116.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSpecFileUndefined is returned if a file wasn't specified
	ErrSpecFileUndefined = errors.New("bazelmod file undefined")
	// ErrSpecModuleUndefined is returned if a module wasn't specified
	ErrSpecModuleUndefined = errors.New("bazelmod module undefined")
	// ErrWrongSpec is returned when the Spec has wrong content
	ErrWrongSpec = errors.New("wrong spec content")
)

Functions

This section is empty.

Types

type BazelDep

type BazelDep struct {
	Name     string
	Version  string
	RepoName string // Optional repo_name parameter
	LineNum  int    // Line number in the original file (1-indexed)
	FullLine string // The complete line(s) for this bazel_dep call
}

BazelDep represents a bazel_dep() function call

type Bazelmod

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

Bazelmod stores configuration about the MODULE.bazel file and the module to update

func New

func New(spec interface{}) (*Bazelmod, error)

New returns a reference to a newly initialized Bazelmod object from a Spec or an error if the provided Spec triggers a validation error.

func (*Bazelmod) Changelog

func (b *Bazelmod) Changelog(from, to string) *result.Changelogs

Changelog returns the changelog for this resource, or nil if not supported

func (*Bazelmod) Condition

func (b *Bazelmod) Condition(_ context.Context, source string, scm scm.ScmHandler) (pass bool, message string, err error)

Condition checks if the version in MODULE.bazel matches the expected version

func (*Bazelmod) ReportConfig

func (b *Bazelmod) ReportConfig() interface{}

ReportConfig returns a new configuration object with only the necessary fields to identify the resource without any sensitive information or context specific data.

func (*Bazelmod) Source

func (b *Bazelmod) Source(_ context.Context, workingDir string, resultSource *result.Source) error

Source reads the version of the specified module from MODULE.bazel

func (*Bazelmod) Target

func (b *Bazelmod) Target(_ context.Context, source string, scm scm.ScmHandler, dryRun bool, resultTarget *result.Target) error

Target updates the module version in MODULE.bazel file

func (*Bazelmod) Validate

func (b *Bazelmod) Validate() error

Validate tests that the Bazelmod struct is correctly configured

type ModuleFile

type ModuleFile struct {
	Content string
	Deps    []BazelDep
	Lines   []string
}

ModuleFile represents a parsed MODULE.bazel file

func ParseModuleFile

func ParseModuleFile(content string) (*ModuleFile, error)

ParseModuleFile parses a MODULE.bazel file and extracts all bazel_dep() calls

func (*ModuleFile) FindDepByName

func (mf *ModuleFile) FindDepByName(name string) *BazelDep

FindDepByName finds a bazel_dep by module name

func (*ModuleFile) UpdateDepVersion

func (mf *ModuleFile) UpdateDepVersion(moduleName, newVersion string) (string, error)

UpdateDepVersion updates the version of a specific module in the file content

type Spec

type Spec struct {
	// File specifies the path to the MODULE.bazel file
	//
	// compatible:
	//   * source
	//   * condition
	//   * target
	//
	// example:
	//   * MODULE.bazel
	//   * path/to/MODULE.bazel
	File string `yaml:",omitempty" jsonschema:"required"`
	// Module specifies the Bazel module name to target
	//
	// compatible:
	//   * source
	//   * condition
	//   * target
	//
	// example:
	//   * rules_go
	//   * gazelle
	//   * protobuf
	Module string `yaml:",omitempty" jsonschema:"required"`
}

Spec defines a specification for a "bazelmod" resource parsed from an updatecli manifest file

func (*Spec) Validate

func (s *Spec) Validate() error

Validate tests that the spec has the required fields

Jump to

Keyboard shortcuts

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