dependency

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package dependencies checks dependencies, locally or remotely

Index

Constants

This section is empty.

Variables

View Source
var NewRemoteClient = func() (Client, error) {
	return nil, UnsupportedError{"remote upstream functionality is not supported by this command; use sigs.k8s.io/zeitgeist/remote/zeitgeist"}
}

Functions

func ToFile added in v0.5.0

func ToFile(dependencyFilePath string, dependencies *Dependencies) error

Types

type Client

type Client interface {
	// LocalCheck checks whether dependencies are in-sync locally
	//
	// Will return an error if the dependency cannot be found in the files it has defined, or if the version does not match
	LocalCheck(dependencyFilePath, basePath string) error

	// RemoteCheck checks whether dependencies are up to date with upstream
	//
	// Will return an error if checking the versions upstream fails.
	//
	// Out-of-date dependencies will be printed out on stdout at the INFO level.
	RemoteCheck(dependencyFilePath string) ([]string, error)

	// Upgrade retrieves the most up-to-date version of the dependency and replaces
	// the local version with the most up-to-date version.
	//
	// Will return an error if checking the versions upstream fails, or if updating
	// files fails.
	Upgrade(dependencyFilePath, basePath string) ([]string, error)

	SetVersion(dependencyFilePath, basePath, dependency, version string) error

	RemoteExport(dependencyFilePath string) ([]VersionUpdate, error)

	CheckUpstreamVersions(deps []*Dependency) ([]VersionUpdateInfo, error)
}

Client holds any client that is needed

func NewLocalClient added in v0.5.0

func NewLocalClient() (Client, error)

NewClient returns all clients that can be used to the validation

type Dependencies

type Dependencies struct {
	Dependencies []*Dependency `yaml:"dependencies"`
}

Dependencies is used to deserialise the configuration file

func FromFile added in v0.5.0

func FromFile(dependencyFilePath string) (*Dependencies, error)

type Dependency

type Dependency struct {
	Name string `yaml:"name"`
	// Version of the dependency that should be present throughout your code
	Version string `yaml:"version"`
	// Scheme for versioning this dependency
	Scheme VersionScheme `yaml:"scheme"`
	// Optional: sensitivity, to alert e.g. on new major versions
	Sensitivity VersionSensitivity `yaml:"sensitivity,omitempty"`
	// Optional: upstream
	Upstream map[string]string `yaml:"upstream,omitempty"`
	// List of references to this dependency in local files
	RefPaths []*RefPath `yaml:"refPaths"`
}

Dependency is the internal representation of a dependency

func (*Dependency) UnmarshalYAML

func (decoded *Dependency) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements custom unmarshalling of Dependency with validation

type LocalClient added in v0.5.0

type LocalClient struct{}

func (*LocalClient) CheckUpstreamVersions added in v0.5.0

func (c *LocalClient) CheckUpstreamVersions(deps []*Dependency) ([]VersionUpdateInfo, error)

func (*LocalClient) LocalCheck added in v0.5.0

func (c *LocalClient) LocalCheck(dependencyFilePath, basePath string) error

LocalCheck checks whether dependencies are in-sync locally

Will return an error if the dependency cannot be found in the files it has defined, or if the version does not match

func (*LocalClient) RemoteCheck added in v0.5.0

func (c *LocalClient) RemoteCheck(dependencyFilePath string) ([]string, error)

func (*LocalClient) RemoteExport added in v0.5.0

func (c *LocalClient) RemoteExport(dependencyFilePath string) ([]VersionUpdate, error)

func (*LocalClient) SetVersion added in v0.5.0

func (c *LocalClient) SetVersion(dependencyFilePath, basePath, dependency, version string) error

SetVersion sets the version of a dependency to the specified version

Will return an error if updating files fails.

func (*LocalClient) Upgrade added in v0.5.0

func (c *LocalClient) Upgrade(dependencyFilePath, basePath string) ([]string, error)

type RefPath

type RefPath struct {
	// Path of the file to test
	Path string `yaml:"path"`
	// Match expression for the line that should contain the dependency's version. Regexp is supported.
	Match string `yaml:"match"`
}

RefPath represents a file to check for a reference to the version

type UnsupportedError added in v0.5.0

type UnsupportedError struct {
	// contains filtered or unexported fields
}

func (UnsupportedError) Error added in v0.5.0

func (u UnsupportedError) Error() string

type Version

type Version struct {
	Version string
	Scheme  VersionScheme
}

Version is the internal representation of a Version as a string and a scheme

func (Version) MoreRecentThan

func (a Version) MoreRecentThan(b Version) (bool, error)

MoreRecentThan checks whether a given version is more recent than another one.

If the VersionScheme is "random", then it will return true if a != b.

func (Version) MoreSensitivelyRecentThan

func (a Version) MoreSensitivelyRecentThan(b Version, sensitivity VersionSensitivity) (bool, error)

MoreSensitivelyRecentThan checks whether a given version is more recent than another one, accepting a VersionSensitivity argument

If the VersionScheme is "random", then it will return true if a != b.

type VersionScheme

type VersionScheme string

VersionScheme informs us on how to compare two versions

const (
	// Semver [Semantic versioning](https://semver.org/), default
	Semver VersionScheme = "semver"
	// Alpha Alphanumeric, will use standard string sorting
	Alpha VersionScheme = "alpha"
	// Random when releases do not support sorting (e.g. hashes)
	Random VersionScheme = "random"
)

type VersionSensitivity

type VersionSensitivity string

VersionSensitivity informs us on how to compare whether a version is more recent than another, for example to only notify on new major versions Only applicable to Semver versioning

const (
	// Patch version, e.g. 1.1.1 -> 1.1.2, default
	Patch VersionSensitivity = "patch"
	// Minor version, e.g. 1.1.1 -> 1.2.0
	Minor VersionSensitivity = "minor"
	// Major version, e.g. 1.1.1 -> 2.0.0
	Major VersionSensitivity = "major"
)

type VersionUpdate

type VersionUpdate struct {
	Name       string `yaml:"name" json:"name"`
	Version    string `yaml:"version" json:"version"`
	NewVersion string `yaml:"new_version" json:"new_version"`
}

VersionUpdate represents the schema of the output format The output format is dictated by exportOptions.outputFormat

type VersionUpdateInfo added in v0.5.0

type VersionUpdateInfo struct {
	Name            string
	Current         Version
	Latest          Version
	UpdateAvailable bool
}

Jump to

Keyboard shortcuts

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