"Fossies" - the Fresh Open Source Software Archive

Member "etcd-3.4.13/version/version.go" (24 Aug 2020, 1512 Bytes) of package /linux/misc/etcd-3.4.13.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "version.go": 3.4.12_vs_3.4.13.

    1 // Copyright 2015 The etcd Authors
    2 //
    3 // Licensed under the Apache License, Version 2.0 (the "License");
    4 // you may not use this file except in compliance with the License.
    5 // You may obtain a copy of the License at
    6 //
    7 //     http://www.apache.org/licenses/LICENSE-2.0
    8 //
    9 // Unless required by applicable law or agreed to in writing, software
   10 // distributed under the License is distributed on an "AS IS" BASIS,
   11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12 // See the License for the specific language governing permissions and
   13 // limitations under the License.
   14 
   15 // Package version implements etcd version parsing and contains latest version
   16 // information.
   17 package version
   18 
   19 import (
   20     "fmt"
   21     "strings"
   22 
   23     "github.com/coreos/go-semver/semver"
   24 )
   25 
   26 var (
   27     // MinClusterVersion is the min cluster version this etcd binary is compatible with.
   28     MinClusterVersion = "3.0.0"
   29     Version           = "3.4.13"
   30     APIVersion        = "unknown"
   31 
   32     // Git SHA Value will be set during build
   33     GitSHA = "Not provided (use ./build instead of go build)"
   34 )
   35 
   36 func init() {
   37     ver, err := semver.NewVersion(Version)
   38     if err == nil {
   39         APIVersion = fmt.Sprintf("%d.%d", ver.Major, ver.Minor)
   40     }
   41 }
   42 
   43 type Versions struct {
   44     Server  string `json:"etcdserver"`
   45     Cluster string `json:"etcdcluster"`
   46     // TODO: raft state machine version
   47 }
   48 
   49 // Cluster only keeps the major.minor.
   50 func Cluster(v string) string {
   51     vs := strings.Split(v, ".")
   52     if len(vs) <= 2 {
   53         return v
   54     }
   55     return fmt.Sprintf("%s.%s", vs[0], vs[1])
   56 }