github.com/kiali/kiali@v1.84.0/business/checkers/gateways/port_checker.go (about)

     1  package gateways
     2  
     3  import (
     4  	"fmt"
     5  
     6  	networking_v1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1"
     7  
     8  	"github.com/kiali/kiali/kubernetes"
     9  	"github.com/kiali/kiali/models"
    10  )
    11  
    12  type PortChecker struct {
    13  	Gateway *networking_v1beta1.Gateway
    14  }
    15  
    16  func (p PortChecker) Check() ([]*models.IstioCheck, bool) {
    17  	validations := make([]*models.IstioCheck, 0)
    18  	for serverIndex, server := range p.Gateway.Spec.Servers {
    19  		if server == nil {
    20  			continue
    21  		}
    22  		if !kubernetes.ValidatePort(server.Port) {
    23  			validation := models.Build("port.name.mismatch",
    24  				fmt.Sprintf("spec/servers[%d]/port/name", serverIndex))
    25  			validations = append(validations, &validation)
    26  		}
    27  	}
    28  	return validations, len(validations) == 0
    29  }