From 91dfeb7577aec475944cc29427015ed99e8b9eee Mon Sep 17 00:00:00 2001
From: Roberto Rojas <robertojrojas@gmail.com>
Date: Sat, 12 Oct 2019 18:53:17 -0400
Subject: [PATCH] passes KUBEBENCH_VERSION down to Dockerfile (#428)

---
 Dockerfile | 3 ++-
 makefile   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 75a590e..ec97b09 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,8 @@ ADD go.mod go.sum ./
 ADD main.go .
 ADD check/ check/
 ADD cmd/ cmd/
-RUN GO111MODULE=on CGO_ENABLED=0 go install -a -ldflags '-w'
+ARG KUBEBENCH_VERSION
+RUN GO111MODULE=on CGO_ENABLED=0 go install -a -ldflags "-X github.com/aquasecurity/kube-bench/cmd.KubeBenchVersion=${KUBEBENCH_VERSION} -w"
 
 FROM alpine:3.10 AS run
 WORKDIR /opt/kube-bench/
diff --git a/makefile b/makefile
index 8e76483..be69542 100644
--- a/makefile
+++ b/makefile
@@ -4,7 +4,7 @@ DOCKER_REGISTRY ?= aquasec
 VERSION ?= $(shell git rev-parse --short=7 HEAD)
 KUBEBENCH_VERSION ?= $(shell git describe --tags --abbrev=0)
 IMAGE_NAME ?= $(DOCKER_REGISTRY)/$(BINARY):$(VERSION)
-TARGET_OS := linux
+TARGET_OS ?= linux
 BUILD_OS := linux
 uname := $(shell uname -s)
 
@@ -29,6 +29,7 @@ $(BINARY): $(SOURCES)
 build-docker:
 	docker build --build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
              --build-arg VCS_REF=$(shell git rev-parse --short HEAD) \
+			 --build-arg KUBEBENCH_VERSION=$(KUBEBENCH_VERSION) \
              -t $(IMAGE_NAME) .
 
 tests:
-- 
GitLab