From f7314fa6fe383c121fcf9984945113eeca6d81ef Mon Sep 17 00:00:00 2001 From: Zeeshan Qureshi Date: Thu, 29 Oct 2020 18:11:22 -0400 Subject: [PATCH] feat: Split docker image config into name and tag This will allow us to override the tag during release without copyping over the name and risk divergence. --- Makefile | 2 +- integration/suite_test.go | 2 +- pkg/cmd/run.go | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index da353c67..150568bb 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ IMAGE_BUILD_FLAGS ?= "--no-cache" BPFTRACEVERSION ?= "v0.11.1" -LDFLAGS := -ldflags '-X github.com/iovisor/kubectl-trace/pkg/version.buildTime=$(shell date +%s) -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageNameTag=${IMAGE_TRACERUNNER_COMMIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageNameTag=${IMAGE_INITCONTAINER_COMMIT}' +LDFLAGS := -ldflags '-X github.com/iovisor/kubectl-trace/pkg/version.buildTime=$(shell date +%s) -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageName=${IMAGE_NAME} -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageTag=${GIT_COMMIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageName=${IMAGE_NAME_INIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageTag=${GIT_COMMIT}' TESTPACKAGES := $(shell go list ./... | grep -v github.com/iovisor/kubectl-trace/integration) kubectl_trace ?= _output/bin/kubectl-trace diff --git a/integration/suite_test.go b/integration/suite_test.go index 563d04a7..3dc05b00 100644 --- a/integration/suite_test.go +++ b/integration/suite_test.go @@ -68,7 +68,7 @@ func (k *KubectlTraceSuite) SetUpSuite(c *check.C) { defer os.RemoveAll(dir) imageTarPath := filepath.Join(dir, "image.tar") - err = save(cmd.ImageNameTag, imageTarPath) + err = save(cmd.ImageName+":"+cmd.ImageTag, imageTarPath) c.Assert(err, check.IsNil) // Copy the bpftrace image to the nodes diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index 69811909..6c0a7414 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -21,10 +21,14 @@ import ( ) var ( - // ImageNameTag represents the default tracerunner image - ImageNameTag = "quay.io/iovisor/kubectl-trace-bpftrace:latest" - // InitImageNameTag represents the default init container image - InitImageNameTag = "quay.io/iovisor/kubectl-trace-init:latest" + // ImageName represents the default tracerunner image + ImageName = "quay.io/iovisor/kubectl-trace-bpftrace" + // ImageTag represents the tag to fetch for ImageName + ImageTag = "latest" + // InitImageName represents the default init container image + InitImageName = "quay.io/iovisor/kubectl-trace-init" + // InitImageTag represents the tag to fetch for InitImage + InitImageTag = "latest" // DefaultDeadline is the maximum time a tracejob is allowed to run, in seconds DefaultDeadline = 3600 // DefaultDeadlineGracePeriod is the maximum time to wait to print a map or histogram, in seconds @@ -96,8 +100,8 @@ func NewRunOptions(streams genericclioptions.IOStreams) *RunOptions { IOStreams: streams, serviceAccount: "default", - imageName: ImageNameTag, - initImageName: InitImageNameTag, + imageName: ImageName + ":" + ImageTag, + initImageName: InitImageName + ":" + InitImageTag, deadline: int64(DefaultDeadline), deadlineGracePeriod: int64(DefaultDeadlineGracePeriod), }