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

     1  package k8sreferencegrants
     2  
     3  import (
     4  	"fmt"
     5  
     6  	k8s_networking_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
     7  
     8  	"github.com/kiali/kiali/models"
     9  )
    10  
    11  type NamespaceChecker struct {
    12  	Namespaces     models.Namespaces
    13  	ReferenceGrant k8s_networking_v1beta1.ReferenceGrant
    14  }
    15  
    16  func (in NamespaceChecker) Check() ([]*models.IstioCheck, bool) {
    17  	validations := make([]*models.IstioCheck, 0)
    18  
    19  	if len(in.ReferenceGrant.Spec.From) > 0 {
    20  		for nsIndex, from := range in.ReferenceGrant.Spec.From {
    21  			if !in.Namespaces.Includes(string(from.Namespace)) {
    22  				validation := models.Build("k8sreferencegrants.from.namespacenotfound",
    23  					fmt.Sprintf("spec/from[%d]/namespace", nsIndex))
    24  				validations = append(validations, &validation)
    25  			}
    26  		}
    27  	}
    28  
    29  	return validations, len(validations) == 0
    30  }