@@ -93,7 +93,7 @@ def list_bucket(bucket):
9393
9494
9595def run_build (build_dir = None ,spec_file = None ,repo_url = None ,token = None ,size = None ,bucket_name = None ,
96- repo_id = None ,commit = None ,verbose = True ,response_url = None ,logfile = None ):
96+ repo_id = None ,commit = None ,verbose = True ,response_url = None ,logfile = None , secret = None ):
9797 '''run_build will generate the Singularity build from a spec_file from a repo_url.
9898 If no arguments are required, the metadata api is queried for the values.
9999 :param build_dir: directory to do the build in. If not specified,
@@ -105,7 +105,8 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
105105 :param size: the size of the image to build. If none set, builds default 1024.
106106 :param bucket_name: the name of the bucket to send files to
107107 :param verbose: print out extra details as we go (default True)
108- :param token: a token to send back to the server to authenticate adding the build
108+ :param token: a token to send back to the server to authenticate the collection
109+ :param secret: a secret to match to the correct container
109110 :param logfile: path to a logfile to read and include path in response to server.
110111 :param response_url: the build url to send the response back to. Should also come
111112 from metadata. If not specified, no response is sent
@@ -131,6 +132,7 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
131132 {'key' : 'bucket_name' , 'value' : bucket_name , 'return_text' : True },
132133 {'key' : 'token' , 'value' : token , 'return_text' : False },
133134 {'key' : 'commit' , 'value' : commit , 'return_text' : True },
135+ {'key' : 'secret' , 'value' : secret , 'return_text' : True },
134136 {'key' : 'size' , 'value' : size , 'return_text' : True },
135137 {'key' : 'logfile' , 'value' : logfile , 'return_text' : True }]
136138
@@ -203,19 +205,18 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
203205 files .append (log_file )
204206
205207 # Finally, package everything to send back to shub
206- response = {"files" : files ,
208+ response = {"files" : json . dumps ( files ) ,
207209 "repo_url" : params ['repo_url' ],
208210 "commit" : params ['commit' ],
209- "repo_id" : params ['repo_id' ]}
211+ "repo_id" : params ['repo_id' ],
212+ "secret" : params ['secret' ]}
210213
211214 if params ['token' ] != None :
212215 response ['token' ] = params ['token' ]
213216
214217 # Send it back!
215218 if params ['response_url' ] != None :
216- response = api_put (url = params ['response_url' ],
217- data = response ,
218- token = params ['token' ]) # will generate header with token
219+ finish = requests .post (params ['response_url' ],data = response )
219220
220221 else :
221222 # Tell the user what is actually there
@@ -224,6 +225,10 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
224225 logging .info ("Found files are %s" ,"\n " .join (present_files ))
225226
226227
228+ # Clean up
229+ shutil .rmtree (build_dir )
230+
231+
227232#####################################################################################
228233# METADATA
229234#####################################################################################
0 commit comments