| 72 | } |
| 73 | |
| 74 | func (d *devPod) Start(ctx devspacecontext.Context, devPodConfig *latest.DevPod, options Options) error { |
| 75 | d.m.Lock() |
| 76 | if d.cancel != nil { |
| 77 | d.m.Unlock() |
| 78 | return errors.Errorf("dev pod is already running, please stop it before starting") |
| 79 | } |
| 80 | |
| 81 | d.cancelCtx, d.cancel = context.WithCancel(ctx.Context()) |
| 82 | ctx = ctx.WithContext(d.cancelCtx) |
| 83 | d.m.Unlock() |
| 84 | |
| 85 | // log devpod to console if debug |
| 86 | if ctx.Log().GetLevel() == logrus.DebugLevel { |
| 87 | out, err := yaml.Marshal(devPodConfig) |
| 88 | if err == nil { |
| 89 | ctx.Log().Debugf("DevPod Config: \n%s\n", string(out)) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // start the dev pod |
| 94 | err := d.startWithRetry(ctx, devPodConfig, options) |
| 95 | if err != nil { |
| 96 | d.Stop() |
| 97 | return err |
| 98 | } |
| 99 | |
| 100 | return nil |
| 101 | } |
| 102 | |
| 103 | func (d *devPod) Err() error { |
| 104 | d.m.Lock() |