@@ -59,6 +59,7 @@ type SkaffoldRunner struct {
59
59
opts * config.SkaffoldOptions
60
60
watchFactory watch.Factory
61
61
builds []build.Artifact
62
+ hasDeployed bool
62
63
imageList * kubernetes.ImageList
63
64
}
64
65
@@ -207,6 +208,11 @@ func (r *SkaffoldRunner) newLogger(out io.Writer, artifacts []*latest.Artifact)
207
208
return kubernetes .NewLogAggregator (out , imageNames , r .imageList )
208
209
}
209
210
211
+ // HasDeployed returns true if this runner has deployed something.
212
+ func (r * SkaffoldRunner ) HasDeployed () bool {
213
+ return r .hasDeployed
214
+ }
215
+
210
216
func (r * SkaffoldRunner ) buildTestDeploy (ctx context.Context , out io.Writer , artifacts []* latest.Artifact ) error {
211
217
bRes , err := r .BuildAndTest (ctx , out , artifacts )
212
218
if err != nil {
@@ -260,6 +266,13 @@ func (r *SkaffoldRunner) BuildAndTest(ctx context.Context, out io.Writer, artifa
260
266
return bRes , err
261
267
}
262
268
269
+ // Deploy deploys the given artifacts
270
+ func (r * SkaffoldRunner ) Deploy (ctx context.Context , out io.Writer , artifacts []build.Artifact ) ([]deploy.Artifact , error ) {
271
+ dRes , err := r .Deployer .Deploy (ctx , out , artifacts )
272
+ r .hasDeployed = true
273
+ return dRes , err
274
+ }
275
+
263
276
// TailLogs prints the logs for deployed artifacts.
264
277
func (r * SkaffoldRunner ) TailLogs (ctx context.Context , out io.Writer , artifacts []* latest.Artifact , bRes []build.Artifact ) error {
265
278
if ! r .opts .Tail {
@@ -281,7 +294,7 @@ func (r *SkaffoldRunner) TailLogs(ctx context.Context, out io.Writer, artifacts
281
294
282
295
// Dev watches for changes and runs the skaffold build and deploy
283
296
// pipeline until interrrupted by the user.
284
- func (r * SkaffoldRunner ) Dev (ctx context.Context , out io.Writer , artifacts []* latest.Artifact ) ([]build. Artifact , error ) {
297
+ func (r * SkaffoldRunner ) Dev (ctx context.Context , out io.Writer , artifacts []* latest.Artifact ) error {
285
298
logger := r .newLogger (out , artifacts )
286
299
287
300
// Create watcher and register artifacts to build current state of files.
@@ -349,7 +362,7 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
349
362
func () ([]string , error ) { return DependenciesForArtifact (ctx , artifact ) },
350
363
func (e watch.Events ) { changed .AddDirtyArtifact (artifact , e ) },
351
364
); err != nil {
352
- return nil , errors .Wrapf (err , "watching files for artifact %s" , artifact .ImageName )
365
+ return errors .Wrapf (err , "watching files for artifact %s" , artifact .ImageName )
353
366
}
354
367
}
355
368
@@ -358,47 +371,47 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
358
371
func () ([]string , error ) { return r .TestDependencies () },
359
372
func (watch.Events ) { changed .needsRedeploy = true },
360
373
); err != nil {
361
- return nil , errors .Wrap (err , "watching test files" )
374
+ return errors .Wrap (err , "watching test files" )
362
375
}
363
376
364
377
// Watch deployment configuration
365
378
if err := watcher .Register (
366
379
func () ([]string , error ) { return r .Dependencies () },
367
380
func (watch.Events ) { changed .needsRedeploy = true },
368
381
); err != nil {
369
- return nil , errors .Wrap (err , "watching files for deployer" )
382
+ return errors .Wrap (err , "watching files for deployer" )
370
383
}
371
384
372
385
// Watch Skaffold configuration
373
386
if err := watcher .Register (
374
387
func () ([]string , error ) { return []string {r .opts .ConfigurationFile }, nil },
375
388
func (watch.Events ) { changed .needsReload = true },
376
389
); err != nil {
377
- return nil , errors .Wrapf (err , "watching skaffold configuration %s" , r .opts .ConfigurationFile )
390
+ return errors .Wrapf (err , "watching skaffold configuration %s" , r .opts .ConfigurationFile )
378
391
}
379
392
380
393
// First run
381
394
if err := r .buildTestDeploy (ctx , out , artifacts ); err != nil {
382
- return nil , errors .Wrap (err , "exiting dev mode because first run failed" )
395
+ return errors .Wrap (err , "exiting dev mode because first run failed" )
383
396
}
384
397
385
398
// Start logs
386
399
if r .opts .TailDev {
387
400
if err := logger .Start (ctx ); err != nil {
388
- return nil , errors .Wrap (err , "starting logger" )
401
+ return errors .Wrap (err , "starting logger" )
389
402
}
390
403
}
391
404
392
405
if r .opts .PortForward {
393
406
portForwarder := kubernetes .NewPortForwarder (out , r .imageList )
394
407
395
408
if err := portForwarder .Start (ctx ); err != nil {
396
- return nil , errors .Wrap (err , "starting port-forwarder" )
409
+ return errors .Wrap (err , "starting port-forwarder" )
397
410
}
398
411
}
399
412
400
413
r .Trigger .WatchForChanges (out )
401
- return nil , watcher .Run (ctx , r .Trigger , onChange )
414
+ return watcher .Run (ctx , r .Trigger , onChange )
402
415
}
403
416
404
417
func (r * SkaffoldRunner ) shouldWatch (artifact * latest.Artifact ) bool {
0 commit comments