Documentation
¶
Overview ¶
ds contains data structure implementations that can be reused across other modules.
Index ¶
- func SetToString[T ~string](s Set[T]) string
- type PgEdgeVersion
- func (v *PgEdgeVersion) Clone() *PgEdgeVersion
- func (v *PgEdgeVersion) Compare(other *PgEdgeVersion) int
- func (v *PgEdgeVersion) Equals(other *PgEdgeVersion) bool
- func (v *PgEdgeVersion) GreaterThan(other *PgEdgeVersion) bool
- func (v *PgEdgeVersion) LessThan(other *PgEdgeVersion) bool
- func (v *PgEdgeVersion) Normalize() (*PgEdgeVersion, error)
- func (v *PgEdgeVersion) String() string
- type Set
- func (s Set[T]) Add(elements ...T)
- func (s Set[T]) Difference(o Set[T]) Set[T]
- func (s Set[T]) Empty() bool
- func (s Set[T]) Equal(o Set[T]) bool
- func (s Set[T]) Has(element T) bool
- func (s Set[T]) Intersection(o Set[T]) Set[T]
- func (s Set[T]) Remove(element T)
- func (s Set[T]) Size() int
- func (s Set[T]) SymmetricDifference(o Set[T]) Set[T]
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) ToSortedSlice(cmp func(a T, b T) int) []T
- func (s Set[T]) Union(o Set[T]) Set[T]
- type Stability
- type Version
- func (v *Version) Clone() *Version
- func (v *Version) Compare(other *Version) int
- func (v *Version) Major() (uint64, bool)
- func (v *Version) MajorMinorVersion() *Version
- func (v *Version) MajorString() (string, bool)
- func (v *Version) MajorVersion() *Version
- func (v *Version) MarshalText() (data []byte, err error)
- func (v *Version) String() string
- func (v *Version) UnmarshalJSON(data []byte) error
- func (v *Version) UnmarshalText(data []byte) error
- type VersionConstraint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetToString ¶ added in v0.9.0
SetToString is a shortcut for producing a sorted, comma-separated string representation of a Set of string-ish values.
Types ¶
type PgEdgeVersion ¶ added in v0.8.0
type PgEdgeVersion struct {
PostgresVersion *Version `json:"postgres_version"`
SpockVersion *Version `json:"spock_version"`
// Stability is the release stability of the manifest image backing this
// version. Empty when the host does not report one (eg. the systemd
// orchestrator); treat empty as stable.
Stability Stability `json:"stability,omitempty"`
}
func MustParsePgEdgeVersion ¶ added in v0.9.0
func MustParsePgEdgeVersion(postgresVersion, spockVersion string) *PgEdgeVersion
func ParsePgEdgeVersion ¶ added in v0.9.0
func ParsePgEdgeVersion(postgresVersion, spockVersion string) (*PgEdgeVersion, error)
func (*PgEdgeVersion) Clone ¶ added in v0.8.0
func (v *PgEdgeVersion) Clone() *PgEdgeVersion
func (*PgEdgeVersion) Compare ¶ added in v0.8.0
func (v *PgEdgeVersion) Compare(other *PgEdgeVersion) int
func (*PgEdgeVersion) Equals ¶ added in v0.8.0
func (v *PgEdgeVersion) Equals(other *PgEdgeVersion) bool
func (*PgEdgeVersion) GreaterThan ¶ added in v0.8.0
func (v *PgEdgeVersion) GreaterThan(other *PgEdgeVersion) bool
func (*PgEdgeVersion) LessThan ¶ added in v0.8.0
func (v *PgEdgeVersion) LessThan(other *PgEdgeVersion) bool
func (*PgEdgeVersion) Normalize ¶ added in v0.9.0
func (v *PgEdgeVersion) Normalize() (*PgEdgeVersion, error)
Normalize returns the Postgres version in major.minor format and the Spock version in major format. This matches the way that versions are currently provided in our API.
func (*PgEdgeVersion) String ¶ added in v0.8.0
func (v *PgEdgeVersion) String() string
type Set ¶
type Set[T comparable] map[T]bool
Set is a generic set type.
func NewSet ¶
func NewSet[T comparable](elements ...T) Set[T]
func SetDifference ¶
func SetDifference[T comparable](a, b []T) Set[T]
SetDifference (a-b) returns the set of elements that are in a, but not b.
func SetSymmetricDifference ¶ added in v0.7.0
func SetSymmetricDifference[T comparable](a, b []T) Set[T]
SetSymmetricDifference (a-b)∪(b-a) returns the set of elements that are in either a or b, but not both.
func (Set[T]) Difference ¶
Difference (s-o) returns elements that are in the receiver set, but not the given set 'o'.
func (Set[T]) Intersection ¶
Intersection (s∩o) returns elements that are in both sets.
func (Set[T]) SymmetricDifference ¶
SymmetricDifference (s-o)∪(o-s) returns elements that are in the receiver set, but not the given set 'o', along with those that are in 'o', but not the receiver set.
func (Set[T]) ToSlice ¶
func (s Set[T]) ToSlice() []T
ToSlice returns a slice of all the elements in the set.
func (Set[T]) ToSortedSlice ¶
ToSortedSlice returns a sorted slice of all the elements in the set.
type Stability ¶
type Stability string
Stability indicates the release stability of a manifest image entry.
From least to most mature:
- StabilityDev: a mutable channel tag. Its contents can change under a running deployment and its declared postgres_version can drift from what the tag resolves to.
- StabilityBeta: a feature-complete pre-release, immutable build. Defined for completeness.
- StabilityRC: a release candidate, immutable build believed to be GA-quality.
- StabilityStable: generally available.
- StabilityDeprecated: still resolvable and still supported for existing databases, but should not be chosen for a new database.
func (Stability) AllowedAsDefault ¶
AllowedAsDefault reports whether an entry with this stability may be the manifest default (the image chosen when a create request omits the version). Only stable entries qualify.
func (Stability) AllowedAsUpgradeTarget ¶
AllowedAsUpgradeTarget reports whether an operator may apply an image upgrade to an entry with this stability when they name it explicitly. Stable and rc qualify (an rc is the exact bits intended for GA), as does deprecated (so a database can be moved along a sunset line). Dev and beta do not.
func (Stability) Normalized ¶
func (Stability) OfferedForUpgrade ¶
OfferedForUpgrade reports whether an entry with this stability is surfaced in a database's available_upgrades list. Only stable entries are.
type Version ¶ added in v0.8.0
type Version struct {
Components []uint64 `json:"components"`
// PreRelease is the optional suffix after a "-" (e.g. "beta.1" in
// "6.0.0-beta.1"). It is an opaque string, not decomposed into SemVer
// precedence rules, and is intentionally dropped by MajorVersion and
// MajorMinorVersion since a major/major-minor bucket never carries one.
PreRelease string `json:"pre_release,omitempty"`
}
func MustParseVersion ¶ added in v0.8.0
func ParseImageTag ¶
ParseImageTag extracts the Postgres and Spock versions from an image reference following the pgEdge tag format. Returns ok=false if the tag does not match the expected format (e.g. a dev build tag like "my-build"). Digest suffixes (e.g. @sha256:…) are stripped before parsing.
func ParseVersion ¶ added in v0.8.0
func (*Version) Compare ¶ added in v0.8.0
Compare orders by numeric components first. If those are equal, a pre-release never compares equal to its release counterpart (a release sorts after any pre-release of the same numeric version), and two different pre-releases of the same numeric version fall back to a plain string comparison. This is NOT full SemVer pre-release precedence — it's just enough to avoid falsely claiming two different versions are equal.
func (*Version) MajorMinorVersion ¶ added in v0.9.0
MajorMinorVersion returns the major.minor components. PreRelease is intentionally dropped: a major.minor bucket never carries a pre-release suffix.
func (*Version) MajorString ¶ added in v0.8.0
func (*Version) MajorVersion ¶ added in v0.8.0
MajorVersion returns just the major component. PreRelease is intentionally dropped: a major-version bucket never carries a pre-release suffix.
func (*Version) MarshalText ¶ added in v0.8.0
func (*Version) UnmarshalJSON ¶ added in v0.8.0
func (*Version) UnmarshalText ¶ added in v0.8.0
type VersionConstraint ¶ added in v0.8.0
type VersionConstraint struct {
Min *Version `json:"min,omitempty"`
Max *Version `json:"max,omitempty"`
}
VersionConstraint defines an optional minimum and/or maximum version bound. A nil Min or Max means no restriction on that end of the range.
func (*VersionConstraint) IsSatisfied ¶ added in v0.8.0
func (c *VersionConstraint) IsSatisfied(v *Version) bool
IsSatisfied returns true if v falls within the constraint's bounds.
func (*VersionConstraint) String ¶ added in v0.8.0
func (c *VersionConstraint) String() string