| 382 | } |
| 383 | |
| 384 | func nextRequeueTimeDuration(cloudshell *cloudshellv1alpha1.CloudShell) *time.Duration { |
| 385 | if cloudshell.Spec.TTLSecondsAfterStarted != nil { |
| 386 | startTime := metav1.Now() |
| 387 | if cloudshell.Status.LastScheduleTime != nil { |
| 388 | startTime = *cloudshell.Status.LastScheduleTime |
| 389 | } |
| 390 | |
| 391 | ttl := time.Second * time.Duration(*cloudshell.Spec.TTLSecondsAfterStarted) |
| 392 | |
| 393 | duration := time.Until(startTime.Add(ttl)) |
| 394 | return &duration |
| 395 | } |
| 396 | |
| 397 | return nil |
| 398 | } |
| 399 | |
| 400 | // StartupWorkerFor copy kubeConfig and start ttyd |
| 401 | func (c *Controller) StartupWorkerFor(ctx context.Context, cloudshell *cloudshellv1alpha1.CloudShell) error { |