7
7
from tempfile import mkdtemp
8
8
9
9
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
12
12
13
13
if len (sys .argv ) > 1 and sys .argv [1 ] in ['-h' , '--h' , '-help' , '--help' ]:
14
14
print """Quickly re-build images depending on OpenShift Origin build artifacts.
127
127
"openshift" : "/usr/bin/openshift"
128
128
},
129
129
"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
+ },
131
141
}
132
142
133
143
@@ -138,12 +148,9 @@ def image_rebuild_requested(image):
138
148
suffix explicitly or does not provide
139
149
any explicit requests.
140
150
"""
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
147
154
148
155
149
156
def full_name (image ):
@@ -166,10 +173,10 @@ def add_to_context(context_dir, source, destination, container_destination):
166
173
sytem at the correct destination.
167
174
"""
168
175
debug ("Adding file:\n \t from {}\n \t to {}\n \t including 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
+ )
173
180
absolute_destination = abspath (join (context_dir , destination ))
174
181
if isdir (source ):
175
182
dir_util .copy_tree (source , absolute_destination )
@@ -185,7 +192,6 @@ def debug(message):
185
192
186
193
187
194
os_root = abspath (join (dirname (__file__ ), ".." ))
188
- os_bin_path = join (os_root , "_output" , "local" , "bin" , "linux" , "amd64" )
189
195
os_image_path = join (os_root , "images" )
190
196
191
197
context_dir = mkdtemp ()
@@ -205,8 +211,14 @@ def debug(message):
205
211
with open (join (context_dir , "Dockerfile" ), "w+" ) as dockerfile :
206
212
dockerfile .write ("FROM {}\n " .format (full_name (image )))
207
213
214
+ binary_dir_args = ["_output" , "local" , "bin" , "linux" , "amd64" ]
208
215
config = image_config [image ]
209
216
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
+
210
222
add_to_context (
211
223
context_dir ,
212
224
source = join (os_bin_path , binary ),
0 commit comments