module

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DotHLBPath is a relative directory containing files related to HLB.
	// It is expected to commit files in this directory to git repositories.
	DotHLBPath = "./.hlb"

	// ModulesPath is the subdirectory of DotHLBPath that contains vendored
	// modules.
	ModulesPath = filepath.Join(DotHLBPath, "modules")
)

Functions

func ModulesPathExist

func ModulesPathExist() (bool, error)

ModulesPathExist returns true if the modules directory exists in the current working directory.

func NewResolver

func NewResolver(cln *client.Client) (codegen.Resolver, error)

NewResolver returns a resolver based on whether the modules path exists in the current working directory.

func NewTree

func NewTree(ctx context.Context, cln *client.Client, mod *ast.Module, long bool) (treeprint.Tree, error)

NewTree resolves the import graph and returns a treeprint.Tree that can be printed to display a visualization of the imports. Imports that transitively import the same module will be duplicated in the tree.

func ResolveGraph

func ResolveGraph(ctx context.Context, cln *client.Client, resolver codegen.Resolver, mod *ast.Module, visitor Visitor) error

ResolveGraph traverses the import graph of a given module.

func Vendor

func Vendor(ctx context.Context, cln *client.Client, mod *ast.Module, targets []string, tidy bool) error

Vendor resolves the import graph and writes the contents into the modules directory of the current working directory.

If tidy mode is enabled, vertices with digests that already exist in the modules directory are skipped, and unused modules are pruned.

func VendorPath

func VendorPath(root string, dgst digest.Digest) string

VendorPath returns a modules path based on the digest of marshalling the LLB. This digest is stable even when the underlying remote sources change contents, for example `alpine:latest` may be pushed to.

Types

type VisitInfo

type VisitInfo struct {
	Parent     *ast.Module
	Import     *ast.Module
	ImportDecl *ast.ImportDecl
	Filename   string
	Digest     digest.Digest
}

type Visitor

type Visitor func(info VisitInfo) error

Visitor is a callback invoked for every import when traversing the import graph.

Jump to

Keyboard shortcuts

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