Skip to content

Commit dcf3090

Browse files
Merge pull request #16335 from jpeeler/build-sc-images
Automatic merge from submit-queue Add service-catalog to local image builder This adds support to build service-catalog images, but by default is turned off (must specify service-catalog). I'm assuming this is the best behavior since by default service catalog is not built by the default make target.
2 parents 169bd66 + 302d6b4 commit dcf3090

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

hack/build-local-images.py

+26-14
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from tempfile import mkdtemp
88

99
from atexit import register
10-
from os import getenv, listdir, mkdir, remove
11-
from os.path import abspath, dirname, exists, isdir, join
10+
from os import getenv, mkdir, remove
11+
from os.path import abspath, dirname, isdir, join
1212

1313
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--h', '-help', '--help']:
1414
print """Quickly re-build images depending on OpenShift Origin build artifacts.
@@ -127,7 +127,17 @@
127127
"openshift": "/usr/bin/openshift"
128128
},
129129
"files": {}
130-
}
130+
},
131+
"service-catalog": {
132+
"directory": "service-catalog",
133+
"vendor_dir": "cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog",
134+
"binaries": {
135+
"controller-manager": "/usr/bin/controller-manager",
136+
"apiserver": "/usr/bin/apiserver",
137+
},
138+
"files": {},
139+
"enable_default": False,
140+
},
131141
}
132142

133143

@@ -138,12 +148,9 @@ def image_rebuild_requested(image):
138148
suffix explicitly or does not provide
139149
any explicit requests.
140150
"""
141-
return len(sys.argv) == 1 or (
142-
len(sys.argv) > 1 and (
143-
image in sys.argv or
144-
full_name(image) in sys.argv
145-
)
146-
)
151+
implicitly_triggered = len(sys.argv) == 1 and image_config[image].get("enable_default", True)
152+
explicitly_triggered = len(sys.argv) > 1 and (image in sys.argv or full_name(image) in sys.argv)
153+
return implicitly_triggered or explicitly_triggered
147154

148155

149156
def full_name(image):
@@ -166,10 +173,10 @@ def add_to_context(context_dir, source, destination, container_destination):
166173
sytem at the correct destination.
167174
"""
168175
debug("Adding file:\n\tfrom {}\n\tto {}\n\tincluding in container at {}".format(
169-
source,
170-
join(context_dir, destination),
171-
container_destination)
172-
)
176+
source,
177+
join(context_dir, destination),
178+
container_destination)
179+
)
173180
absolute_destination = abspath(join(context_dir, destination))
174181
if isdir(source):
175182
dir_util.copy_tree(source, absolute_destination)
@@ -185,7 +192,6 @@ def debug(message):
185192

186193

187194
os_root = abspath(join(dirname(__file__), ".."))
188-
os_bin_path = join(os_root, "_output", "local", "bin", "linux", "amd64")
189195
os_image_path = join(os_root, "images")
190196

191197
context_dir = mkdtemp()
@@ -205,8 +211,14 @@ def debug(message):
205211
with open(join(context_dir, "Dockerfile"), "w+") as dockerfile:
206212
dockerfile.write("FROM {}\n".format(full_name(image)))
207213

214+
binary_dir_args = ["_output", "local", "bin", "linux", "amd64"]
208215
config = image_config[image]
209216
for binary in config.get("binaries", []):
217+
if "vendor_dir" in config:
218+
os_bin_path = join(os_root, config.get("vendor_dir"), *binary_dir_args)
219+
else:
220+
os_bin_path = join(os_root, *binary_dir_args)
221+
210222
add_to_context(
211223
context_dir,
212224
source=join(os_bin_path, binary),

0 commit comments

Comments
 (0)