(url string, kubectlClient kubectl.Client, analyzeNamespace string, log log.Logger, maxWait time.Duration)
| 248 | } |
| 249 | |
| 250 | func openURL(url string, kubectlClient kubectl.Client, analyzeNamespace string, log log.Logger, maxWait time.Duration) error { |
| 251 | // Loop and check if http code is != 502 |
| 252 | log.Info("Waiting for ingress...") |
| 253 | |
| 254 | // Make sure the ingress has some time to take effect |
| 255 | time.Sleep(time.Second * 5) |
| 256 | |
| 257 | now := time.Now() |
| 258 | for time.Since(now) < maxWait { |
| 259 | // Check if domain is ready => ignore error as we will retry request |
| 260 | resp, _ := http.Get(url) |
| 261 | if resp != nil && resp.StatusCode != http.StatusBadGateway && resp.StatusCode != http.StatusServiceUnavailable { |
| 262 | time.Sleep(time.Second * 1) |
| 263 | _ = open.Start(url) |
| 264 | log.Donef("Successfully opened %s", url) |
| 265 | return nil |
| 266 | } |
| 267 | |
| 268 | if kubectlClient != nil && analyzeNamespace != "" { |
| 269 | // Analyze space for issues |
| 270 | report, err := analyze.NewAnalyzer(kubectlClient, log).CreateReport(analyzeNamespace, analyze.Options{Wait: true}) |
| 271 | if err != nil { |
| 272 | return errors.Errorf("Error analyzing space: %v", err) |
| 273 | } |
| 274 | if len(report) > 0 { |
| 275 | reportString := analyze.ReportToString(report) |
| 276 | log.WriteString(logrus.InfoLevel, reportString) |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | time.Sleep(time.Second * 3) |
| 281 | } |
| 282 | return nil |
| 283 | } |
| 284 | |
| 285 | func (cmd *OpenCmd) openLocal(ctx devspacecontext.Context, domain string) error { |
| 286 | _, servicePort, serviceLabels, err := cmd.getService(ctx.KubeClient(), ctx.KubeClient().Namespace(), domain, true) |
no test coverage detected