mirror of
https://github.com/datarhei/core.git
synced 2025-10-04 23:53:12 +08:00

The core API will be started before the cluster is started in order to access the cluster endpoints during a cluster upgrade. If TLS is enabled, possibly stale certificates are loaded into the cache. Otherwise the leader has to be contacted via the cluster API which might have changed.
44 lines
685 B
Go
44 lines
685 B
Go
package cluster
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Masterminds/semver/v3"
|
|
)
|
|
|
|
type ClusterVersion struct {
|
|
Major uint64
|
|
Minor uint64
|
|
Patch uint64
|
|
}
|
|
|
|
func (v ClusterVersion) String() string {
|
|
return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch)
|
|
}
|
|
|
|
func (v ClusterVersion) Equal(x ClusterVersion) bool {
|
|
return v.String() == x.String()
|
|
}
|
|
|
|
func ParseClusterVersion(version string) (ClusterVersion, error) {
|
|
v := ClusterVersion{}
|
|
|
|
sv, err := semver.NewVersion(version)
|
|
if err != nil {
|
|
return v, err
|
|
}
|
|
|
|
v.Major = sv.Major()
|
|
v.Minor = sv.Minor()
|
|
v.Patch = sv.Patch()
|
|
|
|
return v, nil
|
|
}
|
|
|
|
// Version of the cluster
|
|
var Version = ClusterVersion{
|
|
Major: 1,
|
|
Minor: 0,
|
|
Patch: 2,
|
|
}
|