Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pkg/version): default image version as go constant #38

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var imageName string
var buildTime string
var versionFormat = "git commit: %s\nbuild date: %s"
var imageNameTagFormat = "%s:%s"
var defaultImageName = "quay.io/fntlnz/kubectl-trace-bpftrace"
var defaultImageTag = "latest"

// ImageName returns the container image name defined in Makefile
func ImageName() string {
Expand All @@ -23,11 +25,15 @@ func GitCommit() string {
}

func ImageNameTag() string {
commit := GitCommit()
if len(commit) == 0 {
return fmt.Sprintf(imageNameTagFormat, ImageName(), "latest")
imageName := ImageName()
tag := GitCommit()
if len(tag) == 0 {
tag = defaultImageTag
}
return fmt.Sprintf(imageNameTagFormat, ImageName(), GitCommit())
if len(imageName) == 0 {
imageName = defaultImageName
}
return fmt.Sprintf(imageNameTagFormat, imageName, tag)
}

func Time() *time.Time {
Expand Down