From 62af68f3f570612ce1131df2ad71b2dd3161c3b6 Mon Sep 17 00:00:00 2001
From: Roberto Rojas <robertojrojas@gmail.com>
Date: Thu, 12 Dec 2019 16:51:35 -0500
Subject: [PATCH] fixes issue #536 (#540)

---
 .goreleaser.yml | 8 ++++++++
 cmd/root.go     | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/.goreleaser.yml b/.goreleaser.yml
index ecaeccb..f838562 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -1,5 +1,6 @@
 env:
   - GO111MODULE=on
+  - KUBEBENCH_CFG=/etc/kube-bench/cfg
 builds:
   - main: main.go
     binary: kube-bench
@@ -7,14 +8,21 @@ builds:
       - linux
     goarch:
       - amd64
+    ldflags:
+     - "-X github.com/aquasecurity/kube-bench/cmd.KubeBenchVersion={{.Version}}"
+     - "-X github.com/aquasecurity/kube-bench/cmd.cfgDir={{.Env.KUBEBENCH_CFG}}"
 # Archive customization
 archive:
   format: tar.gz
+  files:
+    - "cfg/**/*"
 nfpm:
   vendor: Aqua Security
   description: "The Kubernetes Bench for Security is a Go application that checks whether Kubernetes is deployed according to security best practices"
   license: Apache-2.0
   homepage: https://github.com/aquasecurity/kube-bench
+  files:
+    "cfg/**/*": "/etc/kube-bench/cfg"
   formats:
     - deb
     - rpm
diff --git a/cmd/root.go b/cmd/root.go
index 543269f..6aeafde 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -38,7 +38,7 @@ var (
 	kubeVersion        string
 	benchmarkVersion   string
 	cfgFile            string
-	cfgDir             string
+	cfgDir             = "./cfg/"
 	jsonFmt            bool
 	junitFmt           bool
 	pgSQL              bool
@@ -145,7 +145,7 @@ func init() {
 		`Run all the checks under this comma-delimited list of groups. Example --group="1.1"`,
 	)
 	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./cfg/config.yaml)")
-	RootCmd.PersistentFlags().StringVarP(&cfgDir, "config-dir", "D", "./cfg/", "config directory")
+	RootCmd.PersistentFlags().StringVarP(&cfgDir, "config-dir", "D", cfgDir, "config directory")
 	RootCmd.PersistentFlags().StringVar(&kubeVersion, "version", "", "Manually specify Kubernetes version, automatically detected if unset")
 	RootCmd.PersistentFlags().StringVar(&benchmarkVersion, "benchmark", "", "Manually specify CIS benchmark version. It would be an error to specify both --version and --benchmark flags")
 
-- 
GitLab