vendeps

package
v0.0.0-...-6a00723 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package vendeps provides functionality for managing vendored external dependencies.

Index

Constants

View Source
const (
	BuildBazel  = "BUILD.bazel"
	DepsBzl     = "deps.bzl"
	ManifestBzl = "manifest.bzl"
	Vendor      = "vendor"
)

Variables

View Source
var Licenses = map[string]string{
	"0BSD":         "BSD Zero Clause License",
	"Apache-2.0":   "Apache License 2.0",
	"BSD-2-Clause": "BSD 2-Clause \"Simplified\" License",
	"BSD-3-Clause": "BSD 3-Clause \"New\" or \"Revised\" License",
	"MIT":          "MIT License",
}

Licenses is the set of acceptable software licenses, referenced by their SPDX id.

Functions

func AcceptableLicense

func AcceptableLicense(options string) (license string, ok bool)

AcceptableLicense determines whether the given set of licenses includes at least one acceptable license as described above.

func ApplyPatches

func ApplyPatches(dir string, patchArgs []string, patches []string) error

ApplyPatches applies the given set of patch files to the directory specified.

func DigestDirectory

func DigestDirectory(fsys fs.FS, dir string, ignore ...string) (string, error)

DigestDirectory produces the digest for a directory and its contents in a filesystem. This is performed by hashing one line of text for each file, with the files sorted into lexographical order. Each line consists of the hexadecimal digest of the file's contents, two spaces (\x20), the relative filename, and a newline (\x0a).

Filenames containing a newline (\x0a) are not allowed.

Any filenames listed in ignore are not included in the hashing process.

The final digest is formatted as the hash algorithm name, a colon (\x3a), and the hexadecimal digest.

func DigestFiles

func DigestFiles(fsys fs.FS, filenames []string) (string, error)

DigestFiles produces the digest for a set of named files and their contents in a filesystem. This is performed by hashing one line of text for each file, with the files sorted into lexographical order. Each line consists of the hexadecimal digest of the file's contents, two spaces (\x20), the relative filename, and a newline (\x0a).

Filenames containing a newline (\x0a) are not allowed.

The final digest is formatted as the hash algorithm name, a colon (\x3a), and the hexadecimal digest.

func FetchGoModule

func FetchGoModule(ctx context.Context, mod *GoModule, dir string) error

FetchGoModule downloads a Go module using the proxy.golang.org Go module proxy API.

func UpdateGoModule

func UpdateGoModule(ctx context.Context, mod *UpdateDep) (updated bool, err error)

UpdateGoModule checks a Go module for updates, using the proxy.golang.org Go module proxy API.

Types

type Action

type Action interface {
	Do(fs.FS) error
	fmt.Stringer
}

Action represents a logical action that should be taken to progress the vendoring of a set of software dependencies.

An action should contain any context necessary to perform its tasks.

func StripCachedActions

func StripCachedActions(fsys fs.FS, actions []Action) []Action

StripCachedActions processes the action sequence, removing any actions that the cache can prove are unnecessary, returning the resulting action sequence.

If no actions can be cached, or if there is no cache, the unmodified action sequence is returned.

type CopyBUILD

type CopyBUILD struct {
	Source string
	Path   string
}

CopyBUILD indicates that the named BUILD file should be copied to the given path.

func (CopyBUILD) Do

func (c CopyBUILD) Do(fsys fs.FS) error

func (CopyBUILD) String

func (c CopyBUILD) String() string

type Deps

type Deps struct {
	Go []*GoModule `bzl:"go/module"`
}

Deps describes a set of software dependencies.

func GenerateCacheManifest

func GenerateCacheManifest(fsys fs.FS, deps *Deps) (*Deps, error)

GenerateCacheManifest produces the cache manifest, which describes the set of data cached in the vendor directly.

type DownloadGoModule

type DownloadGoModule struct {
	Module *GoModule
	Path   string
}

DownloadModule indicates that the named module should be downloaded from the module proxy and extracted into the given path.

func (DownloadGoModule) Do

func (c DownloadGoModule) Do(fsys fs.FS) error

func (DownloadGoModule) String

func (c DownloadGoModule) String() string

type GoModule

type GoModule struct {
	// Dependency details.
	Name    string `bzl:"name"`
	Version string `bzl:"version"`

	// Patches to be applied to the
	// downloaded module, before the
	// BUILD file is copied/generated.
	PatchArgs []string `bzl:"patch_args"`
	Patches   []string `bzl:"patches"`

	// Packages that should be used.
	Packages []*GoPackage `bzl:"packages/package"`

	// Directories containing plain files.
	Directories []*TextFiles `bzl:"directories/files"`

	// Generation details.
	Digest      string `bzl:"digest"`
	PatchDigest string `bzl:"patch_digest"`
}

GoModule contains the information necessary to vendor a Go module, specifying the set of packages within the module that are used.

type GoPackage

type GoPackage struct {
	// Dependency details.
	Name string `bzl:"name"`

	// Whether to use Bzlmod names
	// (eg rules_go, rather than io_bazel_rules_go).
	Bzlmod bool

	// Manually-managed BUILD file.
	BuildFile string `bzl:"build_file"`

	// Build configuration.
	Deps       []string `bzl:"deps"`
	Embed      []string `bzl:"embed"`
	EmbedGlobs []string `bzl:"embed_globs"`

	// Binary configuration.
	Binary     bool     `bzl:"binary"`
	BinaryDeps []string `bzl:"binary_deps"`

	// Test configuration.
	NoTests       bool     `bzl:"no_tests"`
	TestSize      string   `bzl:"test_size"`
	TestData      []string `bzl:"test_data"`
	TestDataGlobs []string `bzl:"test_data_globs"`
	TestDeps      []string `bzl:"test_deps"`
}

GoPackage describes a package within a Go module.

type RemoveAll

type RemoveAll string

RemoveAll deletes a directory, along with any child nodes that exist. If the path does not exist, there is no effect.

func (RemoveAll) Do

func (r RemoveAll) Do(fsys fs.FS) error

func (RemoveAll) String

func (r RemoveAll) String() string

type TextFiles

type TextFiles struct {
	// Dependency details.
	Name string `bzl:"name"`

	// Export files publicly.
	ExportsFiles []string `bzl:"exports_files"`
}

TextFiles contains information necessary to manage text files.

type UpdateDep

type UpdateDep struct {
	Name    string
	Version *string
}

UpdateDep describes the least information necessary to determine a third-party software library. This is used when determining whether updates are available.

type UpdateDeps

type UpdateDeps struct {
	Go []*UpdateDep
}

UpdateDeps includes a set of dependencies for the purposes of updating them.

Jump to

Keyboard shortcuts

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