vending

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package vending provides the public primitives that are needed for working with the tool.

Index

Constants

View Source
const VERSION = "v0.4.9"

VERSION of the current tool

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultPreset

type DefaultPreset struct{}

DefaultPreset provides the default configuration for the vendor library.

func (*DefaultPreset) ForceFilters

func (dp *DefaultPreset) ForceFilters() bool

func (*DefaultPreset) GetCacheDir

func (dp *DefaultPreset) GetCacheDir() string

GetCacheDir default implementation tries to return a path under the user home dir. When this operation fails, it resorts back to a temporary dir..

func (*DefaultPreset) GetFilters

func (dp *DefaultPreset) GetFilters() *Filters

func (*DefaultPreset) GetFiltersForDependency

func (dp *DefaultPreset) GetFiltersForDependency(*Dependency) *Filters

func (*DefaultPreset) GetPresetName

func (dp *DefaultPreset) GetPresetName() string

func (*DefaultPreset) GetSpecFilename

func (dp *DefaultPreset) GetSpecFilename() string

func (*DefaultPreset) GetSpecLockFilename

func (dp *DefaultPreset) GetSpecLockFilename() string

func (*DefaultPreset) GetVendorDir

func (dp *DefaultPreset) GetVendorDir() string

type Dependency

type Dependency struct {
	URL     string   `yaml:"url"`
	Branch  string   `yaml:"branch"`
	Filters *Filters `yaml:",inline"`
}

Dependency holds relevant information related to a dependency that has to be vendored. This model directly maps to the serialized YAML, for dependencies.

func NewDependency

func NewDependency(url, branch string) *Dependency

NewDependency allocates a Dependency, with a default Filters instance.

func (*Dependency) Update

func (d *Dependency) Update(other *Dependency)

Update changes the URL, Branch and Filters fields of the dependency by the fields of another one. This clones the Filters to ensure there's no shared data with the other Dependency.

type DependencyLock

type DependencyLock struct {
	URL    string `yaml:"url"`
	Commit string `yaml:"commit"`
}

DependencyLock holds relevant information of a dependency that has been locked to a specific commit. This model directly maps to the serialized YAML for locked dependencies.

func NewDependencyLock

func NewDependencyLock(url, commit string) *DependencyLock

NewDependencyLock allocates a new DependencyLock

type Filters

type Filters struct {
	Extensions []string `yaml:"extensions,omitempty"`
	Targets    []string `yaml:"targets,omitempty"`
	Ignores    []string `yaml:"ignores,omitempty"`
}

Filters is a collection type. When vendoring dependencies we look if the file paths are copied or ignored, or whether the extension is supported. Filters are directly serialized into the output YAML.

Filters supposed to make life easier proving a builder pattern so it's convenient to create, but also merge operations with other Filters or even Presets and Dependencies. This is really handy because this tool supports both global customization, and specific granular configurations for each dependency. For this reason, we often need to combine multiple Filters before we're able to vendor a dependency.

func NewFilters

func NewFilters() *Filters

NewFilters allocates a Filters instance with empty lists initialization.

func (*Filters) AddExtension

func (f *Filters) AddExtension(extension ...string) *Filters

AddExtension adds one or several extensions to the collection.

func (*Filters) AddIgnore

func (f *Filters) AddIgnore(ignore ...string) *Filters

AddIgnore adds one or several ignored paths to the collection.

func (*Filters) AddTarget

func (f *Filters) AddTarget(target ...string) *Filters

AddTarget adds one or several target paths to the collection.

func (*Filters) ApplyFilters

func (f *Filters) ApplyFilters(filters *Filters) *Filters

ApplyFilters merges the current Filters instance with another one. Because this method combines instances, it stabilizes the results by doing the intersection, but also sorting the entries.

func (*Filters) ApplyPreset

func (f *Filters) ApplyPreset(preset Preset) *Filters

ApplyPreset applies the Filters of a Preset.

func (*Filters) ApplyPresetForDependency added in v0.4.4

func (f *Filters) ApplyPresetForDependency(preset Preset, dep *Dependency) *Filters

ApplyPresetForDependency applies the filters of a Preset, and a Dependency.

func (*Filters) Clear added in v0.4.1

func (f *Filters) Clear() *Filters

Clear resets the lists.

func (*Filters) Clone

func (f *Filters) Clone() *Filters

Clone allocates a new instance, and clones the contents of the current one.

type Preset

type Preset interface {
	// GetPresetName returns the name for this preset
	GetPresetName() string

	// GetVendorDir returns the name for the vendor folder
	GetVendorDir() string

	// GetSpecFilename returns the name of the spec file
	GetSpecFilename() string

	// GetSpecLockFilename returns the name of the spec lock file
	GetSpecLockFilename() string

	// GetFilters returns the global filters of the preset
	GetFilters() *Filters

	// GetFiltersForDependency returns the specific filters for a dependency
	GetFiltersForDependency(*Dependency) *Filters

	// ForceFilters flag returns whether the preset will force the overriding of
	// the spec or dependency filters to the preset ones
	ForceFilters() bool

	// GetCacheDir returns the path where the repository cache will be kept
	GetCacheDir() string
}

Preset interface used to customize the behavior of the vendor library. It allows customizing anything you need, like the names of the spec and lock file, also allows customizing the targeted and ignored paths.

type Spec

type Spec struct {
	Version    string        `yaml:"version"`
	PresetName string        `yaml:"preset"`
	VendorDir  string        `yaml:"vendor_dir,omitempty"`
	Filters    *Filters      `yaml:",inline"`
	Deps       []*Dependency `yaml:"deps"`
	// contains filtered or unexported fields
}

Spec holds relevant information related to the specification of what versions need to be fetched when updating dependencies.

This model directly maps to the serialized YAML of the spec lock file.

func NewSpec

func NewSpec(preset Preset) *Spec

NewSpec allocates a new Spec instance with the default initialization.

func (*Spec) AddDependency

func (s *Spec) AddDependency(dependency *Dependency)

AddDependency adds a Dependency to the list of dependencies to vendor.

func (*Spec) Load added in v0.4.0

func (s *Spec) Load() error

Load Spec from the filesystem.

func (*Spec) Save

func (s *Spec) Save() error

Save converts the Spec to YAML, and writes the data in the spec file, as specified by the Preset.

type SpecLock

type SpecLock struct {
	Version string            `yaml:"version"`
	Deps    []*DependencyLock `yaml:"deps"`
	// contains filtered or unexported fields
}

SpecLock holds relevant information related to the specification of what specific versions need to be pinned when vendoring.

This model directly maps to the serialized YAML of the spec lock file.

func NewSpecLock

func NewSpecLock(preset Preset) *SpecLock

NewSpecLock allocates a new SpecLock instance with a default initialization.

func (*SpecLock) AddDependencyLock

func (s *SpecLock) AddDependencyLock(lock *DependencyLock)

AddDependencyLock adds a DependencyLock to the list of locked dependencies.

func (*SpecLock) FindByURL added in v0.3.6

func (s *SpecLock) FindByURL(url string) (*DependencyLock, bool)

FindByURL finds a DependencyLock by URL.

func (*SpecLock) Load added in v0.4.0

func (s *SpecLock) Load() error

Load SpecLock from the filesystem.

func (*SpecLock) Save

func (s *SpecLock) Save() error

Save converts the SpecLock to YAML, and writes the data in the spec lock file, as specified by the Preset.

Jump to

Keyboard shortcuts

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