github.com/azure-devops-engineer/helm@v3.0.0-alpha.2+incompatible/internal/version/version.go (about)

     1  /*
     2  Copyright The Helm Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package version // import "helm.sh/helm/internal/version"
    18  
    19  import (
    20  	"flag"
    21  	"runtime"
    22  
    23  	hversion "helm.sh/helm/pkg/version"
    24  )
    25  
    26  var (
    27  	// version is the current version of the Helm.
    28  	// Update this whenever making a new release.
    29  	// The version is of the format Major.Minor.Patch[-Prerelease][+BuildMetadata]
    30  	//
    31  	// Increment major number for new feature additions and behavioral changes.
    32  	// Increment minor number for bug fixes and performance enhancements.
    33  	// Increment patch number for critical fixes to existing releases.
    34  	version = "v3.0"
    35  
    36  	// metadata is extra build time data
    37  	metadata = "unreleased"
    38  	// gitCommit is the git sha1
    39  	gitCommit = ""
    40  	// gitTreeState is the state of the git tree
    41  	gitTreeState = ""
    42  )
    43  
    44  // GetVersion returns the semver string of the version
    45  func GetVersion() string {
    46  	if metadata == "" {
    47  		return version
    48  	}
    49  	return version + "+" + metadata
    50  }
    51  
    52  // Get returns build info
    53  func Get() hversion.BuildInfo {
    54  	v := hversion.BuildInfo{
    55  		Version:      GetVersion(),
    56  		GitCommit:    gitCommit,
    57  		GitTreeState: gitTreeState,
    58  		GoVersion:    runtime.Version(),
    59  	}
    60  
    61  	// HACK(bacongobbler): strip out GoVersion during a test run for consistent test output
    62  	if flag.Lookup("test.v") != nil {
    63  		v.GoVersion = ""
    64  	}
    65  	return v
    66  }