Merge pull request #67106 from spiffxp/make-test-images-on-macos

Automatic merge from submit-queue (batch tested with PRs 66984, 67236, 67216, 62721, 67106). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

macOS and docker for mac don't play nicely with mktemp

**What this PR does / why we need it**:

On macOS mktemp -d drops something in /var/folders, which isn't
shared by default with Docker for Mac. Thus I can't run docker
with that volume mounted to build binaries for test images. So
instead, tell mktemp to use kubernetes/_tmp as its base, which
is what I see some of the hack/verify-* scripts use

I had to use this patch to build images for:
- https://github.com/kubernetes/kubernetes/pull/67030
- https://github.com/kubernetes/kubernetes/pull/67034
- https://github.com/kubernetes/kubernetes/pull/67035

I am _super_ open to a better way of doing this if I missed something

**Special notes for your reviewer**: Kindly make sure this doesn't break
building images on linux

/release-note-none
/sig release
/cc @dims @ixdy
This commit is contained in:
Kubernetes Submit Queue 2018-08-10 18:59:19 -07:00 committed by GitHub
commit 1658e70ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,10 @@ build() {
# Create a temporary directory for every architecture and copy the image content
# and build the image from temporary directory
temp_dir=$(mktemp -d)
mkdir -p ${KUBE_ROOT}/_tmp
temp_dir=$(mktemp -d ${KUBE_ROOT}/_tmp/test-images-build.XXXXXX)
kube::util::trap_add "rm -rf ${temp_dir}" EXIT
cp -r ${IMAGE}/* ${temp_dir}
if [[ -f ${IMAGE}/Makefile ]]; then
# make bin will take care of all the prerequisites needed