From fbfad43dfceedf1f6968e039f52bdcd6ac0b9033 Mon Sep 17 00:00:00 2001 From: Konstantin Belyaev Date: Wed, 23 May 2018 15:51:24 +0400 Subject: [PATCH] Add support to build kubectl with cgo Modify formula to support build dynamic binary with CGO_ENABLED=1. Building kubectl without cgo breaks dns name resolution since it uses /etc/resolv.conf for getting resolvers while nothing in macos should use it for name resolution. More information about this issue can be obtained here - https://github.com/kubernetes/release/issues/469 --- Formula/kubernetes-cli.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Formula/kubernetes-cli.rb b/Formula/kubernetes-cli.rb index 9106832b890e9..2d7b11a32bbb7 100644 --- a/Formula/kubernetes-cli.rb +++ b/Formula/kubernetes-cli.rb @@ -12,6 +12,8 @@ class KubernetesCli < Formula sha256 "ac6ea67a29a7e1b3581538c752097084734af77807831ed787084b081542a49f" => :el_capitan end + option "with-dynamic", "Build dynamic binary with CGO_ENABLED=1" + # kubernetes-cli will not support go1.10 until version 1.11.x depends_on "go@1.9" => :build @@ -27,6 +29,12 @@ def install ENV.deparallelize { system "make", "generated_files" } # Make binary + if build.with? "dynamic" + ENV["CGO_ENABLED"] = "1" + # Delete kubectl binary from KUBE_STATIC_LIBRARIES + inreplace "hack/lib/golang.sh", " kubectl", "" + end + system "make", "kubectl" bin.install "_output/local/bin/darwin/#{arch}/kubectl"