rules

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

package rules is used find and modify Bazel rules in WORKSPACE and bzl files.

Index

Constants

This section is empty.

Variables

View Source
var (
	// SupportedRules is a list of all rules that can be mirrored.
	SupportedRules = []string{
		"http_archive",
		"http_file",
		"rpm",
	}

	// ErrNoUpstreamURL is returned when a rule has no upstream URL.
	ErrNoUpstreamURL = errors.New("rule has no upstream URL")
)

Functions

func AddURLs

func AddURLs(rule *build.Rule, urls []string)

AddURLs adds a url to a rule.

func Check

func Check(rule *build.Rule) (validationErrs []error)

Check checks if a dependency rule is normalized and contains a mirror url. All errors reported by this function can be fixed by calling AddURLs and Normalize.

func GetHash

func GetHash(rule *build.Rule) (string, error)

GetHash returns the sha256 hash of a rule.

func GetURLs

func GetURLs(rule *build.Rule) []string

GetURLs returns the sorted urls of a rule.

func HasMirrorURL

func HasMirrorURL(rule *build.Rule) bool

HasMirrorURL returns true if the rule has a url from the Edgeless mirror with the correct hash.

func Normalize

func Normalize(rule *build.Rule) (changed bool)

Normalize normalizes a rule and returns true if the rule was changed.

func PrepareUpgrade

func PrepareUpgrade(rule *build.Rule) (changed bool, err error)

PrepareUpgrade prepares a rule for an upgrade by removing all urls that are not upstream urls. and removing the hash attribute. it returns true if the rule was changed.

func Rules

func Rules(file *build.File, filter []string) (rules []*build.Rule)

Rules is used to find and modify Bazel rules of a set of rule kinds in WORKSPACE and .bzl files. Filter is a list of rule kinds to consider. If filter is empty, all rules are considered.

func SetHash

func SetHash(rule *build.Rule, hash string)

SetHash sets the sha256 hash of a rule.

func UpstreamURLs

func UpstreamURLs(rule *build.Rule) (urls []string, err error)

UpstreamURLs returns the upstream urls (non-mirror urls) of a rule.

func ValidatePinned

func ValidatePinned(rule *build.Rule) (validationErrs []error)

ValidatePinned checks if the given rule is a pinned dependency rule. That is, if it has a name, either a url or urls attribute, and a sha256 attribute.

Types

This section is empty.

Jump to

Keyboard shortcuts

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