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

     1  package checkers
     2  
     3  import (
     4  	k8s_networking_v1 "sigs.k8s.io/gateway-api/apis/v1"
     5  
     6  	"github.com/kiali/kiali/business/checkers/k8sgateways"
     7  	"github.com/kiali/kiali/config"
     8  	"github.com/kiali/kiali/models"
     9  )
    10  
    11  const K8sGatewayCheckerType = "k8sgateway"
    12  
    13  type K8sGatewayChecker struct {
    14  	K8sGateways    []*k8s_networking_v1.Gateway
    15  	GatewayClasses []config.GatewayAPIClass
    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 K8sGatewayChecker) Check() models.IstioValidations {
    21  	// Multinamespace checkers
    22  	validations := k8sgateways.MultiMatchChecker{
    23  		K8sGateways: g.K8sGateways,
    24  		Cluster:     g.Cluster,
    25  	}.Check()
    26  
    27  	for _, gw := range g.K8sGateways {
    28  		validations.MergeValidations(g.runSingleChecks(gw))
    29  	}
    30  
    31  	return validations
    32  }
    33  
    34  func (g K8sGatewayChecker) runSingleChecks(gw *k8s_networking_v1.Gateway) models.IstioValidations {
    35  	key, validations := EmptyValidValidation(gw.Name, gw.Namespace, K8sGatewayCheckerType, g.Cluster)
    36  
    37  	enabledCheckers := []Checker{
    38  		k8sgateways.StatusChecker{
    39  			K8sGateway: gw,
    40  		},
    41  		k8sgateways.GatewayClassChecker{
    42  			K8sGateway:     gw,
    43  			GatewayClasses: g.GatewayClasses,
    44  		},
    45  	}
    46  
    47  	for _, checker := range enabledCheckers {
    48  		checks, validChecker := checker.Check()
    49  		validations.Checks = append(validations.Checks, checks...)
    50  		validations.Valid = validations.Valid && validChecker
    51  	}
    52  
    53  	return models.IstioValidations{key: validations}
    54  }