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

	// Index the virtual services for this gateway by the domain
	vsByDomain := 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
		}

		// Not specifying any domains is not an error per se, but we need to check whether multiple virtual services
		// don't specify any, so we use the empty string as a placeholder in this function.
		domains := append([]string{}, vs.VirtualHost.Domains...)
		if len(domains) == 0 {
			domains = []string{""}
		}

		for _, domain := range domains {
			vsByDomain[domain] = append(vsByDomain[domain], vs)
		}
	}

	var conflictingDomains []string
	for domain, vsWithThisDomain := range vsByDomain {
		if len(vsWithThisDomain) > 1 {
			conflictingDomains = append(conflictingDomains, domain)
			for i, vs := range vsWithThisDomain {
				var conflictingVsNames []string
				for j, otherVs := range vsWithThisDomain {
					if i != j {
						conflictingVsNames = append(conflictingVsNames, otherVs.Metadata.Ref().Key())
					}
				}
				reports.AddError(vs, DomainInOtherVirtualServicesErr(domain, conflictingVsNames))
			}
		}
	}
	if len(conflictingDomains) > 0 {
		reports.AddError(gateway, GatewayHasConflictingVirtualServicesErr(conflictingDomains))
	}
}
// Errors will be added to the report object.
Errors will be added to the report object.
// Errors will be added to the report object .
func validateVirtualServiceDomains(gateway *v1.Gateway, virtualServices v1.VirtualServiceList, reports reporter.ResourceReports) {
	vsByDomain := map[string]v1.VirtualServiceList{}
	for _, vs := range virtualServices {
		if vs.VirtualHost == nil {
			reports.AddWarning(vs, NoVirtualHostErr(vs).Error())
			continue
		}
		domains := append([]string{}, vs.VirtualHost.Domains...)
		if len(domains) == 0 {
			domains = []string{""}
		}
		for _, domain := range domains {
			vsByDomain[domain] = append(vsByDomain[domain], vs)
		}
	}
	var conflictingDomains []string
	for domain, vsWithThisDomain := range vsByDomain {
		if len(vsWithThisDomain) > 1 {
			conflictingDomains = append(conflictingDomains, domain)
			for i, vs := range vsWithThisDomain {
				var conflictingVsNames []string
				for j, otherVs := range vsWithThisDomain {
					if i != j {
						conflictingVsNames = append(conflictingVsNames, otherVs.Metadata.Ref().Key())
					}
				}
				reports.AddError(vs, DomainInOtherVirtualServicesErr(domain, conflictingVsNames))
			}
		}
	}
	if len(conflictingDomains) > 0 {
		reports.AddError(gateway, GatewayHasConflictingVirtualServicesErr(conflictingDomains))
	}
}
func validateVirtualServiceDomains ( gateway * v1 . Gateway , virtualServices v1 . VirtualServiceList , reports reporter . ResourceReports ) { vsByDomain := map [ string ] v1 . VirtualServiceList { } for _ , vs := range virtualServices { if vs . VirtualHost == nil { reports . AddWarning ( vs , NoVirtualHostErr ( vs ) . Error ( ) ) continue } domains := append ( [ ] string { } , vs . VirtualHost . Domains ... ) if len ( domains ) == 0 { domains = [ ] string { " " } } for _ , domain := range domains { vsByDomain [ domain ] = append ( vsByDomain [ domain ] , vs ) } } var conflictingDomains [ ] string for domain , vsWithThisDomain := range vsByDomain { if len ( vsWithThisDomain ) > 1 { conflictingDomains = append ( conflictingDomains , domain ) for i , vs := range vsWithThisDomain { var conflictingVsNames [ ] string for j , otherVs := range vsWithThisDomain { if i != j { conflictingVsNames = append ( conflictingVsNames , otherVs . Metadata . Ref ( ) . Key ( ) ) } } reports . AddError ( vs , DomainInOtherVirtualServicesErr ( domain , conflictingVsNames ) ) } } } if len ( conflictingDomains ) > 0 { reports . AddError ( gateway , GatewayHasConflictingVirtualServicesErr ( conflictingDomains ) ) } }
Errors will be added to the report object.
Errors will be added to the report object .
// Index the virtual services for this gateway by the domain // Add warning and skip if no virtual host // Not specifying any domains is not an error per se, but we need to check whether multiple virtual services // don't specify any, so we use the empty string as a placeholder in this function.