//TODO: Similar mechanisms for filters and applications
//Takes in response bytes, and add metadata to it based on some checks
Similar mechanisms for filters and applications
Takes in response bytes, and add metadata to it based on some checks
// TODO : Similar mechanisms for filters and applications // Takes in response bytes and add metadata to it based on some checks
func (mc *ContentModifier) AddMetadataForPatterns(contentBytes *[]byte) error {
	var patternsPage models.MesheryPatternPage
	err := json.Unmarshal(*contentBytes, &patternsPage)
	if err != nil {
		return err
	}
	patterns := patternsPage.Patterns
	var patternsPageMap map[string]interface{}
	patternsPageBytes, err := json.Marshal(patternsPage)
	if err != nil {
		return err
	}
	err = json.Unmarshal(patternsPageBytes, &patternsPageMap)
	if err != nil {
		return err
	}
	p := make([]map[string]interface{}, len(patterns))
	var wg sync.WaitGroup
	for i, pattern := range patterns {
		wg.Add(1)
		go func(pattern *models.MesheryPattern, i int, p *[]map[string]interface{}, token string, provider models.Provider, prefObj *models.Preference, uid string) {
			defer wg.Done()
			patterncontent := pattern.PatternFile
			temp, err := json.Marshal(pattern)
			if err != nil {
				return
			}
			err = json.Unmarshal(temp, &(*p)[i])
			if err != nil {
				return
			}
			msg, ok := mc.isPatternSupported(patterncontent)
			(*p)[i]["canSupport"] = ok
			(*p)[i]["errmsg"] = msg
		}(pattern, i, &p, mc.token, mc.provider, mc.prefObj, mc.userID)
	}
	wg.Wait()
	patternsPageMap["patterns"] = p
	*contentBytes, err = json.Marshal(patternsPageMap)
	if err != nil {
		return err
	}
	return err
}
func ( mc * ContentModifier ) AddMetadataForPatterns ( contentBytes * [ ] byte ) error { var patternsPage models . MesheryPatternPage err := json . Unmarshal ( * contentBytes , & patternsPage ) if err != nil { return err } patterns := patternsPage . Patterns var patternsPageMap map [ string ] interface { } patternsPageBytes , err := json . Marshal ( patternsPage ) if err != nil { return err } err = json . Unmarshal ( patternsPageBytes , & patternsPageMap ) if err != nil { return err } p := make ( [ ] map [ string ] interface { } , len ( patterns ) ) var wg sync . WaitGroup for i , pattern := range patterns { wg . Add ( 1 ) go func ( pattern * models . MesheryPattern , i int , p * [ ] map [ string ] interface { } , token string , provider models . Provider , prefObj * models . Preference , uid string ) { defer wg . Done ( ) patterncontent := pattern . PatternFile temp , err := json . Marshal ( pattern ) if err != nil { return } err = json . Unmarshal ( temp , & ( * p ) [ i ] ) if err != nil { return } msg , ok := mc . isPatternSupported ( patterncontent ) ( * p ) [ i ] [ " " ] = ok ( * p ) [ i ] [ " " ] = msg } ( pattern , i , & p , mc . token , mc . provider , mc . prefObj , mc . userID ) } wg . Wait ( ) patternsPageMap [ " " ] = p * contentBytes , err = json . Marshal ( patternsPageMap ) if err != nil { return err } return err }
Similar mechanisms for filters and applications
Takes in response bytes, and add metadata to it based on some checks
Similar mechanisms for filters and applications Takes in response bytes and add metadata to it based on some checks