From 2093b981a002020a5a03e54c3ca4f3a4f4a144c6 Mon Sep 17 00:00:00 2001
From: Joakim Karlsson <5434736+roffe@users.noreply.github.com>
Date: Tue, 29 May 2018 11:40:50 +0200
Subject: [PATCH] Mac compat

Make certgen work on OSX
---
 experimental/custom-metrics-api/gencerts.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/experimental/custom-metrics-api/gencerts.sh b/experimental/custom-metrics-api/gencerts.sh
index 312ce74c..1c2a2dc5 100755
--- a/experimental/custom-metrics-api/gencerts.sh
+++ b/experimental/custom-metrics-api/gencerts.sh
@@ -1,5 +1,14 @@
 #!/usr/bin/env bash
 
+# Detect if we are on mac or should use GNU base64 options
+case `uname` in
+        Darwin)
+            b64_opts='-b=0'
+            ;; 
+        *)
+            b64_opts='--width=0'
+esac
+
 go get -v -u github.com/cloudflare/cfssl/cmd/...
 
 export PURPOSE=metrics
@@ -16,6 +25,6 @@ kind: Secret
 metadata:
   name: cm-adapter-serving-certs
 data:
-  serving.crt: $(cat apiserver.pem | base64 --wrap=0)
-  serving.key: $(cat apiserver-key.pem | base64 --wrap=0)
+  serving.crt: $(cat apiserver.pem | base64 ${b64_opts})
+  serving.key: $(cat apiserver-key.pem | base64 ${b64_opts})
 EOF
-- 
GitLab