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

     1  package checkers
     2  
     3  import (
     4  	networking_v1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1"
     5  
     6  	"github.com/kiali/kiali/business/checkers/gateways"
     7  	"github.com/kiali/kiali/models"
     8  )
     9  
    10  const GatewayCheckerType = "gateway"
    11  
    12  type GatewayChecker struct {
    13  	Gateways              []*networking_v1beta1.Gateway
    14  	WorkloadsPerNamespace map[string]models.WorkloadList
    15  	IsGatewayToNamespace  bool
    16  	Cluster               string
    17  }
    18  
    19  // Check runs checks for the all namespaces actions as well as for the single namespace validations
    20  func (g GatewayChecker) Check() models.IstioValidations {
    21  	// Multinamespace checkers
    22  	validations := gateways.MultiMatchChecker{
    23  		Gateways: g.Gateways,
    24  		Cluster:  g.Cluster,
    25  	}.Check()
    26  
    27  	for _, gw := range g.Gateways {
    28  		validations.MergeValidations(g.runSingleChecks(gw))
    29  	}
    30  
    31  	return validations
    32  }
    33  
    34  func (g GatewayChecker) runSingleChecks(gw *networking_v1beta1.Gateway) models.IstioValidations {
    35  	key, validations := EmptyValidValidation(gw.Name, gw.Namespace, GatewayCheckerType, g.Cluster)
    36  
    37  	enabledCheckers := []Checker{
    38  		gateways.SelectorChecker{
    39  			Gateway:               gw,
    40  			WorkloadsPerNamespace: g.WorkloadsPerNamespace,
    41  			IsGatewayToNamespace:  g.IsGatewayToNamespace,
    42  		},
    43  	}
    44  
    45  	for _, checker := range enabledCheckers {
    46  		checks, validChecker := checker.Check()
    47  		validations.Checks = append(validations.Checks, checks...)
    48  		validations.Valid = validations.Valid && validChecker
    49  	}
    50  
    51  	return models.IstioValidations{key: validations}
    52  }