From 643cad37228cbb69b038dfc63241389328eecc8f Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Wed, 13 Sep 2017 14:32:13 -0400 Subject: [PATCH] Teach build-local-images to build service-catalog Building images from RPM takes quite a bit of time, so add service catalog to the local image build list. A prerequisite for this task is to have the service catalog binaries compiled, which is done with #1: 1) cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog/hack/build-go.sh 2) hack/build-local-images service-catalog The first script uses the origin tooling to build in the same way as the RPMs are built. Note that a new "enable_default" key has been added to the image_config and set to False for service catalog so that it is not built unless directly specified (as indicated in #2). --- hack/build-local-images.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/hack/build-local-images.py b/hack/build-local-images.py index 6ed875ce9bc9..3d62e66c1dff 100755 --- a/hack/build-local-images.py +++ b/hack/build-local-images.py @@ -127,7 +127,17 @@ "openshift": "/usr/bin/openshift" }, "files": {} - } + }, + "service-catalog": { + "directory": "service-catalog", + "vendor_dir": "cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog", + "binaries": { + "controller-manager": "/usr/bin/controller-manager", + "apiserver": "/usr/bin/apiserver", + }, + "files": {}, + "enable_default": False, + }, } @@ -138,12 +148,9 @@ def image_rebuild_requested(image): suffix explicitly or does not provide any explicit requests. """ - return len(sys.argv) == 1 or ( - len(sys.argv) > 1 and ( - image in sys.argv or - full_name(image) in sys.argv - ) - ) + implicitly_triggered = len(sys.argv) == 1 and image_config[image].get("enable_default", True) + explicitly_triggered = len(sys.argv) > 1 and (image in sys.argv or full_name(image) in sys.argv) + return implicitly_triggered or explicitly_triggered def full_name(image): @@ -185,7 +192,6 @@ def debug(message): os_root = abspath(join(dirname(__file__), "..")) -os_bin_path = join(os_root, "_output", "local", "bin", "linux", "amd64") os_image_path = join(os_root, "images") context_dir = mkdtemp() @@ -205,8 +211,14 @@ def debug(message): with open(join(context_dir, "Dockerfile"), "w+") as dockerfile: dockerfile.write("FROM {}\n".format(full_name(image))) + binary_dir_args = ["_output", "local", "bin", "linux", "amd64"] config = image_config[image] for binary in config.get("binaries", []): + if "vendor_dir" in config: + os_bin_path = join(os_root, config.get("vendor_dir"), *binary_dir_args) + else: + os_bin_path = join(os_root, *binary_dir_args) + add_to_context( context_dir, source=join(os_bin_path, binary),