version

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersionRequirement

func CheckVersionRequirement(currentVersion, minVersion string) error

CheckVersionRequirement checks if the current version meets the minimum requirement. Returns nil if the requirement is met, or a VersionError if not. If currentVersion is empty (unknown), returns nil for graceful degradation.

func CompareVersions

func CompareVersions(current, other Version) int

CompareVersions compares two versions and returns:

  • 1 if current > other
  • 0 if current == other
  • -1 if current < other

func IsVersionSupported

func IsVersionSupported(currentVersion, minVersion string) bool

IsVersionSupported checks if the current version meets the minimum version requirement. Returns true if current >= minimum, false otherwise. If either version string is empty or invalid, returns true for graceful degradation.

Types

type Version

type Version struct {
	Major int
	Minor int
	Patch int
	// Original stores the original version string (e.g., "16.7.0-ee")
	Original string
}

Version represents a semantic version with major, minor, and patch components.

func ParseVersion

func ParseVersion(versionStr string) (Version, error)

ParseVersion extracts semantic version from GitLab version strings. Examples:

  • "16.7.0-ee" -> Version{16, 7, 0, "16.7.0-ee"}
  • "15.11.3-ce" -> Version{15, 11, 3, "15.11.3-ce"}
  • "17.0.0" -> Version{17, 0, 0, "17.0.0"}
  • "v16.7.0" -> Version{16, 7, 0, "v16.7.0"}

Returns an error if the version string is malformed or empty.

func (Version) String

func (v Version) String() string

String returns the string representation of the version.

type VersionError

type VersionError struct {
	// CurrentVersion is the detected GitLab version
	CurrentVersion string
	// RequiredVersion is the minimum required GitLab version
	RequiredVersion string
	// Feature is the feature or command that requires the minimum version
	Feature string
	// Host is the GitLab host
	Host string
	// Message is a descriptive error message
	Message string
}

VersionError represents a version compatibility error.

func NewVersionError

func NewVersionError(currentVersion, requiredVersion, feature, host string) *VersionError

NewVersionError creates a new VersionError with the given details.

func (*VersionError) Error

func (e *VersionError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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