func validateVirtualServiceSniDomains(gateway *v1.Gateway, virtualServices v1.VirtualServiceList, reports reporter.ResourceReports) {

	// Index the virtual services for this gateway by the domain
	vsBySniDomain := map[string]v1.VirtualServiceList{}
	for _, vs := range virtualServices {

		// Add warning and skip if no virtual host
		if vs.VirtualHost == nil {
			reports.AddWarning(vs, NoVirtualHostErr(vs).Error())
			continue
		}

		if len(vs.GetSslConfig().GetSniDomains()) > 0 {
			sniDomains := append([]string{}, vs.SslConfig.SniDomains...)
			for _, sniDomain := range sniDomains {
				vsBySniDomain[sniDomain] = append(vsBySniDomain[sniDomain], vs)
			}
		}
	}

	var conflictingSniDomains []string
	for sniDomain, vsWithThisSniDomain := range vsBySniDomain {
		if len(vsWithThisSniDomain) > 1 {
			conflictingSniDomains = append(conflictingSniDomains, sniDomain)
			for idx1, vs := range vsWithThisSniDomain {
				var conflictingVsNames []string
				for idx2, otherVs := range vsWithThisSniDomain {
					if idx1 != idx2 {
						conflictingVsNames = append(conflictingVsNames, otherVs.Metadata.Ref().Key())
					}
				}
				reports.AddError(vs, SniDomainInOtherVirtualServicesErr(sniDomain, conflictingVsNames))
			}
		}
	}
	if len(conflictingSniDomains) > 0 {
		reports.AddError(gateway, GatewayHasConflictingVirtualServicesErr(conflictingSniDomains))
	}
}
// Similar to previous function, but for SNI domains.
// Errors will be added to the report object.
Similar to previous function, but for SNI domains.
Errors will be added to the report object.
// Similar to previous function but for SNI domains . // Errors will be added to the report object .
func validateVirtualServiceSniDomains(gateway *v1.Gateway, virtualServices v1.VirtualServiceList, reports reporter.ResourceReports) {
	vsBySniDomain := map[string]v1.VirtualServiceList{}
	for _, vs := range virtualServices {
		if vs.VirtualHost == nil {
			reports.AddWarning(vs, NoVirtualHostErr(vs).Error())
			continue
		}
		if len(vs.GetSslConfig().GetSniDomains()) > 0 {
			sniDomains := append([]string{}, vs.SslConfig.SniDomains...)
			for _, sniDomain := range sniDomains {
				vsBySniDomain[sniDomain] = append(vsBySniDomain[sniDomain], vs)
			}
		}
	}
	var conflictingSniDomains []string
	for sniDomain, vsWithThisSniDomain := range vsBySniDomain {
		if len(vsWithThisSniDomain) > 1 {
			conflictingSniDomains = append(conflictingSniDomains, sniDomain)
			for idx1, vs := range vsWithThisSniDomain {
				var conflictingVsNames []string
				for idx2, otherVs := range vsWithThisSniDomain {
					if idx1 != idx2 {
						conflictingVsNames = append(conflictingVsNames, otherVs.Metadata.Ref().Key())
					}
				}
				reports.AddError(vs, SniDomainInOtherVirtualServicesErr(sniDomain, conflictingVsNames))
			}
		}
	}
	if len(conflictingSniDomains) > 0 {
		reports.AddError(gateway, GatewayHasConflictingVirtualServicesErr(conflictingSniDomains))
	}
}
func validateVirtualServiceSniDomains ( gateway * v1 . Gateway , virtualServices v1 . VirtualServiceList , reports reporter . ResourceReports ) { vsBySniDomain := map [ string ] v1 . VirtualServiceList { } for _ , vs := range virtualServices { if vs . VirtualHost == nil { reports . AddWarning ( vs , NoVirtualHostErr ( vs ) . Error ( ) ) continue } if len ( vs . GetSslConfig ( ) . GetSniDomains ( ) ) > 0 { sniDomains := append ( [ ] string { } , vs . SslConfig . SniDomains ... ) for _ , sniDomain := range sniDomains { vsBySniDomain [ sniDomain ] = append ( vsBySniDomain [ sniDomain ] , vs ) } } } var conflictingSniDomains [ ] string for sniDomain , vsWithThisSniDomain := range vsBySniDomain { if len ( vsWithThisSniDomain ) > 1 { conflictingSniDomains = append ( conflictingSniDomains , sniDomain ) for idx1 , vs := range vsWithThisSniDomain { var conflictingVsNames [ ] string for idx2 , otherVs := range vsWithThisSniDomain { if idx1 != idx2 { conflictingVsNames = append ( conflictingVsNames , otherVs . Metadata . Ref ( ) . Key ( ) ) } } reports . AddError ( vs , SniDomainInOtherVirtualServicesErr ( sniDomain , conflictingVsNames ) ) } } } if len ( conflictingSniDomains ) > 0 { reports . AddError ( gateway , GatewayHasConflictingVirtualServicesErr ( conflictingSniDomains ) ) } }
Similar to previous function, but for SNI domains.
Similar to previous function but for SNI domains .
// Index the virtual services for this gateway by the domain // Add warning and skip if no virtual host