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

Method findDomain

cmd/open.go:440–474  ·  view source on GitHub ↗
(client kubectl.Client, namespace, host string)

Source from the content-addressed store, hash-verified

438}
439
440func (cmd *OpenCmd) findDomain(client kubectl.Client, namespace, host string) (string, bool, error) {
441 cmd.log.Info("Retrieve ingresses...")
442
443 // List all ingresses and only create one if there is none already
444 ingressList, err := client.KubeClient().NetworkingV1().Ingresses(namespace).List(context.TODO(), metav1.ListOptions{})
445 if err != nil {
446 return "", false, errors.Errorf("Error listing ingresses: %v", err)
447 }
448
449 // Check ingresses for our domain
450 domain := ""
451 tls := false
452 for _, ingress := range ingressList.Items {
453 for _, rule := range ingress.Spec.Rules {
454 if strings.TrimSpace(rule.Host) == host {
455 domain = host
456 }
457 }
458
459 // Check if tls is enabled
460 if domain != "" {
461 for _, tlsEntry := range ingress.Spec.TLS {
462 for _, host := range tlsEntry.Hosts {
463 if strings.TrimSpace(host) == host {
464 tls = true
465 }
466 }
467 }
468
469 break
470 }
471 }
472
473 return domain, tls, nil
474}

Callers 1

RunOpenMethod · 0.95

Calls 4

ListMethod · 0.65
KubeClientMethod · 0.65
InfoMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected