dependency

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package dependencies checks dependencies, locally or remotely

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AWSEC2Client ec2iface.EC2API
}

Client holds any client that is needed

func NewClient

func NewClient() *Client

NewClient returns all clients that can be used to the validation

func (*Client) LocalCheck

func (c *Client) 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 (*Client) RemoteCheck

func (c *Client) RemoteCheck(dependencyFilePath string) ([]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.

func (*Client) RemoteExport

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

func (*Client) Upgrade added in v0.3.3

func (c *Client) Upgrade(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.

type Dependencies

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

Dependencies is used to deserialise the configuration file

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 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 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

Jump to

Keyboard shortcuts

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