mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
- Changed the archive name template in .goreleaser.yaml for better clarity. - Added a new section in README files to document the UI installation process for versions v4.0.0 and above. - Removed the old release workflow file and updated the releaser.yaml to include artifact synchronization to OSS. - Introduced a new script (downloadKubekey.sh) for downloading binaries with UI support. Signed-off-by: redscholar <blacktiledhouse@gmail.com>
72 lines
2.3 KiB
Go
72 lines
2.3 KiB
Go
/*
|
|
Copyright 2020 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
// Package version implements version handling code.
|
|
package version
|
|
|
|
import (
|
|
_ "embed"
|
|
"encoding/json"
|
|
"fmt"
|
|
"runtime"
|
|
)
|
|
|
|
var (
|
|
gitMajor string // major version, always numeric
|
|
gitMinor string // minor version, numeric possibly followed by "+"
|
|
gitVersion string // semantic version, derived by build scripts
|
|
gitCommit string // sha1 from git, output of $(git rev-parse HEAD)
|
|
gitTreeState string // state of git tree, either "clean" or "dirty"
|
|
buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
)
|
|
|
|
// Info exposes information about the version used for the current running code.
|
|
type Info struct {
|
|
Major string `json:"major,omitempty"`
|
|
Minor string `json:"minor,omitempty"`
|
|
GitVersion string `json:"gitVersion,omitempty"`
|
|
GitCommit string `json:"gitCommit,omitempty"`
|
|
GitTreeState string `json:"gitTreeState,omitempty"`
|
|
BuildDate string `json:"buildDate,omitempty"`
|
|
GoVersion string `json:"goVersion,omitempty"`
|
|
Compiler string `json:"compiler,omitempty"`
|
|
Platform string `json:"platform,omitempty"`
|
|
}
|
|
|
|
// Get returns an Info object with all the information about the current running code.
|
|
func Get() Info {
|
|
return Info{
|
|
Major: gitMajor,
|
|
Minor: gitMinor,
|
|
GitVersion: gitVersion,
|
|
GitCommit: gitCommit,
|
|
GitTreeState: gitTreeState,
|
|
BuildDate: buildDate,
|
|
GoVersion: runtime.Version(),
|
|
Compiler: runtime.Compiler,
|
|
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
|
|
}
|
|
}
|
|
|
|
// String returns info as a human-friendly version string.
|
|
func (info Info) String() string {
|
|
b, err := json.Marshal(info)
|
|
if err != nil {
|
|
return fmt.Sprintf("error: %v", err)
|
|
}
|
|
return string(b)
|
|
}
|