Пример #1
0
func (c *MinHostsPerCluster) Config(config *configuration.Parameters) error {
	if config == nil {
		return errors.New("Configuration must be not nil")
	}

	constraint_id, ok := (*config)["constraint-id"].(string)
	if !ok {
		return checkers.NewInvalidParameterError("constraint-id")
	}
	c.constraintId = constraint_id

	return nil
}
Пример #2
0
func getParam(config interface{}, key string) (string, error) {
	switch t := config.(type) {
	case *configuration.Parameters:
		if value, ok := (*t)[key]; ok {
			return fmt.Sprint(value), nil
		}
	case map[interface{}]interface{}:
		if value, ok := t[key]; ok {
			return fmt.Sprint(value), nil
		}
	}

	return "", checkers.NewInvalidParameterError(key)
}