Skip to content

Commit

Permalink
fix(pkg/version): default image version as go constant
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Fontana <[email protected]>
  • Loading branch information
fntlnz committed Jan 15, 2019
1 parent a5b3d5d commit 06dfa11
Showing 1 changed file with 10 additions and 4 deletions.
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

0 comments on commit 06dfa11

Please sign in to comment.