StartSSH starts the ssh functionality
(ctx devspacecontext.Context, devPod *latest.DevPod, selector targetselector.TargetSelector, parent *tomb.Tomb)
| 28 | |
| 29 | // StartSSH starts the ssh functionality |
| 30 | func StartSSH(ctx devspacecontext.Context, devPod *latest.DevPod, selector targetselector.TargetSelector, parent *tomb.Tomb) (retErr error) { |
| 31 | if ctx == nil || ctx.Config() == nil || ctx.Config().Config() == nil { |
| 32 | return fmt.Errorf("DevSpace config is nil") |
| 33 | } |
| 34 | |
| 35 | // init done array is used to track when sync was initialized |
| 36 | initDoneArray := []chan struct{}{} |
| 37 | loader.EachDevContainer(devPod, func(devContainer *latest.DevContainer) bool { |
| 38 | if devContainer.SSH == nil || (devContainer.SSH.Enabled != nil && !*devContainer.SSH.Enabled) { |
| 39 | return true |
| 40 | } |
| 41 | |
| 42 | initDone := parent.NotifyGo(func() error { |
| 43 | return startSSH(ctx, devPod.Name, string(devContainer.Arch), devContainer.SSH, selector.WithContainer(devContainer.Container), parent) |
| 44 | }) |
| 45 | initDoneArray = append(initDoneArray, initDone) |
| 46 | return true |
| 47 | }) |
| 48 | |
| 49 | // wait for init chans to be finished |
| 50 | for _, initDone := range initDoneArray { |
| 51 | <-initDone |
| 52 | } |
| 53 | return nil |
| 54 | } |
| 55 | |
| 56 | func startSSH(ctx devspacecontext.Context, name, arch string, sshConfig *latest.SSH, selector targetselector.TargetSelector, parent *tomb.Tomb) error { |
| 57 | if ctx.IsDone() { |
no test coverage detected