2017-08-02 17:27:17 +00:00
|
|
|
/*
|
2021-07-06 20:14:46 +00:00
|
|
|
Copyright the Velero contributors.
|
2017-08-02 17:27:17 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2019-01-25 03:33:07 +00:00
|
|
|
// Package buildinfo holds build-time information like the velero version.
|
2017-08-02 17:27:17 +00:00
|
|
|
// This is a separate package so that other packages can import it without
|
|
|
|
// worrying about introducing circular dependencies.
|
|
|
|
package buildinfo
|
|
|
|
|
2017-09-18 22:30:12 +00:00
|
|
|
import "fmt"
|
|
|
|
|
2017-09-13 14:16:16 +00:00
|
|
|
var (
|
2019-01-25 03:33:07 +00:00
|
|
|
// Version is the current version of Velero, set by the go linker's -X flag at build time.
|
2017-09-13 14:16:16 +00:00
|
|
|
Version string
|
2017-08-02 17:27:17 +00:00
|
|
|
|
2017-09-13 14:16:16 +00:00
|
|
|
// GitSHA is the actual commit that is being built, set by the go linker's -X flag at build time.
|
|
|
|
GitSHA string
|
|
|
|
|
|
|
|
// GitTreeState indicates if the git tree is clean or dirty, set by the go linker's -X flag at build
|
|
|
|
// time.
|
|
|
|
GitTreeState string
|
2021-07-06 20:14:46 +00:00
|
|
|
|
|
|
|
// ImageRegistry is the image registry that this build of Velero should use by default to pull the
|
2022-10-12 11:12:40 +00:00
|
|
|
// Velero and Restore Helper images from.
|
2021-07-06 20:14:46 +00:00
|
|
|
ImageRegistry string
|
2017-09-13 14:16:16 +00:00
|
|
|
)
|
2017-09-18 22:30:12 +00:00
|
|
|
|
|
|
|
// FormattedGitSHA renders the Git SHA with an indicator of the tree state.
|
|
|
|
func FormattedGitSHA() string {
|
|
|
|
if GitTreeState != "clean" {
|
|
|
|
return fmt.Sprintf("%s-%s", GitSHA, GitTreeState)
|
|
|
|
}
|
|
|
|
return GitSHA
|
|
|
|
}
|