@@ -150,7 +150,7 @@ var (
150150 },
151151 }
152152
153- obtainMachine := func () (* buildRofl.Machine , error ) {
153+ obtainMachine := func () (* buildRofl.Machine , * roflmarket. Instance , error ) {
154154 if deployOffer != "" {
155155 machine .Offer = deployOffer
156156 }
@@ -168,15 +168,15 @@ var (
168168 }
169169 if offer == nil {
170170 showProviderOffers (ctx , npa , conn , * providerAddr )
171- return nil , fmt .Errorf ("offer '%s' not found for provider '%s'" , machine .Offer , providerAddr )
171+ return nil , nil , fmt .Errorf ("offer '%s' not found for provider '%s'" , machine .Offer , providerAddr )
172172 }
173173
174174 fmt .Printf ("Taking offer:\n " )
175175 showProviderOffer (ctx , offer )
176176
177177 term := detectTerm (offer )
178178 if deployTermCount < 1 {
179- return nil , fmt .Errorf ("number of terms must be at least 1" )
179+ return nil , nil , fmt .Errorf ("number of terms must be at least 1" )
180180 }
181181
182182 // Calculate total price.
@@ -206,23 +206,27 @@ var (
206206
207207 var machineID roflmarket.InstanceID
208208 if ! common .BroadcastOrExportTransaction (ctx , npa , conn , sigTx , meta , & machineID ) {
209- return nil , fmt .Errorf ("broadcast transaction failed" )
209+ return nil , nil , fmt .Errorf ("broadcast transaction failed" )
210210 }
211211
212212 rawMachineID , _ := machineID .MarshalText ()
213- cobra .CheckErr (err )
214213 machine .ID = string (rawMachineID )
215214 deployment .Machines [deployMachine ] = machine
216215
217216 fmt .Printf ("Created machine: %s\n " , machine .ID )
218- return machine , nil
217+
218+ var insDsc * roflmarket.Instance
219+ insDsc , err = conn .Runtime (npa .ParaTime ).ROFLMarket .Instance (ctx , client .RoundLatest , * providerAddr , machineID )
220+ cobra .CheckErr (err )
221+
222+ return machine , insDsc , nil
219223 }
220224
221- doDeployMachine := func (machine * buildRofl.Machine ) error {
225+ doDeployMachine := func (machine * buildRofl.Machine ) ( * roflmarket. Instance , error ) {
222226 // Deploy into existing machine.
223227 var machineID roflmarket.InstanceID
224228 if err = machineID .UnmarshalText ([]byte (machine .ID )); err != nil {
225- return fmt .Errorf ("malformed machine ID: %w" , err )
229+ return nil , fmt .Errorf ("malformed machine ID: %w" , err )
226230 }
227231
228232 fmt .Printf ("Deploying into existing machine: %s\n " , machine .ID )
@@ -237,8 +241,8 @@ var (
237241 if deployReplaceMachine {
238242 fmt .Printf ("Machine instance not found. Obtaining new one..." )
239243 machine .ID = ""
240- _ , err = obtainMachine ()
241- return err
244+ _ , _ , err = obtainMachine ()
245+ return nil , err
242246 }
243247
244248 cobra .CheckErr ("Machine instance not found.\n Tip: If your instance expired, run this command with --replace-machine flag to replace it with a new machine." )
@@ -248,7 +252,7 @@ var (
248252 if insDsc .Deployment != nil && insDsc .Deployment .AppID != machineDeployment .AppID && ! deployForce {
249253 fmt .Printf ("Machine already contains a deployment of ROFL app '%s'.\n " , insDsc .Deployment .AppID )
250254 fmt .Printf ("You are trying to replace it with ROFL app '%s'.\n " , machineDeployment .AppID )
251- return fmt .Errorf ("refusing to change existing ROFL app, use --force to override" )
255+ return nil , fmt .Errorf ("refusing to change existing ROFL app, use --force to override" )
252256 }
253257
254258 // Prepare transaction.
@@ -269,23 +273,26 @@ var (
269273 cobra .CheckErr (err )
270274
271275 if ! common .BroadcastOrExportTransaction (ctx , npa , conn , sigTx , meta , nil ) {
272- return fmt .Errorf ("broadcast transaction failed" )
276+ return nil , fmt .Errorf ("broadcast transaction failed" )
273277 }
274278
275- return nil
279+ return insDsc , nil
276280 }
277281
282+ var insDsc * roflmarket.Instance
278283 if machine .ID == "" {
279284 // When machine is not set, we need to obtain one.
280285 fmt .Printf ("No pre-existing machine configured, creating a new one...\n " )
281- machine , err = obtainMachine ()
286+ machine , insDsc , err = obtainMachine ()
282287 cobra .CheckErr (err )
283288 } else {
284- cobra .CheckErr (doDeployMachine (machine ))
289+ insDsc , err = doDeployMachine (machine )
290+ cobra .CheckErr (err )
285291 }
286292
287293 fmt .Printf ("Deployment into machine scheduled.\n " )
288- fmt .Printf ("Use `oasis rofl machine show` to see status.\n " )
294+ fmt .Printf ("This machine expires on %s. Use `oasis rofl machine top-up` to extend it.\n " , time .Unix (int64 (insDsc .PaidUntil ), 0 ))
295+ fmt .Printf ("Use `oasis rofl machine show` to check status.\n " )
289296
290297 if err = manifest .Save (); err != nil {
291298 cobra .CheckErr (fmt .Errorf ("failed to update manifest: %w" , err ))
0 commit comments