github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/steampipeconfig/versionmap/resolved_version_constraint.go (about) 1 package versionmap 2 3 import ( 4 "github.com/Masterminds/semver/v3" 5 "github.com/turbot/steampipe/pkg/steampipeconfig/modconfig" 6 ) 7 8 type ResolvedVersionConstraint struct { 9 Name string `json:"name,omitempty"` 10 Alias string `json:"alias,omitempty"` 11 Version *semver.Version `json:"version,omitempty"` 12 Constraint string `json:"constraint,omitempty"` 13 StructVersion int `json:"struct_version,omitempty"` 14 } 15 16 func NewResolvedVersionConstraint(name, alias string, version *semver.Version, constraintString string) *ResolvedVersionConstraint { 17 return &ResolvedVersionConstraint{ 18 Name: name, 19 Alias: alias, 20 Version: version, 21 Constraint: constraintString, 22 StructVersion: WorkspaceLockStructVersion, 23 } 24 } 25 26 func (c ResolvedVersionConstraint) Equals(other *ResolvedVersionConstraint) bool { 27 return c.Name == other.Name && 28 c.Version.Equal(other.Version) && 29 c.Constraint == other.Constraint 30 } 31 32 func (c ResolvedVersionConstraint) IsPrerelease() bool { 33 return c.Version.Prerelease() != "" || c.Version.Metadata() != "" 34 } 35 36 func (c ResolvedVersionConstraint) DependencyPath() string { 37 return modconfig.BuildModDependencyPath(c.Name, c.Version) 38 }