download

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package download is responsible for downloading vendored modules.

Index

Constants

View Source
const (
	// ErrAlreadyVendored indicates that a module is already vendored.
	ErrAlreadyVendored errors.Kind = "module is already vendored"

	// ErrUnsupportedModSrc indicates that the module source is not supported.
	ErrUnsupportedModSrc errors.Kind = "unsupported module source"

	// ErrDownloadMod indicates that an error occurred while trying to download a module.
	ErrDownloadMod errors.Kind = "downloading module"

	// ErrModRefEmpty indicates that a module source had no reference on it.
	ErrModRefEmpty errors.Kind = "module ref is empty"
)

Variables

This section is empty.

Functions

func HandleVendorRequests

func HandleVendorRequests(
	rootdir string,
	vendorRequests <-chan event.VendorRequest,
	progressEvents ProgressEventStream,
) <-chan Report

HandleVendorRequests starts a goroutine that will handle all vendor requests sent on vendorRequests, calling Vendor for each event and sending one report result for each event on the returned Report channel.

It will read events from vendorRequests until it is closed. If progressEvents is nil it will not send any progress events, like Vendor.

When vendorRequests is closed it will close the returned Report channel, indicating that no more processing will be done.

func MergeVendorReports

func MergeVendorReports(reports <-chan Report) <-chan Report

MergeVendorReports will read all reports from the given reports channel, merge them and send the merged result on the returned channel and then close it. The returned channel always produce a single final report after the given reports channel is closed.

Types

type IgnoredVendor

type IgnoredVendor struct {
	RawSource string
	Reason    error
}

IgnoredVendor describes an ignored dependency.

type ProgressEventStream

type ProgressEventStream event.Stream[event.VendorProgress]

ProgressEventStream is a stream of vendor related events.

func NewEventStream

func NewEventStream() ProgressEventStream

NewEventStream creates a new event stream.

func (ProgressEventStream) Send

Send send a progress event.

type Report

type Report struct {
	Vendored map[project.Path]Vendored
	Ignored  []IgnoredVendor
	Error    error
	// contains filtered or unexported fields
}

Report with the result of the vendor related functions.

func NewReport

func NewReport(vendordir project.Path) Report

NewReport returns a new empty report.

func Vendor

func Vendor(
	rootdir string,
	vendorDir project.Path,
	modsrc tf.Source,
	events ProgressEventStream,
) Report

Vendor will vendor the given module and its dependencies inside the provided root dir. The root dir must be an absolute path. The vendor dir must be an absolute path that will be considered as relative to the given rootdir.

Vendored modules will be located at:

- <rootdir>/<vendordir>/<Source.Path>/<Source.Ref>

The whole path inside the vendor dir will be created if it not exists. Vendoring will not download any git submodules.

The remote git module dependencies will also be vendored and each module.source declaration for those dependencies will be rewritten to reference them inside the vendor directory.

An [EventStream] instance may be passed if the caller is interested on live events from what is happening inside the vendoring process. Passing a nil EventStream ignores all events. It is the caller responsibility to close the [EventStream] after the Vendor call returns.

It returns a report of everything vendored and ignored (with a reason).

func VendorAll

func VendorAll(
	rootdir string,
	vendorDir project.Path,
	tfdir string,
	events ProgressEventStream,
) Report

VendorAll will vendor all dependencies of the tfdir into rootdir. It will scan all .tf files in the directory and vendor each module declaration containing the supported remote source URLs.

func (Report) HasFailures

func (r Report) HasFailures() bool

HasFailures returns true if any vendor attempt failed. It will exclude all ErrAlreadyVendored since those indicate that the module exists on the vendor dir.

func (Report) IsEmpty

func (r Report) IsEmpty() bool

IsEmpty returns true if the report is empty (nothing to report).

func (*Report) RemoveIgnoredByKind

func (r *Report) RemoveIgnoredByKind(kind errors.Kind)

RemoveIgnoredByKind removes all ignored from this report that have errors with the given kind.

func (Report) String

func (r Report) String() string

func (Report) Verbose

func (r Report) Verbose() string

Verbose is like String but outputs additional fields (like Errors).

type Vendored

type Vendored struct {
	// Source is the remote source.
	Source tf.Source
	// Dir is the directory where the dependency have been vendored into.
	Dir project.Path
}

Vendored describes a vendored dependency.

Jump to

Keyboard shortcuts

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