Beispiel #1
0
func ConfigureFromFile(req *wcg.Request, filepath string, overwrite bool) error {
	// gates
	var gateConfigs []*models.Gate
	if err := lib.LoadJSONFileToStruct(filepath, &gateConfigs); err != nil {
		return err
	}
	updates := make([]*models.Gate, 0)
	for _, cfg := range gateConfigs {
		current := Get(req, cfg.Key)
		if current != nil && len(current.UIDs) > 0 && !overwrite {
			continue
		}
		updates = append(updates, cfg)
	}

	if err := PutMulti(req, updates...); err != nil {
		return err
	}
	req.Logger.Infof("Loaded Gates from %s", filepath)
	return nil
}
Beispiel #2
0
func ConfigureFromFile(req *wcg.Request, filepath string, overwrite bool) error {
	// site config
	var serverConfigs []*models.ServerConfig
	if err := lib.LoadJSONFileToStruct(filepath, &serverConfigs); err != nil {
		return err
	}
	updates := make([]*models.ServerConfig, 0)
	for _, cfg := range serverConfigs {
		if GetValue(req, cfg.Key) != "" && !overwrite {
			continue
		}
		updates = append(updates, cfg)
	}

	if err := PutMulti(req, updates...); err != nil {
		return err
	}
	req.Logger.Infof("Loaded ServerConfig from %s", filepath)
	return nil

}