From 06dfa115305bb59973f6e55561d91de594152a02 Mon Sep 17 00:00:00 2001 From: Lorenzo Fontana Date: Tue, 15 Jan 2019 11:17:50 +0100 Subject: [PATCH] fix(pkg/version): default image version as go constant Signed-off-by: Lorenzo Fontana --- pkg/version/version.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/version/version.go b/pkg/version/version.go index 7d69e3b5..3a0d3ff5 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -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 { @@ -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 {