api/outlier_report.go
func (a *API) UpdateOutlierReport(cfg *OutlierReport) (*OutlierReport, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid outlier report config [nil]")
	}

	reportCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.OutlierReportCIDRegex, reportCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid outlier report CID [%s]", reportCID)
	}

	jsonCfg, err := json.Marshal(cfg)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] update outlier report, sending JSON: %s", string(jsonCfg))
	}

	result, err := a.Put(reportCID, jsonCfg)
	if err != nil {
		return nil, err
	}

	report := &OutlierReport{}
	if err := json.Unmarshal(result, report); err != nil {
		return nil, err
	}

	return report, nil
}
func (a *API) UpdateOutlierReport(cfg *OutlierReport) (*OutlierReport, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid outlier report config [nil]")
	}

	reportCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.OutlierReportCIDRegex, reportCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid outlier report CID [%s]", reportCID)
	}

	jsonCfg, err := json.Marshal(cfg)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] update outlier report, sending JSON: %s", string(jsonCfg))
	}

	result, err := a.Put(reportCID, jsonCfg)
	if err != nil {
		return nil, err
	}

	report := &OutlierReport{}
	if err := json.Unmarshal(result, report); err != nil {
		return nil, err
	}

	return report, nil
}
func ( a * API ) UpdateOutlierReport ( cfg * OutlierReport ) ( * OutlierReport , error ) { if cfg == nil { return nil , fmt . Errorf ( " " ) } reportCID := string ( cfg . CID ) matched , err := regexp . MatchString ( config . OutlierReportCIDRegex , reportCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , reportCID ) } jsonCfg , err := json . Marshal ( cfg ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( jsonCfg ) ) } result , err := a . Put ( reportCID , jsonCfg ) if err != nil { return nil , err } report := & OutlierReport { } if err := json . Unmarshal ( result , report ) ; err != nil { return nil , err } return report , nil }
// UpdateOutlierReport updates passed outlier report.
UpdateOutlierReport updates passed outlier report .