common

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeNone   = ""
	ContentTypeBinary = "application/octet-stream"
	ContentTypeForm   = "application/x-www-form-urlencoded"
	ContentTypeJSON   = "application/json"
	ContentTypeHTML   = "text/html; charset=utf-8"
	ContentTypeText   = "text/plain; charset=utf-8"
)

Variables

View Source
var Execute execute = execute{}
View Source
var FalsePtr *bool = &[]bool{false}[0]
View Source
var Git git = git{}
View Source
var HttpUtil httpUtil

exported global variable

View Source
var TruePtr *bool = &[]bool{true}[0]

Functions

func Base64ToHex

func Base64ToHex(base64String string) (string, error)

func DecodeBase64

func DecodeBase64(base64String string) ([]byte, error)

func EncodeToHex

func EncodeToHex(bytes []byte) string

func FileExists

func FileExists(filePath string) (bool, error)

func FilePathMatchesPattern

func FilePathMatchesPattern(filePath string, patterns ...string) (bool, error)

Checks if the given filePath matches at least one of the given patterns.

func FindAllNamedMatchesWithIndex

func FindAllNamedMatchesWithIndex(regex *regexp.Regexp, str string, includeNotMatchedOptional bool, n int) []map[string][]*CapturedGroup

Find all named matches in the given string, returning an list of objects with start/end-index and the value for each named match

func FindNamedMatchesWithIndex

func FindNamedMatchesWithIndex(regex *regexp.Regexp, str string, includeNotMatchedOptional bool) map[string][]*CapturedGroup

func NormalizeString

func NormalizeString(value string, maxLength int) string

func ReplaceMatchesInRegex

func ReplaceMatchesInRegex(regex *regexp.Regexp, str string, replacementMap map[string]string) (string, int)

Replaces the given replacements from the map inside the passed string.

func SearchFiles

func SearchFiles(rootPath string, matchPaths []string, ignorePatterns []string) ([]string, error)

Types

type CapturedGroup

type CapturedGroup struct {
	StartIndex int
	EndIndex   int
	Key        string
	Value      string
}

func (*CapturedGroup) String

func (cg *CapturedGroup) String() string

type DatasourceSettings

type DatasourceSettings struct {
	// The logger to use for the datasource.
	Logger *slog.Logger
	// Host rules that might apply when using this datasource.
	HostRules []*HostRule
}

type DatasourceType

type DatasourceType string
const (
	DATASOURCE_TYPE_ANTVERSION      DatasourceType = "ant-version"
	DATASOURCE_TYPE_ARTIFACTORY     DatasourceType = "artifactory"
	DATASOURCE_TYPE_BROWSERVERSION  DatasourceType = "browser-version"
	DATASOURCE_TYPE_DOCKER          DatasourceType = "docker"
	DATASOURCE_TYPE_GITHUB_RELEASES DatasourceType = "github-releases"
	DATASOURCE_TYPE_GITHUB_TAGS     DatasourceType = "github-tags"
	DATASOURCE_TYPE_GITLAB_PACKAGES DatasourceType = "gitlab-packages"
	DATASOURCE_TYPE_GOMOD           DatasourceType = "go-mod"
	DATASOURCE_TYPE_GOVERSION       DatasourceType = "go-version"
	DATASOURCE_TYPE_GRADLEVERSION   DatasourceType = "gradle-version"
	DATASOURCE_TYPE_JAVAVERSION     DatasourceType = "java-version"
	DATASOURCE_TYPE_MAVEN           DatasourceType = "maven"
	DATASOURCE_TYPE_NODEJS          DatasourceType = "nodejs"
	DATASOURCE_TYPE_NPM             DatasourceType = "npm"
)

type Dependency

type Dependency struct {
	// The name of the dependency.
	Name string
	// The current version of the dependency (unprocessed).
	Version string
	// An optional digest either in addition to the version or instead a version.
	Digest string
	// The type of the dependency. Used to allow different handlings per type in the manager. Optional.
	Type string
	// The datasource of the dependency.
	Datasource DatasourceType
	// A map that contains additional data about the dependency (for example a digest).
	AdditionalData map[string]string
	// The filepath from where this dependency was found.
	FilePath string

	// Defines how much the dependency is allowed to update. Can be "major", "minor", or "patch".
	MaxUpdateType UpdateType
	// This flag defines if unstable releases are allowed. Unstable usually means a version that also has parts with text.
	AllowUnstable *bool
	// A list of registry urls to use. Allows overwriting the default. Depends on the datasource.
	RegistryUrls []string
	// Defines the regexp to use to parse the version into separate parts. See https://github.com/Roemer/gover for more details.
	Versioning string
	// An optional regexp that is used to separate the version part from the rest of the raw version string.
	ExtractVersion string
	// A flag to indicate if versions from a remote that do not match the versioning should be ignored or give an exception.
	IgnoreNonMatching *bool
	// A flag that allows disabling individual dependencies.
	Skip *bool
	// An optional text to describe, why a dependency was disabled.
	SkipReason string
	// Flag to indicate if the version check should be skipped (eg. for versions like latest or jdk8 where there is still a digest)
	SkipVersionCheck *bool

	// Allows defining regexes that replace further information from dependencies (like hash) after updating.
	PostUpgradeReplacements []string
	// An optional name of a group to group dependency updates together.
	GroupName string

	// Contains the information about the new release if any is found.
	NewRelease *ReleaseInfo

	// Contains information about the manager from which this dependency was found from. Is "nil" if the dependency is not from a manager.
	ManagerInfo *ManagerInfo
}

This type represents a concrete dependency.

func (*Dependency) HasDigest

func (d *Dependency) HasDigest() bool

func (*Dependency) String

func (d *Dependency) String() string

type DevcontainerManagerFeatureDependency

type DevcontainerManagerFeatureDependency struct {
	Property       string
	Datasource     DatasourceType
	DependencyName string
}

type DevcontainerManagerSettings

type DevcontainerManagerSettings struct {
	FeatureDependencies map[string][]*DevcontainerManagerFeatureDependency
}

Settings relevant for the devcontainer manager.

type HostRule

type HostRule struct {
	// The host that needs to match in order to use this rule.
	MatchHost string `json:"matchHost" yaml:"matchHost"`
	// The username to authenticate with the host.
	Username string `json:"username" yaml:"username"`
	// The password to authenticate with the host.
	Password string `json:"password" yaml:"password"`
	// A token to authenticate with the host.
	Token string `json:"token" yaml:"token"`
}

A host rule that is applied when using a certain host.

func (*HostRule) PasswordExpanded

func (hr *HostRule) PasswordExpanded() string

Expands the password with environment variables.

func (*HostRule) TokendExpanded

func (hr *HostRule) TokendExpanded() string

Expands the token with environment variables.

func (*HostRule) UsernameExpanded

func (hr *HostRule) UsernameExpanded() string

Expands the username with environment variables.

type IDatasource

type IDatasource interface {
	// Gets all possible releases for the dependency.
	GetReleases(dependency *Dependency) ([]*ReleaseInfo, error)
	// Gets the digest for the dependency.
	GetDigest(dependency *Dependency, releaseVersion string) (string, error)
	// Gets additional data for the dependency and the new release.
	GetAdditionalData(dependency *Dependency, newRelease *ReleaseInfo, dataType string) (string, error)
	// Handles the dependency update searching.
	SearchDependencyUpdate(dependency *Dependency) (*ReleaseInfo, error)
}

This is the interface that needs to be implemented by all datasources.

type IEngine

type IEngine interface {
	// Gets the logger for the engine.
	Logger() *slog.Logger
	// Gets the desired manager.
	GetManager(managerSettings *ManagerSettings) (IManager, error)
	// Resolves match-strings with presets.
	ResolveMatchString(matchString string) (string, error)
	// Resolves versioning-strings with presets.
	ResolveVersioning(versioning string) (string, error)
}

This is the interface for the gonovate engine.

type IManager

type IManager interface {
	// Gets the id of the manager.
	Id() string
	// Gets the type of the manager.
	Type() ManagerType
	// Gets the settings with which the manager was created.
	Settings() *ManagerSettings
	// Extracts all dependencies from the manager.
	ExtractDependencies(filePath string) ([]*Dependency, error)
	// Applies a dependency update with the manager.
	ApplyDependencyUpdate(dependency *Dependency) error
}

This is the interface that needs to be implemented by all managers.

type ManagerInfo

type ManagerInfo struct {
	// The id of the manager from which this dependency was found.
	ManagerId string
	// An object that can contain data which is set/read from the manager to process the dependency.
	ManagerData interface{}
}

Object with information about a manager.

type ManagerSettings

type ManagerSettings struct {
	// The logger to use for the manager.
	Logger *slog.Logger
	// A flag which is set when the manager is disabled.
	Disabled *bool
	// A list of patterns with the files that the manager should process.
	FilePatterns []string
	// Settings for the RegexManager.
	RegexManagerSettings *RegexManagerSettings
	// Settings for the DevcontainerManager.
	DevcontainerManagerSettings *DevcontainerManagerSettings
}

This struct contains settings relevant for managers.

type ManagerType

type ManagerType string
const (
	MANAGER_TYPE_DEVCONTAINER ManagerType = "devcontainer"
	MANAGER_TYPE_DOCKERFILE   ManagerType = "dockerfile"
	MANAGER_TYPE_GOMOD        ManagerType = "go-mod"
	MANAGER_TYPE_INLINE       ManagerType = "inline"
	MANAGER_TYPE_REGEX        ManagerType = "regex"
)

type PlatformSettings

type PlatformSettings struct {
	// The logger to use for the platform.
	Logger *slog.Logger
	// The type of the platform.
	Platform PlatformType
	// The token which is used to interact with the platform. Is expanded from environment variables.
	Token string
	// The endpoint to use when interacting with the platform.
	Endpoint string
	// The author to use when interacting with git.
	GitAuthor string
	// The name of the base branch.
	BaseBranch string
}

func (*PlatformSettings) TokendExpanded

func (ps *PlatformSettings) TokendExpanded() string

type PlatformType

type PlatformType string
const (
	PLATFORM_TYPE_GIT    PlatformType = "git"
	PLATFORM_TYPE_GITHUB PlatformType = "github"
	PLATFORM_TYPE_GITLAB PlatformType = "gitlab"
	PLATFORM_TYPE_NOOP   PlatformType = "noop"
)

type Project

type Project struct {
	Path string
}

func (*Project) SplitPath

func (p *Project) SplitPath() (string, string)

Splits the path into "owner" and "repository"

type RegexManagerSettings

type RegexManagerSettings struct {
	MatchStringPresets map[string]*presets.MatchStringPreset
	MatchStrings       []string
}

Settings relevant for the regex manager.

type ReleaseInfo

type ReleaseInfo struct {
	// The time when the release was created
	ReleaseDate time.Time
	// The original versionstring of the release
	VersionString string
	// The parsed version of the release
	Version *gover.Version
	// The digest of the release
	Digest string
	// Can contain additional data for the release like hashes
	AdditionalData map[string]string
}

This type contains information about a release of a dependency

type UpdateGroup

type UpdateGroup struct {
	Title        string
	BranchName   string
	Dependencies []*Dependency
}

type UpdateType

type UpdateType string
const (
	UPDATE_TYPE_MAJOR UpdateType = "major"
	UPDATE_TYPE_MINOR UpdateType = "minor"
	UPDATE_TYPE_PATCH UpdateType = "patch"
)

Jump to

Keyboard shortcuts

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