//checkIfUsedByAPISplitter checks if api is used by a deployed APISplitter
checkIfUsedByAPISplitter checks if api is used by a deployed APISplitter
// checkIfUsedByAPISplitter checks if api is used by a deployed APISplitter
func checkIfUsedByAPISplitter(apiName string) error {
	virtualServices, err := config.K8s.ListVirtualServicesByLabel("apiKind", userconfig.APISplitterKind.String())
	if err != nil {
		return err
	}
	var usedByAPISplitters []string
	for _, vs := range virtualServices {
		apiSplitterSpec, err := operator.DownloadAPISpec(vs.Labels["apiName"], vs.Labels["apiID"])
		if err != nil {
			return err
		}
		for _, api := range apiSplitterSpec.APIs {
			if apiName == api.Name {
				usedByAPISplitters = append(usedByAPISplitters, apiSplitterSpec.Name)
			}
		}
	}
	if len(usedByAPISplitters) > 0 {
		return ErrorAPIUsedByAPISplitter(usedByAPISplitters)
	}
	return nil
}
func checkIfUsedByAPISplitter ( apiName string ) error { virtualServices , err := config . K8s . ListVirtualServicesByLabel ( " " , userconfig . APISplitterKind . String ( ) ) if err != nil { return err } var usedByAPISplitters [ ] string for _ , vs := range virtualServices { apiSplitterSpec , err := operator . DownloadAPISpec ( vs . Labels [ " " ] , vs . Labels [ " " ] ) if err != nil { return err } for _ , api := range apiSplitterSpec . APIs { if apiName == api . Name { usedByAPISplitters = append ( usedByAPISplitters , apiSplitterSpec . Name ) } } } if len ( usedByAPISplitters ) > 0 { return ErrorAPIUsedByAPISplitter ( usedByAPISplitters ) } return nil }
checkIfUsedByAPISplitter checks if api is used by a deployed APISplitter
checkIfUsedByAPISplitter checks if api is used by a deployed APISplitter