MCPcopy Index your code
hub / github.com/devspace-sh/devspace / openURL

Function openURL

cmd/open.go:250–283  ·  view source on GitHub ↗
(url string, kubectlClient kubectl.Client, analyzeNamespace string, log log.Logger, maxWait time.Duration)

Source from the content-addressed store, hash-verified

248}
249
250func 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
285func (cmd *OpenCmd) openLocal(ctx devspacecontext.Context, domain string) error {
286 _, servicePort, serviceLabels, err := cmd.getService(ctx.KubeClient(), ctx.KubeClient().Namespace(), domain, true)

Callers 1

RunOpenMethod · 0.85

Calls 9

NewAnalyzerFunction · 0.92
ReportToStringFunction · 0.92
StartMethod · 0.65
CreateReportMethod · 0.65
WriteStringMethod · 0.65
InfoMethod · 0.45
GetMethod · 0.45
DonefMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected