@@ -163,6 +163,12 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
163163 if go == None :
164164 sys .exit (0 )
165165
166+ # If the user wants debug, this will be set
167+ debug = True
168+ enable_debug = get_build_metadata (key = 'debug' )
169+ if enable_debug == None :
170+ debug = False
171+
166172 # If no build directory is specified, make a temporary one
167173 if build_dir == None :
168174 build_dir = tempfile .mkdtemp ()
@@ -171,23 +177,23 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
171177 bot .logger .info ('Build directory set to %s' , build_dir )
172178
173179 # Get variables from the instance metadata API
174- metadata = [{'key' : 'repo_url' , 'value' : repo_url , 'return_text' : False },
175- {'key' : 'repo_id' , 'value' : repo_id , 'return_text' : True },
176- {'key' : 'response_url' , 'value' : response_url , 'return_text' : True },
177- {'key' : 'bucket_name' , 'value' : bucket_name , 'return_text' : True },
178- {'key' : 'token' , 'value' : token , 'return_text' : False },
179- {'key' : 'commit' , 'value' : commit , 'return_text' : True },
180- {'key' : 'secret' , 'value' : secret , 'return_text' : True },
181- {'key' : 'size' , 'value' : size , 'return_text' : True },
182- {'key' : 'branch' , 'value' : branch , 'return_text' : True },
183- {'key' : 'spec_file' , 'value' : spec_file , 'return_text' : True },
184- {'key' : 'padding' , 'value' : padding , 'return_text' : True },
185- {'key' : 'logging_url' , 'value' : logging_url , 'return_text' : True },
186- {'key' : 'logfile' , 'value' : logfile , 'return_text' : True }]
187-
180+ metadata = [{'key' : 'repo_url' , 'value' : repo_url },
181+ {'key' : 'repo_id' , 'value' : repo_id },
182+ {'key' : 'response_url' , 'value' : response_url },
183+ {'key' : 'bucket_name' , 'value' : bucket_name },
184+ {'key' : 'token' , 'value' : token },
185+ {'key' : 'commit' , 'value' : commit },
186+ {'key' : 'secret' , 'value' : secret },
187+ {'key' : 'size' , 'value' : size },
188+ {'key' : 'branch' , 'value' : branch },
189+ {'key' : 'spec_file' , 'value' : spec_file },
190+ {'key' : 'padding' , 'value' : padding },
191+ {'key' : 'logging_url' , 'value' : logging_url },
192+ {'key' : 'logfile' , 'value' : logfile }]
188193
189194 # Obtain values from build
190195 params = get_build_params (metadata )
196+ params ['debug' ] = debug
191197
192198 # Default spec file is Singularity
193199 if params ['spec_file' ] == None :
@@ -311,8 +317,7 @@ def finish_build(verbose=True):
311317
312318def get_build_metadata (key ):
313319 '''get_build_metadata will return metadata about an instance from within it.
314- :param key: the key to look upu
315- :param return_text: return text (appropriate for one value, or if needs custom parsing. Otherwise, will return json
320+ :param key: the key to look up
316321 '''
317322 headers = {"Metadata-Flavor" :"Google" }
318323 url = "http://metadata.google.internal/computeMetadata/v1/instance/attributes/%s" % (key )
@@ -332,12 +337,12 @@ def get_build_metadata(key):
332337def get_build_params (metadata ):
333338 '''get_build_params uses get_build_metadata to retrieve corresponding meta data values for a build
334339 :param metadata: a list, each item a dictionary of metadata, in format:
335- metadata = [{'key': 'repo_url', 'value': repo_url, 'return_text': False },
336- {'key': 'repo_id', 'value': repo_id, 'return_text': True },
337- {'key': 'credential', 'value': credential, 'return_text': True },
338- {'key': 'response_url', 'value': response_url, 'return_text': True },
339- {'key': 'token', 'value': token, 'return_text': False },
340- {'key': 'commit', 'value': commit, 'return_text': True }]
340+ metadata = [{'key': 'repo_url', 'value': repo_url },
341+ {'key': 'repo_id', 'value': repo_id },
342+ {'key': 'credential', 'value': credential },
343+ {'key': 'response_url', 'value': response_url },
344+ {'key': 'token', 'value': token},
345+ {'key': 'commit', 'value': commit }]
341346
342347 '''
343348 params = dict ()
0 commit comments