Skip to content

Commit

Permalink
Teach build-local-images to build service-catalog
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jpeeler committed Sep 14, 2017
1 parent 01d9694 commit 643cad3
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions hack/build-local-images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}


Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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),
Expand Down

0 comments on commit 643cad3

Please sign in to comment.