Exemple #1
0
func readConfig(reader io.Reader) (*api.RunOnceDurationConfig, error) {
	obj, err := configlatest.ReadYAML(reader)
	if err != nil {
		return nil, err
	}
	if obj == nil {
		return nil, nil
	}
	config, ok := obj.(*api.RunOnceDurationConfig)
	if !ok {
		return nil, fmt.Errorf("unexpected config object %#v", obj)
	}
	errs := validation.ValidateRunOnceDurationConfig(config)
	if len(errs) > 0 {
		return nil, errs.ToAggregate()
	}
	return config, nil
}
Exemple #2
0
func readConfig(reader io.Reader) (*api.RunOnceDurationConfig, error) {
	config := &api.RunOnceDurationConfig{}
	if reader == nil || reflect.ValueOf(reader).IsNil() {
		return config, nil
	}
	configBytes, err := ioutil.ReadAll(reader)
	if err != nil {
		return nil, err
	}
	err = configlatest.ReadYAML(configBytes, config)
	if err != nil {
		return nil, err
	}
	errs := validation.ValidateRunOnceDurationConfig(config)
	if len(errs) > 0 {
		return nil, errs.ToAggregate()
	}
	return config, nil
}